NEW
Font size
WorksheetsPython Quiz 2
Total questions: 20
Worksheet time: 10mins
Which of the following function convert a string to a float in python?
int(x,[,base])
long(x,[base])
float(x)
str(x)
It is possible to execute both the statements under if and else at the same time.
TRUE
FALSE
There can be an else statement without an if statement
FALSE
TRUE
What is does this code display?
You are in primary school.
You are in secondary school.
You are not in school.
Nothing.
Which logic operator is used when only one condition has to be true?
and
or
not
What does the 'not' logic operator do?
Nothing.
Changes an if statement so that the condition needs to be true.
Changes an if statement so that the condition needs to be false.
Changes a value.
What is the difference between complex and simple conditions?
Complex conditions have more than one condition.
Simple conditions have more than one condition.
Complex conditions use the 'not' operator.
Only simple conditions can use logic operators.
name = 'Dave'
print (name)
What will this code output?
Fizz
Buzz
True
False
What would be printed by the command
print("12-5")
12-5
'12-5'
7
'7'
What is the output of the code below?
x = 5
if x == 0:
print("x is 0")
elif x > 1:
print("x is greater than 1")
elif x > 3:
print("x is greater than 3")
x is 0
x is greater than 1
x is greater than 3
How did python get its name?
The creator invented it whilst in hospital from a snake bite
The code is written in a snaking structure
The creator named it after Marty Python
The creator named it after Monty Python
In input/process/output, what is process?
The whole program.
What information comes out of the program.
What the user types in to the program.
How the program modifies the information it has received in order to produce the output.
What function converts a string to an integer?
float()
str()
int()
bool()
