Python Questions March 20, 2023 | No Comments 0 votes, 0 avg 238 123456789101112131415 Python Questions 1 / 15 1. What will be the output of the following Python code? l=list('HELLO') p=l[0], l[-1], l[1:3] 'a={0}, b={1}, c={2}'.format(*p) A. Error B. “a=’H’, b=’O’, c=(E, L)” C. “a=H, b=O, c=[‘E’, ‘L’]” D. Junk value 2 / 15 2. Study the following program: class Std_Name: def __init__(self, Std_firstName, Std_Phn, Std_lastName): self.Std_firstName = Std_firstName self. Std_PhnStd_Phn = Std_Phn self. Std_lastNameStd_lastName = Std_lastName Std_firstName = "Wick" name = Std_Name(Std_firstName, 'F', "Bob") Std_firstName = "Ann" name.lastName = "Nick" print(name.Std_firstName, name.Std_lastName) What will be the output of the print statement? A. Ann Bob B. Ann Nick C. Wick Bob D. Wick Nick 3 / 15 3. Which of the following types of loops are not supported in Python? A. for B. while C. do-while D. All of the above 4 / 15 4. 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 5 / 15 5. 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 6 / 15 6. Which of the following modules need to be imported to handle date time computations in Python? A. datetime B. date C. time D. timedate 7 / 15 7. 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 8 / 15 8. 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] 9 / 15 9. What will be the output of the following code snippet? a = 3 b = 1 print(a, b) a, b = b, a print(a, b) A. 1 3 3 1 B. 1 3 1 3 C. 3 1 3 1 D. 3 1 1 3 10 / 15 10. 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 11 / 15 11. 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 12 / 15 12. 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]] 13 / 15 13. The process of pickling in Python includes ____________ A. conversion of a Python object hierarchy into byte stream B. conversion of a datatable into a list C. conversion of a byte stream into Python object hierarchy D. conversion of a list into a datatable 14 / 15 14. 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 15 / 15 15. 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 Your score is The average score is 35% LinkedIn Facebook Twitter VKontakte 0% Restart quiz Questions, Quiz