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 kind of exception will be raised by (using python 3.X version):
assert 5>10
- (a): ValueError exception
- (b): AssertionError exception
- (c): ZeroDivisionError exception
- (d): No exception is raised by the program
Answer: (b) AssertionError exception
[2] What kind of exception will be raised by (using python 3.X version):
assert 5/0 > 0
- (a): ValueError exception
- (b): AssertionError exception
- (c): ZeroDivisionError exception
- (d): No exception is raised by the program
Answer:(c) ZeroDivisionError exception
[3] What kind of exception will be raised by (using python 3.X version)
assert 10/5 > 0
- (a): ValueError exception
- (b): AssertionError exception
- (c): ZeroDivisionError exception
- (d): No exception is raised by the program
Answer:(d) No exception is raised by the program
[4] For the following Pyhton3 program
assert len(item) < 5
An assertion is NOT generated if the value of item is (using python 3.X version):
- (a): [1, 2, 3, 4, 5, 6]
- (b): range(0, 3)
- (c): No Assertion Error
- (d): (51,52,53,54,55)
Answer: (b) range(0, 3)
[5] Can the assert statements in a program be disabled by passing -O option to the python interpreter.
- (a): True
- (b): False
Answer: (a) True
[6] Which of the following data structures in python can be traversed using for…in statement –
- (a): tuple
- (b): string
- (c): dictionary
- (d): all of the above
Answer: (d) all of the above
Also, see: Python Programming Quiz – 9th Week Quiz Solution
[7] In python, for loop terminates when next() raises StopIteration exception.
- (a): True
- (b): False
Answer: (a) True
[8] While we create our own iterator, if the class defines __next__(), then __iter__() can just return self.
- (a): True
- (b): False
Answer: (a) True
[9] Which of the following mathematical function definitions is recursive –
(a) factorial(0) = 1 factorial(n) = n*factorial(n-1) where n>=0 (b) f(0) = 0 f(1) = 1 f(n) = f(n-1) + f(n-2) where n>=0 (c) both (a) and (b) (d) none of (a) and (b)
- (a): a
- (b): b
- (c): c
- (d): d
Also See:- TCS Recruitment 2020 Apply Online Form
Answer: (c) c
[10] A function not calling itself (directly/indirectly) is called a recursive functio
- (a): True
- (b): False
Answer: (b) false
[11] Which of following is not a property of properly defined recursive functions –
- (a): change of argument between recursive calls
- (b): change of arguments is towards base case
- (c): there must be zero or more base cases
- (d): none of the above
Answer: (c) there must be zero or more base cases
[12] Estimating the time taken by a program requires to consider only function calls as operations.
- (a): True
- (b): False
Answer: (b) False
[13] Time taken by a function call is proportional to the number of simple operations performed by the call before returning.
- (a): True
- (b): False
Answer: (a) True
[14] Solution to the recurrence relation T(n) = T(n-1) + 1 where T(1) = 1 is –
- (a): T(n) = n-2
- (b): T(n) = n-1
- (c): T(n) = n
- (d): T(n) = n+1
Answer: (c) T(n) = n
[15] Solution to the recurrence relation T(n) = T(n-1) + n where T(1) = 1 is –
- (a): T(n) = n*(n-1)/2
- (b): T(n) = n*(n+1)/2
- (c): T(n) = n*n
- (d): None of the above
Answer: (b) T(n) = n*(n+1)/2
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.