Questions Bank November 5, 2022 Comments Off on Questions Bank Questions Bank › Category: Python Essentials 2What is the expected result of executing the following code? def my_fun(n): s = ‘+’ for i in range(n): s += s yield s for x in my_fun(2): print(x, end=”)OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected result of executing the following code? try: raise Exception(1, 2, 3) except Exception as e: print(len(e.args))OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected result of executing the following code? class A: def a(self): print(‘a’) class B: def a(self): print(‘b’) class C(B, A): def a(self): self.a() o = C() o.c()OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected result of executing the following code? class A: def __init__(self): pass a = A(1) print(hasattr(a, ‘A’))OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected effect of running the following code? class A: def __init__(self, v): self.__a = v + 1 a = A(0) print(a.__a)OpenProgrammingAnswers asked 2 years ago • Python Essentials 2The sys.stderr stream is normally associated with:OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected result of executing the following code? class A: pass class B(A): pass class C(B): pass print(issubclass(A, C))OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected output of the following code? class A: A = 1 def __init__(self): self.a = 0 print(hasattr(A, ‘a’))OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected output of the following code? class A: def __init__(self, v=2): self.v = v def set(self, v=1): self.v += v return self.v a = A() b = a b.set() print(a.v)OpenProgrammingAnswers asked 2 years ago • Python Essentials 2If the class constructor is declared in the following way: Which one of the assignments is invalid? class Class: def __init__(self, val=0): passOpenProgrammingAnswers asked 2 years ago • Python Essentials 2The following code: print(float(“1.3”))OpenProgrammingAnswers asked 2 years ago • Python Essentials 2The following code: print(chr(ord(‘p’) + 2))OpenProgrammingAnswers asked 2 years ago • Python Essentials 2The following code: x = “\\\” print(len(x))OpenProgrammingAnswers asked 2 years ago • Python Essentials 2The following code: x = “\\” print(len(x))OpenProgrammingAnswers asked 2 years ago • Python Essentials 2The following statement: assert var == 0OpenProgrammingAnswers asked 2 years ago • Python Essentials 2 Share Facebook Twitter Stumbleupon LinkedIn Pinterest