Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Programming Quiz

Total questions: 12

Worksheet time: 14mins

Name
Class
Date
1.

State True or False- “continue keyword skips remaining part of an iteration in a loop”

4 lines
2.

State the correct output of the following code- S1= “India is on the Moon” A=S1.split("o",3) print(A)

a)

['India is ', 'n the M', ' ', 'n']

b)

'India is ', 'n the M', ' ', 'n'

c)

['India is n ', 'the ', ' ', 'Mn']

d)

['India is', 'the', 'n']

3.

Identify the output of the following code snippet: text = "PYTHONPROGRAM" text=text.replace('PY','#') print(text)

a)

#THONPROGRAM

b)

##THON#ROGRAM

c)

#THON#ROGRAM

d)

#YTHON#ROGRAM

4.

str1=" Programming " str2=" is My Junoon" str3=str1.strip()+str2.replace("J", "j").lstrip() print(str3.partition("My"))

a)

('Programmingis ', 'My', ' junoon')

b)

['Programmingis ', 'My', ' junoon']

c)

['Programming is ', 'My', ' Junoon']

d)

(('Programmingis ', 'My', ' Junoon')

5.

What will be the output of the following code snippet? message= "Olympics 2024" print(message[-2::-4])

4 lines
6.

Given the following tuple- T1= (10,30,20,50,40) Which of the following statement will result an error?

a)

print(T1[0])

b)

print(len(T1))

c)

print(T1[-4:3])

d)

print(T1.insert(2,3))

7.

If dict1 is a dictionary defined below, then which of the following will raise an exception? dict1={“Dhoni”:95,”Virat”:99,”Rohit”:100}

a)

print(str(dict1))

b)

dict1.get(“Virat”)

c)

print(dict1([“Dhoni”,”Rohit”])

d)

dict1[“Rohit”]=158

8.

What does this statement will do in python >>>L1=[10,20,30] # Statement 1 >>>L1.insert(-3,1) # Statement 2 >>>print(L1) # Statement 3

a)

The statement 2 will insert the element -3 at index 1

b)

The statement 2 will insert the element 1 at index -3

c)

The statement 2 will insert the element 1 after the value 10

d)

The statement 2 will insert the element -3 after the value 30

9.

If a table which has one Primary key and two alternate keys. How many Candidate keys will this table have?

a)

1

b)

2

c)

3

d)

4

10.

Which of the following modes keeps the file offset position at the end of file?

a)

r

b)

w

c)

a

d)

r+

11.

What will be the output of the following Python statement: print(6-3**2**2+120/12)

4 lines
12.

What will be output of the following code? X=10 def exam(Y=20): X=30 Z=X+Y print(X,Z,end=”#”) exam(30) print(X,end=”$”)

a)

30 60#10$

b)

30 60 $10#

c)

30 10#10$

d)

30 50#10$