diff --git a/src/functions/test_function_annotations.py b/src/functions/test_function_annotations.py
index 4c6495e6..e730ce22 100644
--- a/src/functions/test_function_annotations.py
+++ b/src/functions/test_function_annotations.py
@@ -20,8 +20,11 @@ def breakfast(ham: str, eggs: str = 'eggs') -> str:
"""
return ham + ' and ' + eggs
+def number(n: int) -> bool:
+ return n > 10
def test_function_annotations():
"""Function Annotations."""
assert breakfast.__annotations__ == {'eggs': str, 'ham': str, 'return': str}
+ assert number.__annotations__ == {'n': int, 'return': bool}
\ No newline at end of file
diff --git a/src/functions/test_function_arbitrary_arguments.py b/src/functions/test_function_arbitrary_arguments.py
index 2b00d176..ff03f592 100644
--- a/src/functions/test_function_arbitrary_arguments.py
+++ b/src/functions/test_function_arbitrary_arguments.py
@@ -31,3 +31,4 @@ def concat(*args, sep='/'):
assert concat('earth', 'mars', 'venus') == 'earth/mars/venus'
assert concat('earth', 'mars', 'venus', sep='.') == 'earth.mars.venus'
+ assert concat('earth', 'mars', 'venus', 'mercury', 'jupyter', sep=' ') == 'earth mars venus mercury jupyter'
diff --git a/src/functions/test_function_decorators.py b/src/functions/test_function_decorators.py
index 1603a5ff..1c982241 100644
--- a/src/functions/test_function_decorators.py
+++ b/src/functions/test_function_decorators.py
@@ -64,7 +64,6 @@ def greeting_with_div_p(name):
return "Hello, {0}!".format(name)
assert greeting_with_div_p('John') == '
'
-
# One important thing to notice here is that the order of setting our decorators matters.
# If the order was different in the example above, the output would have been different.
@@ -83,9 +82,10 @@ def func_wrapper(name):
return func_wrapper
return tags_decorator
+ @tags('body')
@tags('div')
@tags('p')
def greeting_with_tags(name):
return "Hello, {0}!".format(name)
- assert greeting_with_tags('John') == ''
+ assert greeting_with_tags('John') == ''
diff --git a/src/functions/test_function_default_arguments.py b/src/functions/test_function_default_arguments.py
index aa2a09ad..f7357ab4 100644
--- a/src/functions/test_function_default_arguments.py
+++ b/src/functions/test_function_default_arguments.py
@@ -24,3 +24,4 @@ def test_default_function_arguments():
# We may also want to override the second argument by using the following function calls.
assert power_of(3, 2) == 9
assert power_of(3, 3) == 27
+ assert power_of(2) == 4
diff --git a/src/functions/test_function_definition.py b/src/functions/test_function_definition.py
index 82a0b50b..8fdf8953 100644
--- a/src/functions/test_function_definition.py
+++ b/src/functions/test_function_definition.py
@@ -90,9 +90,11 @@ def greet_one_more(name):
def call_func(func):
other_name = 'John'
- return func(other_name)
+ output = 'Welcome! '
+ output += func(other_name)
+ return output
- assert call_func(greet_one_more) == 'Hello, John'
+ assert call_func(greet_one_more) == 'Welcome! Hello, John'
# Functions can return other functions. In other words, functions generating other functions.
diff --git a/src/functions/test_function_keyword_arguments.py b/src/functions/test_function_keyword_arguments.py
index 7b6ff1c3..0b60a9c9 100644
--- a/src/functions/test_function_keyword_arguments.py
+++ b/src/functions/test_function_keyword_arguments.py
@@ -103,17 +103,19 @@ def function_with_one_argument(number):
# (*name must occur before **name.) For example, if we define a function like this:
def test_function(first_param, *arguments, **keywords):
"""This function accepts its arguments through "arguments" tuple and keywords dictionary."""
- assert first_param == 'first param'
- assert arguments == ('second param', 'third param')
+ assert first_param == 'new param'
+ assert arguments == ('first param','second param', 'third param')
assert keywords == {
'fourth_param_name': 'fourth named param',
'fifth_param_name': 'fifth named param'
}
test_function(
+ 'new param',
'first param',
'second param',
'third param',
fourth_param_name='fourth named param',
fifth_param_name='fifth named param',
+
)
diff --git a/src/functions/test_function_unpacking_arguments.py b/src/functions/test_function_unpacking_arguments.py
index 2e231b2f..35319df8 100644
--- a/src/functions/test_function_unpacking_arguments.py
+++ b/src/functions/test_function_unpacking_arguments.py
@@ -23,8 +23,8 @@ def test_function_unpacking_arguments():
assert list(range(*arguments_list)) == [3, 4, 5]
# In the same fashion, dictionaries can deliver keyword arguments with the **-operator:
- def function_that_receives_names_arguments(first_word, second_word):
- return first_word + ', ' + second_word + '!'
+ def function_that_receives_names_arguments(first_word, second_word, third_word):
+ return first_word + ', ' + second_word + '! ' + third_word
- arguments_dictionary = {'first_word': 'Hello', 'second_word': 'World'}
- assert function_that_receives_names_arguments(**arguments_dictionary) == 'Hello, World!'
+ arguments_dictionary = {'first_word': 'Hello', 'second_word': 'World', 'third_word': 'Bye'}
+ assert function_that_receives_names_arguments(**arguments_dictionary) == 'Hello, World! Bye'
diff --git a/src/functions/test_lambda_expressions.py b/src/functions/test_lambda_expressions.py
index f4eb1288..63e0272d 100644
--- a/src/functions/test_lambda_expressions.py
+++ b/src/functions/test_lambda_expressions.py
@@ -29,6 +29,6 @@ def make_increment_function(delta):
# Another use of lambda is to pass a small function as an argument.
pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]
# Sort pairs by text key.
- pairs.sort(key=lambda pair: pair[1])
+ pairs.sort(key=lambda pair: pair[0], reverse = True)
- assert pairs == [(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]
+ assert pairs == [(4, 'four'), (3, 'three'), (2, 'two'), (1, 'one')]