wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PYTHON QUIZ

Total questions: 20

Worksheet time: 12mins

Name
Class
Date
1.
In python the ' STRING data type' can be defined as...?
a)
holds alphanumeric text
b)
hold whole numbers
c)
holds numbers with a decimal point
d)
holds either a true or false value
2.
In python the ' INTEGER data type' can be defined as...?
a)
holds alphanumeric data as text
b)
holds whole numbers
c)
holds numbers with a decimal point
d)
holds either ‘true’ or ‘false’
3.
In python the ' FLOAT data type' can be defined as...?
a)
holds alphanumerical data
b)

holds whole numbers

c)

holds a decimal point in a number

d)
hold either true or false
4.
What is the correct definition for a VARIABLE?
a)
a changeable value, such as a score in a computer game.
b)
a value that cannot be changed
5.
10= 100
Which of the following is used in Python to calculate ten squared?
a)
10 ** 2
b)
10 * 2
c)
10 % 2
d)
10 ** 10
6.
What will the output be from the following code?
print("3+4")
a)
7
b)
3+4
c)
34
d)
SyntaxError
7.

Gjdk is not a good name for a variable, why?

a)

It starts with a capital letter.

b)

It does not contain any spaces.

c)

There are no vowels.

d)

It's meaningless.

8.

Variable names can start with...

a)

...only capital letters.

b)

...any number, letter or an underscore (_).

c)

...any letter or symbol.

d)

...any letter or an underscore (_).

9.

You are asked to write a program where the user types in the amount of marks they got for a paper with 70 marks. The program then calculates and displays their score as a percentage. What is the process?

a)

marks (integer)

b)

percentage (float)

c)

percentage = marks/100*70

d)

percentage = marks/70*100

10.

Guess the output:


a = 255

b = 255

print(a == b)

a)

True

b)

False

11.
To get the users input what function do we use?
a)
Input
b)
input<> 
c)
input() 
d)
INPUT()
12.
Why do we use variables in programming?
a)
edit data
b)
store data
c)
integer
d)
to look good
13.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
14.
A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly
a)
True
b)
False
15.

If you want to create an empty list called colours in Python, which of the following is correct?

a)

colours = [ ]

b)

colours = ( )

c)

colours = { }

d)

colours = <>

16.

What letter will be printed on the screen after running this code:

a)

n

b)

e

c)

a

d)

Nothing prints

17.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Mac, Donald, Colonel, Tony

b)

nameList = ("John", "Harry", "Mac", "Donald", "Colonel", "Tony")

c)

nameList = ["John", "Harry", "Mac", "Donald", "Colonel", "Tony"]

d)

nameList = [John, Harry, Mac, Donald, Colonel, Tony]

18.

List items have an index number. In the following list, which item has the index number of 3?

["John", "Harry", "Mac", "Donald", "Colonel", "Tony"]

a)

"Tony"

b)

"Harry"

c)

"Mac"

d)

"Donald"

19.

The list needs one more name added to the end - "Stark". Which piece of code below would do this?

nameList = ["John", "Harry", "Mac", "Donald", "Colonel", "Tony"]

a)

nameList.append(Stark)

b)

append(nameList,"Stark")

c)

nameList.append["Stark",7]

d)

nameList.append("Stark")

20.

What will be the output?

tuple1=['sam', "Pam", 12,44]

print(type(tuple1))

a)

<class 'list'>

b)

<class 'tuple'>