61. What will be the output of the following Python code?
import time
t=(2010, 9, 20, 8, 15, 12, 6)
time.asctime(t)
a) ‘20 Sep 2010 8:15:12 Sun’
b) ‘2010 20 Sept 08:15:12 Sun’
c) ‘Sun Sept 20 8:15:12 2010’
d) Error
62. What will be the output of the following Python code?
import time
t=(2010, 9, 20, 8, 45, 12, 6, 0, 0)
time.asctime(t)
a) ‘Sep 20 2010 08:45:12 Sun’
b) ‘Sun Sep 20 08:45:12 2010’
c) ’20 Sep 08:45:12 Sun 2010’
d) ‘2010 20 Sep 08:45:12 Sun’
63. The sleep function (under the time module) is used to ___________
a) Pause the code for the specified number of seconds
b) Return the specified number of seconds, in terms of milliseconds
c) Stop the execution of the code
d) Return the output of the code had it been executed earlier by the specified number of seconds
64. What will be the output of the following Python code?
import time
for i in range(0,5):
print(i)
time.sleep(2)
a) After an interval of 2 seconds, the numbers 1, 2, 3, 4, 5 are printed all together
b) After an interval of 2 seconds, the numbers 0, 1, 2, 3, 4 are printed all together
c) Prints the numbers 1, 2, 3, 4, 5 at an interval of 2 seconds between each number
d) Prints the numbers 0, 1, 2, 3, 4 at an interval of 2 seconds between each number
65. What will be the output if we try to extract only the year from the following Python code?
(time.struct_time(tm_year=2017, tm_mon=6, tm_mday=25, tm_hour=18, tm_min=26, tm_sec=6, tm_wday=6, tm_yday=176, tm_isdst=0))
import time
t=time.localtime()
print(t)
a) t[1]
b) tm_year
c) t[0]
d) t_year
66. State whether true or false.
s = time.time()
t= time.time()
s == t
a) True
b) False
67. To include the use of functions which are present in the random library, we must use the option:
a) import random
b) random.h
c) import.random
d) random.random
68. The output of the following Python code is either 1 or 2.
import random
random.randint(1,2)
a) True
b) False
69. What will be the output of the following Python code?
import random
random.choice(2,3,4)
a) An integer other than 2, 3 and 4
b) Either 2, 3 or 4
c) Error
d) 3 only
70. What will be the output of the following Python code?
import random
random.choice([10.4, 56.99, 76])
a) Error
b) Either 10.4, 56.99 or 76
c) Any number other than 10.4, 56.99 and 76
d) 56.99 only
Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Python Interview Questions (MCQs)
We have divided these Python Questions and Answers into various parts based on the topics. Open the Topic of your choice and Practice these MCQs.