Python Questions March 20, 2023 | No Comments 0 votes, 0 avg 512 123456789101112131415 Python Questions 1 / 15 1. 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 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 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 4 / 15 4. What will be the output of the following Python code? x = 50 def func(): global x print('x is', x) x = 2 print('Changed global x to', x) func() print('Value of x is', x) A. x is 50 Changed global x to 2 Value of x is 50 B. x is 50 Changed global x to 2 Value of x is 2 C. x is 50 Changed global x to 50 Value of x is 50 D. None of the mentioned 5 / 15 5. What will be the output of the following Python program? z=set('abc') z.add('san') z.update(set(['p', 'q'])) Z A. {‘a’, ‘c’, ‘c’, ‘p’, ‘q’, ‘s’, ‘a’, ‘n’} B. {‘abc’, ‘p’, ‘q’, ‘san’} C. {‘a’, ‘b’, ‘c’, ‘p’, ‘q’, ‘san’} D. {‘a’, ‘b’, ‘c’, [‘p’, ‘q’], ‘san} 6 / 15 6. What keyword is used in Python to throw exceptions? A. raise B. try C. goto D. except 7 / 15 7. Is Python code compiled or interpreted? A. Python code is both compiled and interpreted B. Python code is neither compiled nor interpreted C. Python code is only compiled D. Python code is only interpreted 8 / 15 8. 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) 9 / 15 9. 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 10 / 15 10. Which one of the following is the use of function in python? A. Functions don’t provide better modularity for your application B. you can’t also create your own functions C. Functions are reusable pieces of programs D. All of the mentioned 11 / 15 11. Set makes use of __________ Dictionary makes use of ____________ A. keys, keys B. key values, keys C. keys, key values D. key values, key values 12 / 15 12. 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 13 / 15 13. Which of the following functions converts date to corresponding time in Python? A. strptime() B. strftime() C. both A and B D. All of the above 14 / 15 14. Which of the following types of loops are not supported in Python? A. for B. while C. do-while D. All of the above 15 / 15 15. Which of the following concepts is not a part of Python? A. Pointers B. Loops C. dynamic typing D. All of the above Your score isThe average score is 37% LinkedIn Facebook VKontakte 0% Restart quiz By WordPress Quiz plugin Questions, Quiz