Skip to content

Question 39

Given below is an incomplete implementation of a function that prints out 10 multiples of the input n. Replace each blank with a valid Python expression/statement.

1
2
3
def print_10_multiples(n):
    for i in range(_____1_____):
        print(_____2_____)

Here is an example:

>>> print_10_multiples(3)
3
6
9
12
15
18
21
24
27
30

Note that your code needs to be syntactically correct to gain marks. You cannot use any semi-colon(;) and we will deduct marks if your answer is too long.

Model Solution
1
2
3
def print_10_multiples(n):
    for i in range(1, 11):
        print(n*i)
  • Blank 1: 1, 11
    • Notice that the sample run prints out multiples of 3 starting from 3 itself, and not 0. You will need to specify the start value in the range() function to not be 0 so not to produce a product n * i equal to 0.
  • Blank 2: n * i

Another acceptable pair:

  • Blank 1: 10
  • Blank 2: n * (i + 1)