wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Module 1

Total questions: 25

Worksheet time: 12mins

Name
Class
Date
1.

What is the output of the following program:


y = 8

z = lambda x : x * y

print z(6)

a)

48

b)

14

c)

64

d)

None of the above

2.

Which of the following is the use of id() function in python?

a)

Id returns the identity of the object

b)

Every object doesn’t have a unique id

c)

All of the mentioned

d)

None of the mentioned

3.

Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)?

a)

[3, 4, 5, 20, 5, 25, 1, 3]

b)

[1, 3, 3, 4, 5, 5, 20, 25]

c)

[3, 5, 20, 5, 25, 1, 3]

d)

[1, 3, 4, 5, 20, 5, 25]

4.

How can we add two strings together?

a)

s.join(s2)

b)

s.add(s2)

c)

s = s + s2

d)

s ++ s2

5.
What will the output be from the following code?
print("Hello world!\nHello world!")
a)
Hello world! Hello world!
b)
Hello world!
Hello world!
c)
SyntaxError
d)
Hello world!
6.
What will the output be from the following code?
print("Hello" + str(2) + "world!")
a)
Hello world! Hello world!
b)
Hello2world!
c)
Hello Hello world! world!
d)
SyntaxError
7.
Code repeated / looped until a condition has been met or a set number of times.
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
8.

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

9.
What is python named after
a)
The snake
b)
Television show called Monty Python
10.
Decides if a string only contains numbers
a)
isalpha()
b)
isnumeric()
c)
int()
d)
string()
11.
Tells the interpreter that the code which follows is a function
a)
const
b)
int
c)
def
d)
while
12.
Python identifies blocks of code by
a)
BEGIN and END keywords
b)
{ and }
c)
aligning up the starts of lines (indentation)
d)
guessing
13.
If you want more than one option for your code, what do you use (after if)?
a)
elif
b)
else
c)
ifif
14.

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

print (people[1])

what would this result be?

a)
John
b)
Rob
c)
Bob
15.

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

print (people[-1])

what would this result be?

a)
John
b)
Rob
c)
Bob
16.

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

print (people[4])

what would this result be?

a)
John
b)
Rob
c)
Bob
d)
Error
17.
What is the name of the environment in Python that write your programs and then test them out?
a)
Shell
b)
Window
c)
IDLE
d)
CLI
18.
What extension must you add to the end of a file when saving?
a)
.xlsx
b)
.pptx
c)
.docx
d)
.py
19.
What symbol do you use to make a comment in Python?
a)
@
b)
¬
c)
;
d)
#
20.

Python strings can only contain letters

a)

True

b)

False

21.

A Variable Value in Python can not be updated

a)

True

b)

False

22.

What function determines the data type?

a)

Print()

b)

Type

c)

Print

d)

Type()

23.
What will the output be from the following code?
print("3*4+5")
a)
SyntaxErrror
b)
17
c)
3*4+5
d)
12
24.
What will the output be from the following code?
print(9/3)
a)
3
b)
3.0
c)
9/3
d)
SyntaxError
25.
What is a variable?
a)
The set of rules governing the order in which expressions involving multiple operators and operands are evaluated.
b)
A name that refers to a value.
c)
A category of values. The types we have seen so far are integers (type int), floating-point numbers (type float), and strings (type str).
d)
One of the basic units of data, like a number or string, that a program manipulates.