wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python In Real Life Review

Total questions: 20

Worksheet time: 11mins

Name
Class
Date
1.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
2.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
3.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
4.
What would print (10 + 16) produce?
a)
20
b)
22
c)
24
d)
26
5.

What is a input?

a)

A function that allows us to ask the user to enter some data.

b)

To plug in something.

c)

Data displayed on a screen.

d)

A function

6.

x = 5

y = 6

print(x*y)


The code above displays the following:

a)

11

b)

x*y

c)

Syntax Error

d)

30

7.
Which symbol do we use if we want to add a comment to our code?
a)
@
b)
#
c)
*
d)
&
8.
What does an IF statement do?
a)
Closes the program
b)
Makes a decision
c)
Asks a question
9.

numbers = [5, 14 ,9, 17]

for number in numbers:

if number >= 9:

print (number)


The output will be?

a)

17

b)

9

c)

14

9

17

d)

14

17

10.
What will be printed after running this FOR loop:

for number in range(6):
 
    print(number)
a)
The number 6 
b)
The numbers 0 - 5
c)
The number 5
d)
The numbers 1 - 6
11.

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

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

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

d)

nameList = [John, Harry, Jesse, John, Harry, Harry]

12.

numbers = [2, 4, 6, 8]

for number in numbers:

print("hello!")

a)

2 hello! 4 hello! 6 hello! 8 hello!

b)

hello!

c)

2 4 6 8

d)

hello! hello! hello! hello!

13.

What is the output of this code?

a)

It would print 'So good to see you' infinite number of times

b)

There would be no output

c)

It would print an error message.

d)

It would print 'Enter correct code'.

14.

What is the final value of the variable 'number'?

(a)  

15.

What is the output of Following code?

List = ['spam', 2.0, 5, [10, 20]]

print(List[2])

(a)  

16.

What is the output of the following code?

list = []

list.append(1)

list.append(2.0)

list.append("vk")

print(list)

a)

[1, 2.0, 'vk']

b)

Error

c)

['vk', 1, 2.0]

d)

No putput

17.
What will the following code result in:

name = “Alison”
number = len(name)
print(number)
a)
4
b)
5
c)
6
d)
7
18.

name=input("What is your name? ")

print("Your name is " + name)

What will be displayed if the user types in "Bob"?

a)

Your name is name

b)

name

c)

Bob

d)

Your name is Bob

19.

A = random.______([1,2,3,4,5])

Value of A can be 1 to 5(including both)

a)

shuffle

b)

choice

c)

uniform

d)

none of these

20.

What is the minimum and maximum value of 'A' in the following statement..

import random

A=random.randint(2,30)

print(A)

a)

3 and 30

b)

2and 30

c)

2 and 29