Advanced functions and decorators · 10 / 15 Exercise Easy

Multiplier factory

Objective

Create a Python program with a function that returns another function.

Instructions

  • Define def create_multiplier(factor), which defines inside a function multiply(x) that returns x * factor and returns it (without calling it).
  • Read the factor on the first line and, on the second, a list of integers separated by spaces.
  • Create the multiplier with create_multiplier(factor) and show on one line the results of applying it to each number, separated by spaces.
Input
3
1 2 3 4
Output
3 6 9 12

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise