Python · Exercise 1 of 5Next
Beginner
Annotate a function
The function scale multiplies every number in a list by a factor. It has no type hints yet. Add them: values is a list[float], factor is a float, label is a str or None (default None), and the function returns a list[float].
Write each hint as name: type and keep = None after the hint for label. Do not change what the function does. The last line, already in the starter, prints the result for [1.0, 2.0] and 2.0.
What Check tests
valuesis hintedlist[float]factoris hintedfloatlabelis hintedstr | Noneand still defaults to None- The return value is hinted
list[float] - The behaviour is unchanged
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.