Python Questions March 20, 2023 | No Comments 0 votes, 0 avg 13 123456789101112131415 Python Questions 1 / 15 1. Which of the following is not a valid set operation in python? A. Union B. Intersection C. Difference D. none of the above 2 / 15 2. Let A and B be objects of class Foo. Which functions are called when print(A + B) is executed? A. __add__(), __str__() B. __str__(), __add__() C. __sum__(), __str__() D. __str__(), __sum__() 3 / 15 3. The % operator returns the ___. A. Quotient B. Divisor C. Remainder D. None of the mentioned above 4 / 15 4. 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 5 / 15 5. Which of the following functions can be used to read data from a file using a file descriptor? A. os.reader() B. os.read() C. os.quick_read() D. os.scan() 6 / 15 6. What will be the output of the following Python function? float(‘-infinity’) float(‘inf’) A. –inf Inf B. –infinity Inf C. Error Error D. Error Junk value 7 / 15 7. What will be the output of the following code snippet? def tester(**kwargs): for key, value in kwargs.items(): print(key, value, end = " ") tester(Sunday = 1, Monday = 2, Tuesday = 3, Wednesday = 4) A. Sunday 1 Monday 2 Tuesday 3 Wednesday 4 B. Sunday 1 C. Wednesday 4 D. none of the above 8 / 15 8. 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 9 / 15 9. Which of the following modules need to be imported to handle date time computations in Python? A. datetime B. date C. time D. timedate 10 / 15 10. In Python, the break and continue statements, together are called ___ statement. A. Jump B. goto C. compound D. None of the mentioned above 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 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 13 / 15 13. Which function is called when the following Python program is executed? f = foo() format(f) A. str() B. format() C. __str__() D. __format__() 14 / 15 14. What are the two main types of functions in Python? A. System function B. Custom function C. Built-in function & User defined function D. User function 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 is The average score is 34% LinkedIn Facebook Twitter VKontakte 0% Restart quiz Questions, Quiz