#### PRG - Midterm 2021 ####

# This is the assignment for the PRG midterm test. This file is a valid Python module, instructions
# are written in the form of comments. Follow the instructions precisely and please note:
#
# - If the module executes any functions when imported (e.g. print), points will be subtracted.
# - If the module fails to be imported (due to errors), the solution is invalid.


#### TASK 1 ####

PI = 3.14


def circle_area(radius):
    """Compute the circle area for a given radius"""
    if radius < 0:
        raise ValueError("Negative radius not supported")
    area = PI * radius ** 2
    return area

# With the above functions and variables defined, we want to know the namespace (also scope)
# of all used identifiers (with respect to the circle_area function). In the dictionary
# 'namespace_types' below, replace "???" with the namespace type for each identifier. Valid options
# are "local", "nonlocal", "global", "builtin", "variable", "constant", "function", "module".

namespace_types = {
    "PI": "???",
    "circle_area": "???",
    "radius": "???",
    "ValueError": "???",
    "area": "???",
}


#### TASK 2 ####

# Fill in the body of the function below according to its docstring. Make sure it has no
# side-effects (e.g. prints).

def sines(angles):
    """Compute the sine for each element in given list 'angles'. Uses functions from module 'math'.

    :param angles: List of angles in degrees
    :return: List of sines corresponding to the input list

    Examples
    >>> sines([0, 30, 90])
    [0.0, 0.49999999999999994, 1.0]
    """


#### TASK 3 ####

# Fill all the question marks in the docstring below and rename 'function', 'parameter', 'variable'
# and 'result'.

def function(parameter):
    """???

    :param parameter: ???
    :return: ???

    Examples
    >>> function(???)
    ???
    """
    result = ""
    for variable in parameter:
        if variable.lower() in "aeiouy":
            continue
        result += variable
    return result


#### TASK 4 ####

# Fix as many offences against best practices as you can find. Do not rename the function or change
# its intended functionality.

def append_sum(sequence=[]):
    X = 0
    for SequenceElement in sequence:
        X += SequenceElement
    sequence.append(X)
    return sequence
    return None
