You are on page 1of 3

Year 9 – Python programming with sequences of data Activity solutions

Lesson 1 – Warm up

Let me check

Task 1 . Matching task


I would use... whenever I want to...

1. input A. perform actions repeatedly


2. print B. display to the screen
3. while C. check a condition, to select which actions to perform
4. if D. read from the keyboard
5. = E. assign a value to a variable

Answers

1 2 3 4 5

Task 2 . Walkthrough
Read the Python program below:
Note: There may be errors in the program and/or it may not behave as expected.

1 a = int(input())
2 b = int(input())
3 avg = b + a / 2
4 print(avg)

Question
When this program is executed, assuming the user types 12 and 2 on the keyboard, what will be
displayed on the screen?
A. 2 + 12 / 2
B. 13
C. 7
D. 8

Page 1 Last updated: 12-05-2021


Year 9 – Python programming with sequences of data Activity

Answer

Task 3 . Walkthrough
Read the Python program below:
Note: There may be errors in the program and/or it may not behave as expected.

1 a = int(input())
2 b = int(input())
3 max = a
4 if b > max:
5 max = b
6 print(max)

Question
When this program is executed, assuming the user types 12 and 2 on the keyboard, what will be
displayed on the screen?
A. Nothing will be displayed on the screen
B. 2
C. 12
D. max

Answer
Year 9 – Python programming with sequences of data Activity

Task 1 . Identify
Look at the Python program below:
Note: There may be errors in the program and/or it may not behave as expected.

1 a = int(input('Enter your first number:'))


2 b = int(input('Enter your second number:'))
3 print('Finding Maximum number...')
4 print()
5 avg = a + b / 2
6 max = a
7 if b > max:
8 max = b
print('The maximum number is ' + str(max))

List the variables in the program:

List the lines that contain assignments:

Identify an arithmetic expression in the


program and copy it here:

Identify a Boolean expression (a condition) in


the program and copy it here:

List the lines in the program that may never be


executed:

Task 2 . Online-Python.com
Go to the website: www.online-python.com
Write the line of codes in task 1 above
Run the program and write down the output
Change the greater than to a less than
Run the program again and write down the output.

You might also like