Python Questions March 20, 2023 | No Comments 0 votes, 0 avg 599 123456789101112131415 Python Questions 1 / 15 1. Which of these is the definition for packages in Python? A. A set of main modules B. A folder of python modules C. A number of files containing Python definitions and statements D. A set of programs making use of Python modules 2 / 15 2. The following python program can work with ____ parameters. def f(x): def f1(*args, **kwargs): print("JAVA") return x(*args, **kwargs) return f1 A. any number of B. O C. 1 D. 2 3 / 15 3. What will be the output of the following Python code? t = '%(a)s, %(b)s, %(c)s' t % dict(a='hello', b='world', c='universe') A. ‘hello, world, universe’ B. ‘hellos, worlds, universes’ C. Error D. hellos, world, universe 4 / 15 4. What will be the output of the following Python program? def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q)) A. Error B. None C. “false” D. “true” 5 / 15 5. What will be the output of the following Python code? def func(a, b=5, c=10): print('a is', a, 'and b is', b, 'and c is', c) func(3, 7) func(25, c = 24) func(c = 50, a = 100) A. a is 7 and b is 3 and c is 10 a is 25 and b is 5 and c is 24 a is 5 and b is 100 and c is 50 B. a is 3 and b is 7 and c is 10 a is 5 and b is 25 and c is 24 a is 50 and b is 100 and c is 5 C. a is 3 and b is 7 and c is 10 a is 25 and b is 5 and c is 24 a is 100 and b is 5 and c is 50 D. None of the mentioned 6 / 15 6. Which of the following Python code will print True? a = foo(2) b = foo(3) print(a < b) A. class foo: def __init__(self, x): self.x = x def __lt__(self, other): if self.x < other.x: return False else: return True B. class foo: def __init__(self, x): self.x = x def __less__(self, other): if self.x > other.x: return False else: return True C. class foo: def __init__(self, x): self.x = x def __lt__(self, other): if self.x < other.x: return True else: return False D. class foo: def __init__(self, x): self.x = x def __less__(self, other): if self.x < other.x: return False else: return True 7 / 15 7. Which of the following modules need to be imported to handle date time computations in Python? A. datetime B. date C. time D. timedate 8 / 15 8. Which of the following Boolean expressions is not logically equivalent to the other three? A. not(-6<0 or-6>10) B. -6>=0 and -6<=10 C. not(-6<10 or-6==10) D. not(-6>10 or-6==10) 9 / 15 9. Which of the following statements are used in Exception Handling in Python? A. try B. except C. finally D. All of the above 10 / 15 10. Which of the following functions can help us to find the version of python that we are currently working on? A. sys.version(1) B. sys.version(0) C. sys.version() D. sys.version 11 / 15 11. What will be the output of the following Python code? def printMax(a, b): if a > b: print(a, 'is maximum') elif a == b: print(a, 'is equal to', b) else: print(b, 'is maximum') PrintMax(3, 4) A. 3 B. 4 C. 4 is maximum D. None of the mentioned 12 / 15 12. What will be the output of the following Python code? import re s = 'abc123 xyz666 lmn-11 def77' re.sub(r'b([a-z]+)(d+)', r'21:', s) A. ‘123abc: 666xyz: lmn-11 77def:’ B. ‘77def: lmn-11: 666xyz: 123abc’ C. ‘abc123:’, ‘xyz666:’, ‘lmn-11:’, ‘def77:’ D. ‘abc123: xyz666: lmn-11: def77’ 13 / 15 13. What will be the output of the following Python code? l=list('HELLO') p=l[0], l[-1], l[1:3] 'a={0}, b={1}, c={2}'.format(*p) A. Error B. “a=’H’, b=’O’, c=(E, L)” C. “a=H, b=O, c=[‘E’, ‘L’]” D. Junk value 14 / 15 14. Which of the following best describes inheritance? A. Ability of a class to derive members of another class as a part of its own definition B. Means of bundling instance variables and methods in order to restrict access to certain class members C. Focuses on variables and passing of variables to functions D. Allows for implementation of elegant software that is well designed and easily modified 15 / 15 15. What will be the datatype of the var in the below code snippet? var = 10 print(type(var)) var = "Hello" print(type(var)) A. str and int B. int and int C. str and str D. int and str Your score isThe average score is 37% LinkedIn Facebook VKontakte 0% Restart quiz By WordPress Quiz plugin Questions, Quiz