Python Multiple Choice Questions(MCQs)& Answers

Sports GK Questions and Answers 2024 (Latest Updated)

Awards & Honours GK Questions 2024 (Latest Updated)

Questions
101 What is the output of the expression?

round(4.5676,2)?

A 4.5
B 4.6
C 4.57
D 4.56

Answer: 4.57
102 What is the output of the functions shown below?

divmod(10.5,5)

divmod(2.4,1.2)

A (2.00, 0.50) (2.00, 0.00)
B (2, 0.5) (2, 0)
C (2.0, 0.5) (2.0, 0.0)
D (2, 0.5) (2)

Answer: (2.0, 0.5) (2.0, 0.0)
Advertisement
Article and Schedule Quiz Start Test!
DOWNLOAD CURRENT AFFAIRS PDF FROM APP
103 What is the output of the function shown below?

hex(15)

A f
B 0xF
C 0Xf
D 0xf

Answer: 0xf
104 What is the output?

d = {"john":40, "peter":45}

d["john"]

A 40
B 45
C “john”
D “peter”

Answer: 40
105 What is the output of the following piece of code?

a={1:"A",2:"B",3:"C"}

print(a.get(1,4))

A 1
B A
C 4
D Invalid syntax for get method

Answer: A
106 What is the output of the following snippet of code?

total={}

def insert(items):

if items in total:

total[items] += 1

else:

total[items] = 1

insert('Apple')

insert('Ball')

insert('Apple')

print (len(total))

A 3
B 1
C 2
D 0

Answer: 2
107 What is the output of the following code?

a={}

a[2]=1

a[1]=[2,3,4]

print(a[1][1])

A [2,3,4].
B 3
C 2
D An exception is thrown

Answer:3
108 What is the output of the below program?

x = 50

def func():

global x

print('x is', x)

x = 2

print('Changed global x to', x)

func()

print('Value of x is', x)

A x is 50 Changed global x to 2 Value of x is 50
B x is 50 Changed global x to 2 Value of x is 2
C x is 50 Changed global x to 50 Value of x is 50
D None of the mentioned

Answer: x is 50 Changed global x to 2 Value of x is 2
109 What is called when a function is defined inside a class?
A Module
B Class
C Another function
D Method

Answer: Method
110 What is called when a function is defined inside a class?
A Module
B Class
C Another function
D Method

Answer: Method
111 What is the output of below program?

ef f(x, y, z): return x + y + z

f(2, 30, 400)

A 432
B 24000
C 430
D No output

Answer: 432
112 What is the output of the following piece of code?

def a(b):

b = b + [5]

c = [1, 2, 3, 4]

a(c)

print(len(c))

A 4
B 5
C 1
D An exception is thrown

Answer: 5
113 Which of the following statements create a dictionary?
A d = {}
B d = {“john”:40, “peter”:45}
C d = {40:”john”, 45:”peter”}
D All of the mentioned

Answer: All of the mentioned
114 What will be the output of the following Python code snippet?

d = {"john":40, "peter":45}

A “john”, 40, 45, and “peter”
B “john” and “peter”
C 40 and 45
D d = (40:”john”, 45:”peter”)

Answer: “john” and “peter”
115 What will be the output of the following Python code snippet?

d = {"john":40, "peter":45}

"john" in d

A True
B False
C None
D Error

Answer: True
116 What will be the output of the following Python code snippet?

d1 = {"john":40, "peter":45}

d2 = {"john":466, "peter":45}

d1 == d2

A True
B False
C None
D Error

Answer: False
117 What will be the output of the following Python code snippet?

d1 = {"john":40, "peter":45}

d2 = {"john":466, "peter":45}

d1 > d2

A True
B False
C Error
D None

Answer: Error
118 What will be the output of the following Python code snippet?

d = {"john":40, "peter":45}

d["john"]

A 40
B 45
C “john”
D “peter

Answer: 40
119 Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” what command do we use?
A d.delete(“john”:40)
B d.delete(“john”)
C del d[“john”]
D del d(“john”:40)

Answer:del d[“john”]
120 Suppose d = {“john”:40, “peter”:45}. To obtain the number of entries in dictionary which command do we use?
A d.size()
B len(d)
C size(d)
D d.len()

Answer: len(d)
Assam Direct Recruitment Test Series

Teacher Eligibility Test

Assam Direct Recruitment Test Series