wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Quiz 3 - Python coding

Total questions: 20

Worksheet time: 12mins

Name
Class
Date
1.

Which one of the following is correct way of declaring and initializing a variable, x with value 5?

a)

int x

x=5

b)

int x=5

c)

x=5

d)

declare x=5

2.

Which of the following is not valid variable name in Python?

a)

_var

b)

var_name

c)

var11

d)

11var

3.

Which of the following statement is False?

a)

Variable names can be arbitrarily long.

b)

They can contain both letters and numbers.

c)

Variable name can begin with underscore.

d)

Variable name can begin with number.

4.

Which of the operator means less than equal to ?

a)

>

b)

<

c)

>=

d)

<=

5.

8. If, else and elif is used for…..

a)

Selection

b)

Indentation

c)

printing

d)

iteration

6.

what is the variable name in this code?

a)

print

b)

if

c)

secret

d)

password

7.

else: is used

a)

to give an extra condition

b)

to provide an output when the other conditions are false

c)

because it is required

d)

if we do not use it, it gives error

8.

What does this code do?

print("Hello world!")

a)

Displays 'Hello world!' in the shell window.

b)

Sends 'Hello world!' to the printer.

c)

Waits for the user to type in 'Hello world!'

d)

Displays 'hello, world.' in the shell window.

9.

What is an integer?

a)

A number with a decimal point.

b)

A whole number.

c)

An array of characters.

d)

A single character.

10.

In this code, how much does an apple cost?

a)

£1

b)

50p

c)

20p

d)

25p

11.

True or False:

There are no symbols which can be used in a variable name.

a)

True

b)

False

12.

What function converts the data in a variable into a 'float'?

a)

int()

b)

flt()

c)

bool()

d)

float()

13.

Comments are used to make code easier to read.

a)

True

b)

False

14.

What would the program display if you ran this code and entered 2 and then 3 when prompted?

a)

The total is 5.

b)

The total is 23.

c)

The total is 6.

d)

An error.

15.

True or False:

Python can be used to make games and phone apps.

a)

True

b)

False

16.
What function would I use to display text?
a)
sum
b)
import
c)
print
d)
display
17.
I need three of these to display a string of text?
a)
backslashs
b)
quotation marks
c)
apostrophes
d)
parenthesis 
18.
What is the correct name for a *?
a)
hashtag
b)
star
c)
loop
d)
asterisk
19.
What does a hashtag represent when using Python?
a)
red text
b)
float
c)
comment
d)
integer
20.

write the output of the program

a)

Thinley is in class 9A

b)

Thinley is in 9A

c)

Thinleyisin9A

d)

error