

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Function Transformations
incomplete
2: Transformations Review
incomplete
3: More Transformations
incomplete
4: Why Transform?
incomplete
5: Function Transformations Practice
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Here's some example code for you to reference as you work through the assignment:
from collections.abc import Callable
def multiply(x: int, y: int) -> int:
return x * y
def add(x: int, y: int) -> int:
return x + y
def self_math(math_func: Callable[[int, int], int]) -> Callable[[int], int]:
def inner_func(x: int) -> int:
return math_func(x, x)
return inner_func
square_func: Callable[[int], int] = self_math(multiply)
double_func: Callable[[int], int] = self_math(add)
print(square_func(5))
# prints 25
print(double_func(5))
# prints 10
Complete the doc_format_checker_and_converter function. It takes a conversion_function and a list of valid_formats as parameters. It should return a new function that takes two parameters of its own:
filename: The name of the file to be convertedcontent: The content (body text) of the file to be convertedinvalid file format
.split() method on the filename to get the file extension. Then use the in keyword to check if a value is in a list.capitalize_content and reverse_content are "conversion functions" that will be passed into our doc_format_checker_and_converter function by the tests.