wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Introduction to Python

Total questions: 15

Worksheet time: 29mins

Name
Class
Date
1.

Which of the following is a command to have a message appear on the screen?

a)

print

b)

write

c)

msg

d)

input

2.

Which of the following Python command can be used for WHOLE numbers?

a)

input

b)

int

c)

float

d)

print

3.

Which of the following is a Python command to work with DECIMAL numbers?

a)

input

b)

int

c)

float

d)

print

4.

What would be printed by the command

print('12-5')

a)

12-5

b)

'12-5'

c)

7

d)

'7'

5.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
6.

Which of the following is used in Python to give a value to a variable

a)

:=

b)

==

c)

=

7.

What is the value(?) if theoutput is 12

x = 5

y = ?

print (x+y)

a)

"7"

b)

=7

c)

7

d)

/7

8.

Which one is NOT a valid variable name?

a)

my_var

b)

myvar

c)

_myvar

d)

my var

9.
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
10.

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 (_).

11.
Why do we use variables in programming?
a)
edit data
b)
store data
c)
integer
d)
to look good
12.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
13.

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 = <>

14.

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

a)

n

b)

e

c)

a

d)

Nothing prints

15.

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]