L2 Homework - Intro to Python programming - Y8
L2 Homework - Intro to Python programming - Y8
Homework
Task 1 .
Read the Python program below:
1 num1 = int(input())
2 num2 = 10 + num1 * 2
3 print(num2)
4 num1 = 20
5 print(num1)
Question 1
When this program is executed, if the user types 10 on the keyboard, what will be
displayed on the screen as a result of executing line 3?
A. 30
B. 40
C. 10 + 10 * 2
D. 10 + num1 * 2
Question 2
When this program is executed, if the user types 10 on the keyboard, what will be
displayed on the screen as a result of executing line 5?
A. 10
B. 20
C. 10 and 20
D. There is an error in the program because a variable cannot hold two values at the
same time
Task 3 .
The incomplete program below is supposed to prompt the user for a distance in miles,
and convert the distance that the user enters to kilometres.
Step 1
Complete line 2 so that the value assigned to the miles variable is obtained from what
the user types on the keyboard.
Page 2
Step 2
Complete line 3 so that the program calculates the value of the kilometres variable to
be the equivalent of the miles variable, converted to kilometres. Note that 1 mile is equal
to 1.60934 kilometres.
Resources are updated regularly — the latest version is available at: ncce.io/tcc.
This resource is licensed under the Open Government Licence, version 3. For more information on this
licence, see ncce.io/ogl.
Page 3