wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

python basics

Total questions: 20

Worksheet time: 12mins

Name
Class
Date
1.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
2.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
3.

x = 5

y = 6

print(x*y)


The code above displays the following:

a)

11

b)

x*y

c)

Syntax Error

d)

30

4.

What does the following code do? myAge = int (myAge)

a)

Converts the var (variable) myAge to a string

b)

Converts the var (variable) myAge to a integer

c)

Converts the var (variable) myAge from a integer to a string

d)

Converts the var (variable) myAge to if statement

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

people = ["John", "Rob", "Bob"]

print (people[-1])

what would this result be?

a)
John
b)
Rob
c)
Bob
7.

What is the output of program below?


mariana_islands = ['Saipan', 'Tinian', 'Rota']

mariana_islands.remove('Tinian')

print(mariana_islands)

a)

['Saipan', 'Tinian', 'Rota']

b)

['Tinian', 'Rota']

c)

['Saipan', 'Tinian']

d)

['Saipan', 'Rota']

8.

What is the index of the name 'Paula' in the following list:

names = ["Paul","Phillip","Paula","Phillipa"]

a)

0

b)

1

c)

2

d)

3

9.

What is the output of program below?


mariana_islands = ['Saipan', 'Tinian', 'Rota']

mariana_islands[0] = 'Guam'

print(mariana_islands)

a)

['Saipan', 'Tinian', 'Rota']

b)

['Guam', 'Tinian', 'Rota']

c)

['Saipan', 'Tinian', 'Rota', 'Guam']

d)

['Guam', 'Saipan', 'Tinian', 'Rota']

10.

Select the correct answer:


x = 15

y = 4


print(x // y)

a)

3

b)

3.75

c)

4

d)

5

11.
Max has written this program in Python.
One of the lines contains at least one error.
Which line is it?
a)
Line 1
b)
Line 2
c)
Line 3
d)
Line 4
12.

The program above

a)

prints all the odd numbers between 1 and 20

b)

prints all even numbers between 1 and 20

c)

print all the odd numbers between 1 and 21

d)

prints all the even numbers between 1 and 21

13.

The above program prints

a)

Numbers 1 to 10 in reverse order

b)

Numbers 1 to 11 in reverse order

c)

Numbers 1 to 10

d)

Numbers 1 to 11

14.

The code above prints all numbers between 1 and 30 that are

a)

not divisible by 5

b)

divisible by 5

15.

nameList = ["John", "Harry", "Jesse", "John", "Marry", "Larry"]

print(nameList.count("John"))

What would be the output

a)

1

b)

2

c)

3

d)

Error

16.

variable.sort() will do what?

a)

Sort the list into alphabetical order

b)

Sort the list into reverse order

c)

Create a new list

d)

Error

17.

How to create a numeric variable age with a value of 10

a)

age = 10

b)

age = int(10)

c)

age = "10"

18.

age = '5'


In the code above, age is a

a)

string

b)

integer

c)

floating point

19.

Which symbol means "not equal to"

a)

%

b)

==

c)

!=

d)

**

20.

What symbol comes before a comment?

a)

$

b)

>>

c)

#

d)

!