FrescoPlay Python Functions and OOP
FrescoPlay Python Functions and OOP
- — {97, 112,
108, 101}
The output of the expression [ chr(i) for i in [65, 66, 67] ] is _______. —[‘A’, 'B',
'C']
Which of the following types of arguments can be passed to a function? — All the
options mentioned
A generator function can have multiple yield expressions. State if the statement is
True or False. — True
Which of the following are present in a function header? — function name and
parameter list
The output of the expression {0 if i%2 ==0 else 1 for i in range(8)} is _______. —
{0, 1}
class A:
def __init__(self, a = 5):
self.a = a
This study source was downloaded by 100000839484608 from CourseHero.com on 01-05-2022 21:38:31 GMT -06:00
https://www.coursehero.com/file/79021425/FrescoPlay-Python-Functions-and-OOPrtf/
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)
“4 - 10”
class A:
x = 0
def __init__(self):
A.x += 1
def displayCount(self):
This study source was downloaded by 100000839484608 from CourseHero.com on 01-05-2022 21:38:31 GMT -06:00
https://www.coursehero.com/file/79021425/FrescoPlay-Python-Functions-and-OOPrtf/
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)
Results in Error
class grandpa(object):
pass
class father(grandpa):
pass
class mother(object):
pass
This study source was downloaded by 100000839484608 from CourseHero.com on 01-05-2022 21:38:31 GMT -06:00
https://www.coursehero.com/file/79021425/FrescoPlay-Python-Functions-and-OOPrtf/
print(child.__mro__)
class A:
__metaclass__ = B
class class1:
a = 1
def f1(self):
a = 2
class1.a += 1
print(class1.a, end=' ')
print(a, end=' ')
class1().f1()
class1().f1()
2232
This study source was downloaded by 100000839484608 from CourseHero.com on 01-05-2022 21:38:31 GMT -06:00
https://www.coursehero.com/file/79021425/FrescoPlay-Python-Functions-and-OOPrtf/
What is the output of the following code?
class A:
def __init__(self, x=5, y=4):
self.x = x
self.y = y
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()
False
A(x: 12, y: 3)
class A:
def __init__(self):
print('one')
def f(self):
print(float())
This study source was downloaded by 100000839484608 from CourseHero.com on 01-05-2022 21:38:31 GMT -06:00
https://www.coursehero.com/file/79021425/FrescoPlay-Python-Functions-and-OOPrtf/
print(hex(-255))
class B(A):
def __init__(self):
print('two')
def f(self):
print(float())
print(hex(-42))
x = B()
x.f()
two
0.0
-0x2a
This study source was downloaded by 100000839484608 from CourseHero.com on 01-05-2022 21:38:31 GMT -06:00
https://www.coursehero.com/file/79021425/FrescoPlay-Python-Functions-and-OOPrtf/
Which of the following execption occurs, when a
number is divided by zero?—ZeroDivisionError
This study source was downloaded by 100000839484608 from CourseHero.com on 01-05-2022 21:38:31 GMT -06:00
https://www.coursehero.com/file/79021425/FrescoPlay-Python-Functions-and-OOPrtf/
module 'm1' or the functions 'f1' and 'f2' defined in
it?—import f1, f2 from m1
This study source was downloaded by 100000839484608 from CourseHero.com on 01-05-2022 21:38:31 GMT -06:00
https://www.coursehero.com/file/79021425/FrescoPlay-Python-Functions-and-OOPrtf/
a valid identifier
The output of expression [i**+1 for i in
range(3)] is _______. —[0, 1, 2]
This study source was downloaded by 100000839484608 from CourseHero.com on 01-05-2022 21:38:31 GMT -06:00
https://www.coursehero.com/file/79021425/FrescoPlay-Python-Functions-and-OOPrtf/
Powered by TCPDF (www.tcpdf.org)