Basic Python Objective Type Questions(MCQs)& Answers

Sports GK Questions and Answers 2024 (Latest Updated)

Awards & Honours GK Questions 2024 (Latest Updated)

Questions
121 What is the output of the code shown below if the system date is 18th August, 2016?

tday=datetime.date.today()

print(tday.month())

A August
B Aug
C 08
D 8

Answer: 8
122 What is the output of the following code, if the time module has already been imported?

def num(m):

t1 = time.time()

for i in range(0,m):

print(i)

t2 = time.time()

print(str(t2-t1))

num(3)

A 1 2 3 The time taken for the execution of the code
B 3 The time taken for the execution of the code
C 1 2 3 UTC time
D 3 UTC time

Answer: 1 2 3 The time taken for the execution of the code
Advertisement
Article and Schedule Quiz Start Test!
DOWNLOAD CURRENT AFFAIRS PDF FROM APP
123 What is the output of the code shown below?

l=[-2, 4]

m=map(lambda x:x*2, l)

print(m)

A [-4, 16]
B Address of m
C Error
D None of the given choices

Answer: Address of m
124 What is the output of the following?

def to_upper(k):

k.upper()

x = ['ab', 'cd']

print(list(map(to_upper, x)))

A [‘AB’, ‘CD’].
B [‘ab’, ‘cd’].
C none of the mentioned
D errort

Answer: none of the mentioned
125 What is the output of the following?

x = [12, 34]

print(len(''.join(list(map(str, x)))))

A 4
B 5
C 6
D Error

Answer: 4
126 What is the output of the following?

x = abcd

print(list(map(list, x)))

A [‘a’, ‘b’, ‘c’, ‘d’].
B [‘abcd’].
C [[‘a’], [‘b’], [‘c’], [‘d’]].
D none of the mentioned

Answer: none of the mentioned
127 Is the output of the function abs() the same as that of the function math.fabs()?
A sometimes
B always
C never
D none of the mentioned

Answer: sometimes
128 What is returned by math.isfinite(float(‘nan’))?
A True
B False
C None
D error

Answer: False
129 What is the default base used when math.log(x) is found?
A e
B 10
C 2
D none of the mentioned

Answer: e
130 What does os.getlogin() return?
A name of the current user logged in
B name of the superuser
C gets a form to login as a different user
D all of the above

Answer:name of the current user logged in
131 What is the output of the line of code shown below?

pickle.HIGHEST_PROTOCOL

A 4
B 5
C 3
D 6

Answer:4
132 Which of the following is true about top-down design process?
A The details of a program design are addressed before the overall design
B Only the details of the program are addressed
C The overall design of the program is addressed before the details
D Only the design of the program is addressed

Answer: The overall design of the program is addressed before the details
133 What is the output of the function shown below (random module has already been imported)?

random.choice('sun')

A sun
B u
C either s, u or n
D error

Answer: either s, u or n
134 Which of the following will not be returned by random.choice(“1 ,”)?
A 1p
B (space)
C ,
D none of the mentioned

Answer: none of the mentioned
135 What is the output of this code?

import sys

eval(sys.stdin.readline())

"India"

A India5
B India
C ‘India\n’
D ‘India’

Answer: ‘India’
136 Which of the following functions does not accept any arguments?
A position
B fillcolor
C goto
D setheading()

Answer: position
137 What is the output of the following code?

import turtle

t=turtle.Pen()

t.right(90)

t.forward(100)

t.heading()

A 0.0
B 90.0
C 270.0
D 360.0

Answer: 270.0
138 The output of the code shown is similar to the alphabet _______________

import turtle

t=turtle.Pen()

t1=turtle.Pen()

t2=turtle.Pen()

t.forward(100)

t1.forward(100)

t2.forward(100)

t1.left(90)

t1.forward(75)

t2.right(90)

t2.forward(75)

A X
B N
C T
D M

Answer: T
139 Which of these definitions correctly describes a module?
A Denoted by triple quotes for providing the specification of certain program elements
B Design and implementation of specific functionality to be incorporated into a program
C Defines the specification of how it is to be used
D Any program that reuses code

Answer: Design and implementation of specific functionality to be incorporated into a program
140 Which of the following is not an advantage of using modules?
A Provides a means of reuse of program code
B Provides a means of dividing up tasks
C Provides a means of reducing the size of the program
D Provides a means of testing individual parts of the program

Answer: Provides a means of reducing the size of the program
Assam Direct Recruitment Test Series

Teacher Eligibility Test

Assam Direct Recruitment Test Series