Python Questions March 20, 2023 | No Comments 0 votes, 0 avg 590 123456789101112131415 Python Questions 1 / 15 1. 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 2 / 15 2. What will be the output of the following code snippet? square = lambda x: x ** 2 a = [] for i in range(5): a.append(square(i)) print(a) A. [0, 1, 4, 9, 16] B. [1, 4, 9, 16, 25] C. [0, 1, 2, 3, 4] D. [1, 2, 3, 4, 5] 3 / 15 3. What is Instantiation in terms of OOP terminology? A. Deleting an instance of class B. Modifying an instance of class C. Copying an instance of class D. Creating an instance of class 4 / 15 4. 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 5 / 15 5. Which of the following is not a valid set operation in python? A. Union B. Intersection C. Difference D. none of the above 6 / 15 6. What is the order of precedence in python? A. Exponential, Parentheses, Multiplication, Division, Addition, Subtraction B. Exponential, Parentheses, Division, Multiplication, Addition, Subtraction C. Parentheses, Exponential, Multiplication, Division, Subtraction, Addition D. Parentheses, Exponential, Multiplication, Division, Addition, Subtraction 7 / 15 7. What will be the output of the following Python code? for i in range(5): if i == 5: break else: print(i) else: print("Here") A. 0 1 2 3 4 Here B. 0 1 2 3 4 5 Here C. 0 1 2 3 4 D. 1 2 3 4 5 8 / 15 8. Which of the following concepts is not a part of Python? A. Pointers B. Loops C. dynamic typing D. All of the above 9 / 15 9. What will be the output of the following Python code? l=[1, 0, 2, 0, 'hello', '', []] list(filter(bool, l)) A. [1, 0, 2, ‘hello’, ”, []] B. Error C. [1, 2, ‘hello’] D. [1, 0, 2, 0, ‘hello’, ”, []] 10 / 15 10. Which of the following is used to define a block of code in Python language? A. Indentation B. Keys C. Brackets D. All of the above 11 / 15 11. Consider the results of a medical experiment that aims to predict whether someone is going to develop myopia based on some physical measurements and heredity. In this case, the input dataset consists of the person’s medical characteristics and the target variable is binary: 1 for those who are likely to develop myopia and 0 for those who aren’t. This can be best classified as A. Regression B. Decision Tree C. Clustering D. Association Rules 12 / 15 12. Study the following code: x = [‘XX’, ‘YY’] for i in a: i.lower() print(a) What will be the output of this program? A. [‘XX’, ‘YY’] B. [‘xx’, ‘yy’] C. [XX, yy] D. None of these 13 / 15 13. What will be the output of the following Python code? class test: def __init__(self,a): self.a=a def display(self): print(self.a) obj=test() obj.display() A. Runs normally, doesn’t display anything B. Displays 0, which is the automatic default value C. Error as one argument is required while creating the object D. Error as display function requires additional argument 14 / 15 14. What will be the output of the following code snippet? a = "4, 5" nums = a.split(',') x, y = nums int_prod = int(x) * int(y) print(int_prod) A. 20 B. 45 C. 54 D. 4, 5 15 / 15 15. What will be the output of the following Python code? x = "abcdef" i = "a" while i in x: x = x[:-1] print(i, end = " ") A. i i i i i i B. a a a a a a C. a a a a a D. none of the mentioned Your score isThe average score is 37% LinkedIn Facebook VKontakte 0% Restart quiz By WordPress Quiz plugin Questions, Quiz