Python Questions March 20, 2023 | No Comments 0 votes, 0 avg 612 123456789101112131415 Python Questions 1 / 15 1. Study the following code: x = [‘XX’, ‘YY’] for i in a: i.lower() print(a) What will be the output of this program? A. [‘XX’, ‘YY’] B. [‘xx’, ‘yy’] C. [XX, yy] D. None of these 2 / 15 2. 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 3 / 15 3. 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 4 / 15 4. 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 5 / 15 5. Which of the following is false regarding conditional statement in Python? A. If-elif is the shortcut for the if-else chain B. We use the dictionary to replace the Switch case statement C. We cannot use python classes to implement the switch case statement D. None of the mentioned above 6 / 15 6. What will be the output of the following Python code? places = ['Bangalore', 'Mumbai', 'Delhi'] places1 = places places2 = places[:] places1[1]="Pune" places2[2]="Hyderabad" print(places) A. [‘Bangalore’, ‘Pune’, ‘Hyderabad’] B. [‘Bangalore’, ‘Pune’, ‘Delhi’] C. [‘Bangalore’, ‘Mumbai’, ‘Delhi’] D. [‘Bangalore’, ‘Mumbai’, ‘Hyderabad’] 7 / 15 7. Which of the following are valid escape sequences in Python? A. n B. t C. \ D. all of the above 8 / 15 8. Python supports the creation of anonymous functions at runtime, using a construct called __________ A. pi B. anonymous C. lambda D. None of the mentioned 9 / 15 9. What is the order of precedence in python? A. Exponential, Parentheses, Multiplication, Division, Addition, Subtraction B. Exponential, Parentheses, Division, Multiplication, Addition, Subtraction C. Parentheses, Exponential, Multiplication, Division, Subtraction, Addition D. Parentheses, Exponential, Multiplication, Division, Addition, Subtraction 10 / 15 10. 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 11 / 15 11. Which of the following types of loops are not supported in Python? A. for B. while C. do-while D. All of the above 12 / 15 12. What will be the output of the following code snippet? def solve(a): a = [1, 3, 5] a = [2, 4, 6] print(a) solve(a) print(a) A. [2,4,6].[2,4,6] B. [2,4,6],[1,3,5] C. [1.3.5],[1,3,5] D. none of these 13 / 15 13. 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__() 14 / 15 14. What is called when a function is defined inside a class? A. Module B. Class C. Another Function D. Method 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 isThe average score is 37% LinkedIn Facebook VKontakte 0% Restart quiz By WordPress Quiz plugin Written by Shubhranshu Shekhar, who has trained 20000+ students in coding. Kritika Papne Questions, Quiz