Python Questions March 20, 2023 | No Comments 0 votes, 0 avg 277 123456789101112131415 Python Questions 1 / 15 1. What will be the output of the following Python code? x = 50 def func(x): print('x is', x) x = 2 print('Changed local x to', x) func(x) print('x is now', x) A. x is 50 Changed local x to 2 x is now 50 B. x is 50 Changed local x to 2 x is now 2 C. x is 50 Changed local x to 2 x is now 100 D. None of the mentioned 2 / 15 2. Which of the following are valid string manipulation functions in Python? A. count() B. upper() C. strip() D. All of the above 3 / 15 3. Which of the following blocks will always be executed whether an exception is encountered or not in a program? A. try B. except C. finally D. none of the above 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 the use of id() function in python? A. Id returns the identity of the object B. Every object doesn’t have a unique id C. All of the mentioned D. None of the mentioned 6 / 15 6. 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 7 / 15 7. 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) 8 / 15 8. 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 9 / 15 9. 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__() 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. 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() 12 / 15 12. What will be the output of the following code snippet? a = [1, 2, 3, 4] b = [3, 4, 5, 6] c = [x for x in a if x not in b] print(c) A. [1, 2] B. [5, 6] C. [1, 2, 5, 6] D. [3, 4] 13 / 15 13. What will be the output of the following code snippet? def thrive(n): if n % 15 == 0: print("thrive", end = “ ”) elif n % 3 != 0 and n % 5 != 0: print("neither", end = “ ”) elif n % 3 == 0: print("three", end = “ ”) elif n % 5 == 0: print("five", end = “ ”) thrive(35) thrive(56) thrive(15) thrive(39) A. five neither three thrive B. five neither thrive three C. three three three three D. five neither five neither 14 / 15 14. 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 15 / 15 15. 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 Your score is The average score is 34% LinkedIn Facebook Twitter VKontakte 0% Restart quiz Questions, Quiz