Python Questions March 20, 2023 | No Comments 0 votes, 0 avg 403 123456789101112131415 Python Questions 1 / 15 1. 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 2 / 15 2. Which of the following statements are used in Exception Handling in Python? A. try B. except C. finally D. All of the above 3 / 15 3. 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 4 / 15 4. What will be the output of the following Python program? def addItem(listParam): listParam += [1] mylist = [1, 2, 3, 4] addItem(mylist) print(len(mylist)) A. 5 B. 2 C. 8 D. 1 5 / 15 5. 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’, ”, []] 6 / 15 6. 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 7 / 15 7. The % operator returns the ___. A. Quotient B. Divisor C. Remainder D. None of the mentioned above 8 / 15 8. What will be the output of the following Python code? a=[13,56,17] a.append([87]) a.extend([45,67]) print(a) A. [13, 56, 17, [87], 45, 67] B. [13, 56, 17, 87, 45, 67] C. [13, 56, 17, 87,[ 45, 67]] D. [13, 56, 17, [87], [45, 67]] 9 / 15 9. Which of the following are valid escape sequences in Python? A. n B. t C. \ D. all of the above 10 / 15 10. To add a new element to a list we use which Python command? A. list1.addEnd(5) B. list1.addLast(5) C. list1.append(5) D. list1.add(5) 11 / 15 11. 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 12 / 15 12. time.time() returns ________ A. the current time in milliseconds since midnight B. the current time in milliseconds since midnight, January 1, 1970 GMT (the Unix time) C. the current time D. the current time in milliseconds 13 / 15 13. 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” 14 / 15 14. 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 15 / 15 15. What will be the output of the following program? i = 0 while i < 5: print(i) i += 1 if i == 3: break else: print(0) A. 1 2 3 B. 0 1 2 3 C. 0 1 2 D. 3 2 1 Your score is The average score is 35% LinkedIn Facebook Twitter VKontakte 0% Restart quiz Questions, Quiz