Here you will get all the assignment and quiz solutions of Python Programming Course by prutor.ai. Prutor is an online smart tutoring platform which provides various MOOC courses for student and organised by by IIT Kharagpur. At the end of each course student gets a certificate for sucessfull completion of each course but throughout the course students have to pass all the weekly assignments and quizes.
[1] What is the output of the following Python3 program (using python 3.X version):
i = 1
while i <= 10:
if i%2==0: # even
continue
print (i, end=’ ‘)
i= i+1
- (a): 1 3 5 7 9
- (b): 2 4 6 8 10
- (c): The program will go into an infinite loop, printing 1 1 1 …
- (d): The program will go into an infinite loop (after possibly printing a single 1)
Answer:(d) The program will go into an infinite loop (after possibly printing a single 1)
[2] What is the output of the following Python3 program (using python 3.X version):
i = 1
while i <= 10:
i= i+1
if i%2==0: # even
continue
print (i, end=’ ‘)
- (a): 3 5 7 9 11
- (b): 1 3 5 7 9
- (c): The program will go into an infinite loop, printing 1 1 1 …
- (d): The program will go into an infinite loop, printing nothing
Answer:(a) 3 5 7 9 11
[3] What is the output of the following Python3 program (using python 3.X version):
i = 1
while i <= 10:
if i%2==0: # even
i= i+1
continue
print (i, end=’ ‘)
- (a): 3 5 7 9 11
- (b): 1 3 5 7 9
- (c): The program will go into an infinite loop, printing 1 1 1 …
- (d): The program will go into an infinite loop, printing nothing
Answer: (c) The program will go into an infinite loop, printing 1 1 1 …
[4] What is the output of the following Python3 program (using python 3.X version):
i = 1
while i <= 10:
if i%2==0: # even
i= i+1
continue
print (i, end=’ ‘)
i= i+1
- (a): 3 5 7 9 11
- (b): 1 3 5 7 9
- (c): The program will go into an infinite loop, printing 1 1 1 …
- (d): The program will go into an infinite loop, printing nothing
Answer:(b) 1 3 5 7 9
[5] What is the output of the following program (using python 3.X version):
r,a,n = 2,10,20
term = a
for i in range(n):
term = term * r
if (i > 3):
break
print (term)
- (a): 40
- (b): 80
- (c): 160
- (d): 320
Answer(d) 320
[6] Which of the following statements is NOT true about Python functions:
- (a): A function can be called only once in a program.
- (b): A function allows us to break a program into small, independent tasks.
- (c): A function can call other functions.
- (d): Python provides several helpful functions
Answer:(a) A function can be called only once in a program.
[7] Functions allow us to “divide and conquer” a complex programming task into simpler programming tasks.
- (a): True
- (b): False
Answer:(a) True
[8] Functions are the only way to write modular programs in Python.
- (a): True
- (b): False
Answer:(b) False
[9] Assume that the “min” function computes the minimum of two values, and “max” function computes the maximum of two values. Let x1, x2, x3 and x4 be 4 distinct integers. What can you say about the following program (using python 3.X version):
y1 = min(x1, x2)
y2 = min(x3, x4)
y3 = max(y1, y2)
- (a): y3 is the largest integer among x1, x2, x3, x4.
- (b): y3 is either the largest or the second largest integer among x1, x2, x3, x4.
- (c): y3 is either the second largest or the third largest integer among x1, x2, x3, x4.
- (d): y3 is the third largest integer among x1, x2, x3, x4.
Answer: (a) y3 is the largest integer among x1, x2, x3, x4.
[10]
Assume that the “min” function computes the minimum of two values, and “max” function computes the maximum of two values. Let x1, x2, x3 and x4 be 4 distinct integers. What can you say about the following program (using python 3.X version):
y1 = min(x1, x2)
y2 = min(x3, x4)
y3 = x1 + x2 – y1
y4 = x3 + x4 – y2
y5 = max(y3, y4)
- (a): y5 is the largest integer among x1, x2, x3, x4.
- (b): y5 is either the largest or the second largest integer among x1, x2, x3, x4.
- (c): y5 is either the second largest or the third largest integer among x1, x2, x3, x4.
- (d): Can not say anything as the data is not sufficient.
Answer:(c) y5 is either the second largest or the third largest integer among x1, x2, x3, x4.
If you have any quetions, please comment down below, we will try to answer with in first 24 hour. Hope you liked this content, We will come with another week’s quiz, Thanks for reading. Good Bye.
0 Comments
Don't be a stranger Just say hello, I will be happy to help you.