Grade 7 - UNIT 2 REVISION - PYTHON PROGRAMMING
Grade 7 - UNIT 2 REVISION - PYTHON PROGRAMMING
GRADE 7 – ICT/COMPUTING
FOR UNIT TEST 2 – PYTHON PROGRAMMING
Here are some of the practice questions taken from your Unit test. Answers are provided to you. (Highlighted
bold and in red)
Sequence
C. I live in location
When this program is executed, what will be displayed on the screen, as a result of executing
line 3?
Note: There may be errors in the program and/or it may not behave as expected.
A. I’ve never been to and whatever the user has typed at the keyboard
1 answer = 3 + 13 * 3
2 print("The Answer is", answer)
A. The Answer is 3 + 13 * 3
B. The Answer is 42
C. The Answer is 48
1 b = 42
2 a = 13
3 print(a,b)
A. 13 42
B. 42 13
C. a b
D. There is an error in the program because variables a and b are not assigned values in the
right order.
1 a = 13
2 a = 42
3 print(a)
A. 13
B. 42
C. 13 42
D. There is an error in the program because variable a cannot hold two values at the same
time.
1 a = 13
2 b = 42
3 a = b
4 print(a, b)
A. 13 42
B. 13 13
C. 42 13
D. 42 42
Q7. Read the Python program below:
1 a = 13
2 b = a + 1
3 print(a, b)
A. 13 14
B. 13 a+1
C. a b
D. There is an error in the program because when line 3 is executed, variable a no longer
has a value.
1 a = 13
2 a = a + 1
3 print(a)
A. 13
B. 14
C. 13 14
D. There is an error in the program because there are no values for variable a that could be
used in the equation in line 3.
1 a = 13
2 b = a + 1
3 a = 42
4 print(b)
A. 14
B. 43
C. 14 43
D. There is an error in the program because variable b cannot hold two values at the same
time.
Q10. Read the Python program below:
1 a = 13
2 print(2*a)
3 print(a)
When this program is executed, what will be displayed on the screen, as a result of executing
line 3?
Note: There may be errors in the program and/or it may not behave as expected.
A. 13
B. 26
C. 13 26
D. Line 3 will not be executed because there is an error in line 2: print cannot display
expressions such as 2*a.
Selection
When this program is executed, what will be displayed on the screen, if the user enters
Python at the prompt?
Note: There may be errors in the program and/or it may not behave as expected.
When this program is executed, what will be displayed on the screen, if the user enters
Python at the prompt?
Note: There may be errors in the program and/or it may not behave as expected.
When this program is executed, what will be displayed on the screen, if the user enters
Python at the prompt?
Note: There may be errors in the program and/or it may not behave as expected.
1 print("Enter a number")
2 number = int(input())
3 if number > 0:
4 print(number, "is positive")
5 else:
6 print(number, "is negative")
When this program is executed, what will be displayed on the screen if the user enters 0 at
the prompt?
A. 0 is positive
0 is negative
B. 0 is positive
C. 0 is negative
D. The program will not display anything because 0 is neither positive nor negative.
When this program is executed, what will be displayed on the screen, if the user enters 90 at
the prompt?
Note: There may be errors in the program and/or it may not behave as expected.
When this program is executed, what will be displayed on the screen, if the user enters 90 at
the prompt?
Note: There may be errors in the program and/or it may not behave as expected.
1 number = 13
2 if number == 0:
3 print("zero")
4 number = 0
C. 13
0
D. 13 0
zero
Q18. Read the Python program below:
1 number = 13
2 if number == 0:
3 print("zero")
4 else:
5 print(number)
6 number = 0
C. 13
zero
D. 13
zero
0
1 if number == 0:
2 print("zero")
3 else:
4 print(number)
5 number = 13
6 number = 0
A. There is an error in the program because when line 1 is executed, variable number
has not been assigned a value.
B. Nothing will be displayed on the screen.
C. 13
zero
D. 13
zero
0
Q20. Read the Python program below:
1 number = 13
2 if number < 10:
3 print("small")
4 if number < 100:
5 print("medium")
6 if number < 1000:
7 print("large")
A. small
B. medium
C. medium
large
D. large
Iteration
1 count = 3
2 while count > 0:
3 print(count)
4 count = count-1
A. None (the condition in line 2 will be False the first time it is checked)
B. 1
C. 3
D. 4
E. Infinitely (the condition in line 2 will never become False)
Q22. Read the Python program below:
1 count = 3
2 while count >= 0:
3 print(count)
4 count = count-1
A. None (the condition in line 2 will be False the first time it is checked)
B. 1
C. 3
D. 4
E. Infinitely (the condition in line 2 will never become False)
A. None (the condition in line 2 will be False the first time it is checked)
B. 1
C. 10
D. It is impossible to determine in advance
E. Infinitely (the condition in line 2 will never become False)
1 from random import randint
2 number = randint(1,10)
3 while number != 10:
4 number = randint(1,10)
5 print(number)
When this program is executed, what will be displayed on the screen, as a result of executing
line 5?
Note: There may be errors in the program and/or it may not behave as expected.
A. 10
B. 1
C. It is impossible to determine in advance
D. There is an error in the program, because line 5 should have been indented
1 pin = "1357"
2 correct = False
3 while correct == False:
4 print("Enter pin")
5 user = input()
6 if user == pin:
7 print("Welcome")
When this program is executed, how many times will line 4 be executed?
Note: There may be errors in the program and/or it may not behave as expected.
When this program is executed, what will be displayed on the screen after
line 6 is executedand the user types 1357 on the keyboard?
Note: There may be errors in the program and/or it may not behave as expected.
B. Wrong
pin, try
again
Welcome
C. Welcome
D. Wrong
pin, try
again
Enter
pin