Python Programming MCQs | Page - 5
Dear candidates you will find MCQ questions of Python Programming here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
β
Correct Answer: (A)
Client
Q. What is the output of the following piece of code?
#mod1
def change(a):
b=[x*2 for x in a]
print(b)
#mod2
def change(a):
b=[x*x for x in a]
print(b)
from mod1 import change
from mod2 import change
#main
s=[1,2,3]
change(s)
β
Correct Answer: (D)
There is a name clash
Q. What is the output of the following program? tday=datetime.date.today() print(tday.month())
β
Correct Answer: (D)
8
Q. Which of the following formatting options can be used in order to add „nβ blank spaces after a given string „Sβ?
β
Correct Answer: (D)
print(“%-ns”%S)
Q. What is the output of the following program?
f = None
for i in range (5):
with open("data.txt", "w") as f:
if i > 2:
break
print(f.closed)
β
Correct Answer: (A)
True
Q. To read the entire remaining contents of the file as a string from a file object infile, we use
β
Correct Answer: (B)
infile.read()
Q. Suppose t = (1, 2, 4, 3), which of the following is incorrect?
β
Correct Answer: (B)
t[3] = 45
Jump to