0% found this document useful (0 votes)
2 views

L2 Homework – Intro to Python programming – Y8

This document is a homework assignment for Year 8 students focusing on Python programming. It includes tasks that require students to analyze a given Python program, rearrange code for user interaction, and complete a program for converting miles to kilometers. The document also provides multiple-choice questions and prompts for user input to reinforce programming concepts.

Uploaded by

SHANJAY RAJA
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

L2 Homework – Intro to Python programming – Y8

This document is a homework assignment for Year 8 students focusing on Python programming. It includes tasks that require students to analyze a given Python program, rearrange code for user interaction, and complete a program for converting miles to kilometers. The document also provides multiple-choice questions and prompts for user input to reinforce programming concepts.

Uploaded by

SHANJAY RAJA
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Year 8 – Intro to Python programming Homework

Lesson 2 – Crunching numbers

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

Page 1​ ​ ​ ​ ​ ​ ​ ​ ​ Last updated: 16-04-21


Task 2 .
Rearrange the lines in the Python program below, so that you have a runnable program
that holds a meaningful interaction with the user.

1 print("And where do you live", name)


2 print("I’ve never been to", location)
3 name = input()
4 print("What is your name?")
5 location = input()

Write your rearranged program below:

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.

1 print("Enter a distance in miles:")


2 miles = .
3 kilometres = .
4 print(miles, "miles is", kilometres, "km")

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​ ​ ​ ​ ​ ​ ​ ​ ​

You might also like