Python 3 - Functions and OOPs - Malay
Python 3 - Functions and OOPs - Malay
----int
The output of the expression [ chr(i) for i in [65, 66, 67] ] is _______.------
['A', 'B', 'C']
The elements of an iterator can be accessed multiple times. State if the statement
is True or False.---False
__metaclass__ = B
def f1(self):
a = 2
class1.a += 1
print(class1.a, end=' ')
print(a, end=' ')
class1().f1()
class1().f1()
def __init__(self):
A.x += 1
def displayCount(self):
print('Count : %d' % A.x)
def display(self):
print('a :', self.a, ' b :', self.b)
a1 = A('George', 25000)
a2 = A('John', 30000)
a3 = A()
a1.display()
a2.display()
print(A.x)
def __str__(self):
return 'A(x: {}, y: {})'.format(self.x, self.y)
def f1():
a = A(12, 3)
b = A(3, 12)
if (a == b):
print(b != a)
print(a)
f1()
Which methods are invoked on entering into and exiting from the block of code
written in 'with' statement?----__enter__, __exit__
Which of the keyword is used to display a customised error message to the user?--
raise
Which of the following execption occurs, when a number is divided by zero?---
AirthmaticError,ZeroDivisionError(Correct)
Which of the following module is not used for parsing command line arguments
automatically?---getopt(wrong) cmdparse
Any Python Script can act like a Module. State if the statement is True or False?--
True
Which of the following is not a way to import the module 'm1' or the functions 'f1'
and 'f2' defined in it?----import f1, f2 from m1
Which of the following statement retreives names of all builtin module names?----
import sys; sys.builtin_module_names
Which of the following methods of 'random' module is used to pick a single element,
randomly, from a given list of elements?---choice
def f(self):
print(float())
print(hex(-255))
class B(A):
def __init__(self):
print('two')
def f(self):
print(float())
print(hex(-42))
x = B()
x.f()
How are variable length non-keyword arguments specified in the function heading?---
one star followed by a valid identifier
class father(grandpa):
pass
class mother(object):
pass
print(child.__mro__)
Which of the following expression can be used to check if the file 'C:\Sample.txt'
exists and is also a regular file?------os.path.isfile(C:\Sample.txt)
The output of the expression {0 if i%2 ==0 else 1 for i in range(8)} is _______.
[0,1]--wrong {0,1}--correct
Which of the following keyword is used for creating a method inside a class ?---def
def f1(self):
self.a += 10
class B(A):
def __init__(self, b = 0):
A.__init__(self, 4)
self.b = b
def f1(self):
self.b += 10
x = B()
x.f1()
print(x.a,'-', x.b)
Which of the following modules contain functions that create iterators for
efficient looping?--itertools
The output of the expression 'itertools.dropwhile(lambda x: x<5, [1,4,6,4,1])'
is----[6]--wrong [1,4]
The output of the expression {i:j for i in "abcd" for j in "kiwi"} is---{'a': 'i',
'd': 'i', 'c': 'i', 'b': 'i'}