wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Who developed the Python programming language?

a)

Rasmus Lerdorf

b)

Wick van Rossum

c)

Guido van Rossum

d)

Niene Stom

2.

Python was first developed as a successor for which programming language?

a)

Perl

b)

C

c)

Cobra

d)

ABC

3.

In which language is Python written ?

a)

C

b)

C++

c)

Java

d)

ABC

4.

 

The Python Enhancement Proposal (PEP) that enumerates stylistic guidelines for Python code is:

a)

PEP 257

b)

PEP 8000

c)

PEP 20

d)

PEP 8

5.

Which method can be used to remove any whitespace from both the beginning and the end of a string?

a)

trim()

b)

strip()

c)

len()

d)

replace()

6.

Dictionary keys must be immutable

a)

True

b)

False

7.

Which method can be used to replace parts of a string?

a)

replace()

b)

repl()

c)

replaceString()

d)

switch()

8.

What is a correct syntax to return the first character in a string?

a)

x = "Hello"[0]

b)

x = sub("Hello", 0, 1)

c)

x = "Hello".sub(0, 1)

d)

All of the above

9.

What will be the output:

a)

53

b)

abc

c)

ab

d)

Error

10.

What is the correct syntax to output the type of a variable or object in Python?

a)

print(typeof(x))

b)

print(typeOf(x))

c)

print(type(x))

d)

print(typeof x)

11.

What will be the output:

a)

1#2

b)

1#2#2

c)

1

d)

Error

12.

Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?

a)

Error

b)

None

c)

2

d)

25

13.

What will be the output:

a)

global

b)

local

c)

none

d)

Cannot be predicted

14.

What will be the output:

a)

('string', 197, 66, 55, 44)

b)

(44, 55, 66, 197, 'string')

c)

None

d)

(44, 55, 66, 197)

15.

 

Suppose t = (1, 2, 4, 3), which of the following is incorrect?

a)

print(t[3])

b)

print(max(t))

c)

print(len(t))

d)

t[3]=45