Basic Python Multiple Choice Questions(MCQs)& Answers

Sports GK Questions and Answers 2024 (Latest Updated)

Awards & Honours GK Questions 2024 (Latest Updated)

Questions
81 What is the output of the code shown below?

import math

[str(round(math.pi)) for i in range (1, 6)]

A [‘3’, ‘3’, ‘3’, ‘3’, ‘3’, ‘3’]
B [‘3.1’, ‘3.14’, ‘3.142’, ‘3.1416’, ‘3.14159’, ‘3.141582’]
C [‘3’, ‘3’, ‘3’, ‘3’, ‘3’]
D [‘3.1’, ‘3.14’, ‘3.142’, ‘3.1416’, ‘3.14159’]

Answer: [‘3’, ‘3’, ‘3’, ‘3’, ‘3’]
82 What is the output of the code shown below?

t=32.00

[round((x-32)*5/9) for x in t]

A [0]
B 0
C [0.00]
D Error

Answer: Error
Advertisement
Article and Schedule Quiz Start Test!
DOWNLOAD CURRENT AFFAIRS PDF FROM APP
83 What is the output of the following?

print([i.lower() for i in "HELLO"])

A [‘h’, ‘e’, ‘l’, ‘l’, ‘o’].
B ‘hello’
C [‘hello’].
D hello

Answer: [‘h’, ‘e’, ‘l’, ‘l’, ‘o’].
84 Suppose list1 is [3, 5, 25, 1, 3], what is min(list1) ?
A 3
B 5
C 25
D 1

Answer: 1
85 Suppose list1 is [1, 3, 2], What is list1 * 2 ?
A [2, 6, 4].
B [1, 3, 2, 1, 3]
C [1, 3, 2, 1, 3, 2] .
D [1, 3, 2, 3, 2, 1]

Answer: [1, 3, 2, 1, 3, 2] .
86 What is the output when the following code is executed ?

"Welcome to Python".split()

A [“Welcome”, “to”, “Python”].
B (“Welcome”, “to”, “Python”)
C {“Welcome”, “to”, “Python”}
D “Welcome”, “to”, “Python”

Answer: [“Welcome”, “to”, “Python”].
87 What will be the output?

names1 = ['Amir', 'Bala', 'Charlie']

names2 = [name.lower() for name in names1]

print(names2[2][0])

A None
B a
C b
D c

Answer: c
88 What will be the output?

values = [[3, 4, 5, 1], [33, 6, 1, 2]]

v = values[0][0]

for lst in values:

for element in lst:

if v > element:

v = element

print(v)

A 1
B 3
C 5
D 6

Answer: 1
89 What is the output of the following code?

import copy

a=[10,23,56,[78]]

b=copy.deepcopy(a)

a[3][0]=95

a[1]=34

print(b)

A [10,34,56,[95]].
B [10,23,56,[78]].
C [10,23,56,[95]].
D [10,34,56,[78]].

Answer: [10,23,56,[78]].
90 What is the output of the following piece of code?

a=list((45,)*4)

print((45)*4)

print(a)

A 180 [(45),(45),(45),(45)].
B (45,45,45,45). [45,45,45,45].
C 180 [45,45,45,45].
D Syntax error

Answer: 180 [45,45,45,45].
91 What is the output of the code shown below?

A = [[1, 2, 3],

[4, 5, 6],

[7, 8, 9]]

[A[i][len(A)-1-i] for i in range(len(A))]

A [1, 5, 9]
B [4, 5, 6]
C [3, 5, 7]
D [2, 5, 8]

Answer: [3, 5, 7]
92 What will be the output of the following Python code?

l=[1,2,3,4,5]

[x&1 for x in l]

A [1, 1, 1, 1, 1]
B [1, 0, 1, 0, 1]
C [1, 0, 0, 0, 0]
D [0, 1, 0, 1, 0]

Answer: [1, 0, 1, 0, 1]
93 What will be the output of the following Python code?

l1=[1,2,3]

l2=[4,5,6]

[x*y for x in l1 for y in l2]

A [4, 8, 12, 5, 10, 15, 6, 12, 18]
B [4, 10, 18]
C [4, 5, 6, 8, 10, 12, 12, 15, 18]
D [18, 12, 6, 15, 10, 5, 12, 8, 4]

Answer:[4, 5, 6, 8, 10, 12, 12, 15, 18]
94 Write the list comprehension to pick out only negative integers from a given list ‘l’.
A [x<0 in l]
B [x for x<0 in l]
C [x in l for x<0]
D [x for x in l if x<0]

Answer: [x for x in l if x<0]
95 What will be the output of the following Python code?

s=["pune", "mumbai", "delhi"]

[(w.upper(), len(w)) for w in s]

A Error
B [‘PUNE’, 4, ‘MUMBAI’, 6, ‘DELHI’, 5]
C [PUNE, 4, MUMBAI, 6, DELHI, 5]
D [(‘PUNE’, 4), (‘MUMBAI’, 6), (‘DELHI’, 5)]

Answer: [(‘PUNE’, 4), (‘MUMBAI’, 6), (‘DELHI’, 5)]
96 What will be the output of the following Python code?

l1=[10, 20, 30]

l2=[-10, -20, -30]

l3=[x+y for x, y in zip(l1, l2)]

l3

A Error
B 0
C [-20, -60, -80]
D [0, 0, 0]

Answer:[0, 0, 0]
97 Write a list comprehension for number and its cube for l=[1, 2, 3, 4, 5, 6, 7, 8, 9].
A [x**3 for x in l]
B [x^3 for x in l]
C [x**3 in l]
D [x^3 in l]

Answer: [x**3 for x in l]
98 What will be the output of the following Python code?

l=[[1 ,2, 3], [4, 5, 6], [7, 8, 9]]

[[row[i] for row in l] for i in range(3)]

A Error
B [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
C

1 4 7

2 5 8

3 6 9

D

(1 4 7)

(2 5 8)

(3 6 9)

Answer: [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
99 What will be the output of the following Python code?

import math

[str(round(math.pi)) for i in range (1, 6)]

A [‘3’, ‘3’, ‘3’, ‘3’, ‘3’, ‘3’]
B [‘3.1’, ‘3.14’, ‘3.142’, ‘3.1416’, ‘3.14159’, ‘3.141582’]
C [‘3’, ‘3’, ‘3’, ‘3’, ‘3’]
D [‘3.1’, ‘3.14’, ‘3.142’, ‘3.1416’, ‘3.14159’]

Answer: [‘3’, ‘3’, ‘3’, ‘3’, ‘3’]
100 What will be the output of the following Python code?

l1=[1,2,3]

l2=[4,5,6]

l3=[7,8,9]

for x, y, z in zip(l1, l2, l3):

print(x, y, z)

A

1 4 7

2 5 8

3 6 9

B

(1 4 7)

(2 5 8)

(3 6 9)

C [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
D Error

Answer:

1 4 7

2 5 8

3 6 9

Assam Direct Recruitment Test Series

Teacher Eligibility Test

Assam Direct Recruitment Test Series