NEW
Font size
WorksheetsPython
Total questions: 72
Worksheet time: 40mins
What will be the output?
name = "Dave"
print (name)
Dave
'Dave'
name
(name)
It displays an output
holds whole numbers
holds a decimal point in a number
What is the output from the following code?
print ("hello world")
The requirements for printing a string in Python are:
( ) , ! and " "
( ) and !
( ) and " "
" " and !
Code for
Five is greater than two!
if 5 > 2:
print("Five is greater than two!")
if 5 = 2:
print("Five is greater than two!")
if 5 > 2: Print("Five is greater than two!")
print("Hello world!\nHello world!")
Hello world!
print("Hello" + str(2) + "world!")
What does the following code do? myAge = int (myAge)
Converts the var (variable) myAge to a string
Converts the var (variable) myAge to a integer
Converts the var (variable) myAge from a integer to a string
Converts the var (variable) myAge to if statement
How many variables are there in this program?
2
3
4
5
What would be the output of this program if the user input was 10?
22.04
220.4
2204
Error wrong data type
What operator is being used in this program?
less than
greater than
less than or equal to
greater than or equal to
What would be the output of this program if the user entered "yes" then "what"?
Enjoy your day
it is too windy for an umbrella
Take an umbrella
Error
What would be the output of this program if the user entered "Alien"
Alienway
wayAlien
lienAay
ayAlien
What data type represents a whole number?
Float
Int
Boolean
String
What data type represents a decimal number?
Float
Int
Boolean
String
What you the output of this program be if the user guessed "h"?
Error
It was heads
It was tails
Bad luck
What type of loop is being used in this program?
Count controlled
Condition Controlled
How many errors are there in this code?
1
2
3
4
How many errors are there in this piece of code?
0
1
2
3
The result of this program:
Friday = False
if Friday:
print "Jeans day!"
else:
print "Uniform day"
Jeans day
Today is Friday
Uniform day
Not Friday
What is the output?
condition
True
Program has a syntax error.
3 > 2
What is the output?
True
False
condition1
condition2
What is the output?
more than 7
more than 23
spam
7
What is the output?
250.0
200.0
300.0
350.0
What is the output?
next
stop
next
stop
syntax error - program doesn't work
What is the output?
3
3
7
3
5
7
7
What is the output?
True
NIL
True
NIL
True
NIL
NIL
What is the output?
level 3
level 3
level 1
level 3
level 1
NIL
level 3
level 2
level 1
NIL
Given the nested if-else below, what will be the value x when the code is executed successfully.
0
4
2
3
Given the nested if-else structure below, what will be the value of x after code execution completes.
2
0
3
4
What is the output of the following if statement?
False
True
What is the result of the code:
team = Cowboys
if team = Cowboys:
print(Dallas is #1)
Error
Cowboys
Team
Dallas is #1
Look at the following code, what will it generate
1,2,3,4,5,6,7,8,9,10,11,12
0,1,2,3,4,5,6,7,8,9,10,11,12
1,2,3,4,5,6,7,8,9,10,11,12,13
0,1,2,3,4,5,6,7,8,9,10,11,12,13
What does the following program display?
1,2,3,4
1,2,3,4,5
counter,counter,counter,counter,counter
0,1,2,3,4,5
1,2,3,4
#What is the output?
1,2,3,4,5
0,1,2,3,4
1,2,3,4
5,4,3,2,1
#How many hallos will be printed?
5
None
4
6
#What is the output?
a, b, c, d, e
a, a, a, a, a
0,1,2,3,4
e, d, c, b, a
word= "computer"
for num in range(1,6):
print(word)
for number in range(6):
print(number)
Which of the following programs prints ten lines?
for i in range(10):
print("hi")
for i = 1 to 10:
print("hi")
for i in 1 - 10:
print("hi")
for i from 0 to 9:
print("hi")
What would be the output of the following code:
for i in range(3):
print(i)
1 2 3
i i i i
i i i
0 1 2
Which of these will allow me to print all numbers from 0 to 4 ?
//0,1,2,3,4
for x in range(4):
print(x)
for x in range(0,4):
print(x)
for x in range(1,5):
print(x)
for x in range(5):
print(y)
How do you define the range of a for loop in Python?
By using the range() function with start, stop, and step parameters.
By using the len() function with the iterable as the parameter.
By using the start, stop, and step parameters directly in the for loop.
By using the range() function with only the stop parameter.
How many times does a for loop iterate if the range is (1, 5)?
4
2
1
3
What is the output of the following code? for i in range(5, 0, -1): print(i)
1
2
3
4
5
1
2
3
4
5
4
3
2
1
4
3
2
1
What is the output of the following code? for i in range(1, 6, 2): print(i)
1 2 3 4 5
1 2 3 4
1 3 5
1 3 5 7
What is the output of the following code?
0 1
0
1
Loop End
0
1
2
0
1
2
Loop End
What is the output of the following code?
0
3
0
1
1
2
0
2
What is the output of the following code?
0 2 Loop completed
0 1 Loop completed
0 1 2 Loop completed
0
2
What will this code do?
Print Numbers 1-11
Print Numbers 1-10
Print Numbers 2-10
Print Error
what will this display?
0,1,2,3,4,5
0,1,2,3,4
1,2,3,4,5
Error
