Title: Python Quiz
Reading Time: 5 Minutes
Published Time: 22 May, 2023
Q 1 - What is output for −
a = ['hat', 'mat', 'rat']
'rhyme'.join(a)
A - [‘hat’,’mat’,’rat’,’rhyme’]
Show Answer
Q 2 - Which is invalid in python for z = 5 ?
Show Answer
Q 3 - Syntax error in python is detected by _________at _______
Show Answer
Q 4 - what is output of following code −
class Count:
def __init__(self, count=0):
self.__count=count
a=Count(2)
b=Count(2)
print(id(a)==id(b), end = '' '')
c= ''hello''
d= ''hello''
print(id(c)==id(d))
Show Answer
Q 5 - What is the output of the following code?
def nprint(message, n):
while(n > 0):
print(message)
n-=1
nprint('z', 5)
Show Answer
Q 6 - Guess the output −
def main():
try:
func()
print(''print this after function call'')
except ZeroDivisionError:
print('Divided By Zero! Not Possible! ')
except:
print('Its an Exception!')
def func():
print(1/0)
main()
B - ‘Divided By Zero! Not possible!’
C - ‘print this after function call’ followed by ‘Divided By Zero! Not Possible!’
D - ‘print this after function call’ followed by ‘Its an Exception!’
Show Answer
Q 7 - Which among them is correct(s) about Recursive Function?
A - They are much faster than the normal functions.
B - They take more space then the non-recursive functions.
C - They can always be replaced by non-recursive functions.
Show Answer
Q 8 - Which code is used to open a file for binary writing?
Show Answer
Q 9 - Suppose you are using a grid manager then which option is best suitable to place a component in multiple rows and columns?
Show Answer
Q 10 - Which is the special symbol used in python to add comments?