WorksheetsCONDITIONAL STATEMENTS
Total questions: 25
Worksheet time: 21mins
FOR loops are
loops which run an unknown number of times
loops which run for a specific number of times
the same as if statements
not part of programming
WHILE loops are
loops which run an unknown number of times
loops which run for a specific number of times
the same as if statements
not part of programming
In a Python program, what would be the ending value for y in the WHILE LOOP code?
5
51
10
3
In a Python program, what would be the ending value of total in the WHILE LOOP code?
0
5
2
20
In a Python program, what would be the increment value for the looping variable in the FOR LOOP code?
15
7
10
1
4
3
2
1
3
2
1
0
What are the three main programming structures?
Sequence, selection, iteration
Structured, object-oriented, procedural
Java, Python, Visual Basic
Machine, assembly, high-level
Write the line of code which initialize the counter variable
x<20
x=x+1
name=input("Enter your name")
x=0
What will this code display?
a = 6
if a => 6:
print("pass")
else:
print("fail")
pass
fail
nothing because there will be an error
passfail
What will this code print?
access denied
access granted
error
password
What is the error in this code?
incorrect variable name
incorrect indentation
incorrect speech marks
incorrect loop
In the above program if the value of 'x' is 23 and 'number' is 24, what will be the output?
23 24
23
23
24
3 4
if age is less than 20 and greater than equal or equal to 15 then
What would be outputted here?
Bigger than 2!
Number is 5
Bigger than 2!
Number is 5
Nothing
Error
What would be outputted here?
it divides by 7!
it divides by 3.
It divides by 7!
It divides by 3.
What will be printed to the screen?
Failure
Part of the way there!
Success
Nothing
The equivalent of the above for loop using the while syntax would be
The program above prints
Numbers between 1 and 100 that are multiples of 5
Numbers between 1 and 100
Numbers between 1 and 100 divisible by 5
Numbers between 1 and 101 that are multiples of 5
The program above prints the sum of all the numbers between 0 and 101 that are
alternate odd numbers
alternate even numbers
alternate numbers
The program above prints each number between 1 and 10
as many times as the number itself
10 times
11 times
What does this program print
2 + 2 = 4
4 + 4 = 8
8 + 8 = 16
16 + 16 = 32
32 + 32 = 64
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 4 = 6
2 + 6 = 8
2 + 8 = 10
2 + 10 = 12
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 4 = 6
2 + 6 = 8
2 + 8 = 10
print(str(i) * 5)
print("i" * i)
print("i" * i)
print(str(i) * i)
What is the value of num when this loop completes?
num = 0
for i in range(2, 8, 2):
num += i
2
8
12
20
