wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Quiz 2

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.
How do you display text?
a)
input
b)
output
c)
print
d)
variable 
2.

Which of the following function convert a string to a float in python?

a)

int(x,[,base])

b)

long(x,[base])

c)

float(x)

d)

str(x)

3.
This operator means that one value is the same as the other value
a)
==
b)
!=
c)
>
d)
<
4.
stores a piece of data, and gives it a specific name
a)
variable
b)
whitespace
c)
interpreter
d)
modulo
5.
The correct way to write a variable in Python?
a)
my_variable = 10
b)
my variable = 10
c)
my_variable is 10
d)
my_variable: 10
6.
Which of these would work as a piece of code?
a)
IF answer == "Yes":
b)
if answer == "Yes"
c)
if answer == "Yes":
d)
if answer = "yes":
7.

It is possible to execute both the statements under if and else at the same time.

a)

TRUE

b)

FALSE

8.

There can be an else statement without an if statement

a)

FALSE

b)

TRUE

9.
A _____________ expression is an expression that is either true or false. 
a)
boolean
b)
truth
c)
variable
d)
conditional
10.

What is does this code display?

a)

You are in primary school.

b)

You are in secondary school.

c)

You are not in school.

d)

Nothing.

11.

Which logic operator is used when only one condition has to be true?

a)

and

b)

or

c)

not

12.

What does the 'not' logic operator do?

a)

Nothing.

b)

Changes an if statement so that the condition needs to be true.

c)

Changes an if statement so that the condition needs to be false.

d)

Changes a value.

13.

What is the difference between complex and simple conditions?

a)

Complex conditions have more than one condition.

b)

Simple conditions have more than one condition.

c)

Complex conditions use the 'not' operator.

d)

Only simple conditions can use logic operators.

14.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
15.

What will this code output?

a)

Fizz

b)

Buzz

c)

True

d)

False

16.

What would be printed by the command

print("12-5")

a)

12-5

b)

'12-5'

c)

7

d)

'7'

17.

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")

a)

x is 0

b)

x is greater than 1

c)

x is greater than 3

18.

How did python get its name?

a)

The creator invented it whilst in hospital from a snake bite

b)

The code is written in a snaking structure

c)

The creator named it after Marty Python

d)

The creator named it after Monty Python

19.

In input/process/output, what is process?

a)

The whole program.

b)

What information comes out of the program.

c)

What the user types in to the program.

d)

How the program modifies the information it has received in order to produce the output.

20.

What function converts a string to an integer?

a)

float()

b)

str()

c)

int()

d)

bool()