Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PythonDS

Total questions: 15

Worksheet time: 11mins

Name
Class
Date
1.
What letter will be printed on the screen after running this code:
a)
e
b)
x
c)
t
d)
Nothing prints
2.
In a list called "players" if you wanted to delete the item with an index of 3 which of the following examples of code would be correct?
a)
players.pop[3]
b)
players.delete(3)
c)
players.remove(3)
d)
players.pop(3)
3.

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

4.

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

5.

The program above prints the sum of all the numbers between 0 and 101 that are

a)

alternate odd numbers

b)

alternate even numbers

c)

alternate numbers

6.

What is the output of the program above

a)

10

b)

15

c)

18

d)

17

e)

16

7.

What is the value of the variable sum after the code above executes

a)

54

b)

44

c)

64

d)

34

e)

74

8.

What does this program print

a)

2 + 2 = 4

4 + 4 = 8

8 + 8 = 16

16 + 16 = 32

32 + 32 = 64

b)

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

c)

2 + 2 = 4

2 + 4 = 6

2 + 6 = 8

2 + 8 = 10

2 + 10 = 12

d)

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

e)

2 + 2 = 4

2 + 4 = 6

2 + 6 = 8

2 + 8 = 10

9.

The code snippet above outputs

a)

error

b)

None

c)

NaN

d)

-1

10.

The output of the code above is

a)

Key Error

b)

4

c)

Math

11.

The code above prints

a)

Math

Physics

Chemistry

English

b)

4

3.8

3.6

3.7

c)

None

None

None

None

d)

NaN

NaN

NaN

NaN

12.

What is the output of the program above

a)

e

b)

y

c)

t

d)

g

13.

The output of the code above is

a)

[101, 102, 103, 104]

b)

[3.6, 3.7, 3.8, 4]

14.

Assume the key is the student's id and the value is the grade. Which of the following code will get the grade of student id 102.

a)

grades[102]

b)

grades.get(102)

c)

grades[2]

d)

grades[3]

e)

grades.key(102)

15.

Which of the following code deletes the key 103 and its value

a)

del grades[103]

b)

grades.pop(103)

c)

del grades["103"]

d)

grades.pop("103")

e)