What does the following code output? from collections import namedtuple Point = namedtuple(‘Point’, [‘x’, ‘y’]) p = Point(3, 4) print(p.x, p[1], len(p)) Python DeveloperMedium Try Now
What does the following code output? def make_adder(n): return lambda x: x + n add5 = make_adder(5) print(add5(3), add5(10)) Python DeveloperMedium Try Now
What is the difference between append() and extend() on a Python list? Python DeveloperMedium Try Now
What is the output of the following? class A: x = 5 a1 = A() a2 = A() a1.x = 10 print(A.x, a1.x, a2.x) Python DeveloperMedium Try Now
What does Python’s super() return and why is it preferred over calling the parent class directly? Python DeveloperMedium Try Now
What does the following code output? from itertools import islice g = (x**2 for x in range(100)) print(list(islice(g, 4))) Python DeveloperMedium Try Now
What is the output of the following? x = {1, 2, 3} & {2, 3, 4} print(x) Python DeveloperMedium Try Now
Which of the following is the correct way to handle multiple exception types in a single except clause? Python DeveloperMedium Try Now
What is the difference between deep copy and shallow copy for nested structures in Python? Python DeveloperMedium Try Now
What is the output of the following? a = [1, 2, 3] print(a[-1], a[-2:]) Python DeveloperMedium Try Now
What is the output of the following? print(sorted([3,1,4,1,5], key=lambda x: -x)) Python DeveloperMedium Try Now