0% found this document useful (0 votes)
12 views3 pages

Worksheet 1intro To Python Programming - Y8

This document is a classwork assignment for Year 8 students introducing Python programming. It includes tasks that require students to analyze and modify Python code, including predicting outputs based on user input and rearranging code for meaningful interaction. Additionally, students are tasked with completing a program that converts miles to kilometers based on user input.

Uploaded by

y6996545
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Worksheet 1intro To Python Programming - Y8

This document is a classwork assignment for Year 8 students introducing Python programming. It includes tasks that require students to analyze and modify Python code, including predicting outputs based on user input and rearranging code for meaningful interaction. Additionally, students are tasked with completing a program that converts miles to kilometers based on user input.

Uploaded by

y6996545
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Year 8 – Intro to Python programming ClassWork

Lesson 2 – Crunching numbers

Classwork
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 1 mark
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 the answer

B. 40

C. 10 + 10 * 2

D. 10 + num1 * 2

Question 2 1 mark
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: 3 marks

Task 3 . 5 marks
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.

Page 3

You might also like