What is the output of this code? a,b=1,0 a=a^b b=a^b a=a^b print(a)
Correct
Incorrect
Question 2 of 14
2. Question
What is the value of this expression? 2**2**3**1
Correct
Incorrect
Question 3 of 14
3. Question
Select all the correct statements. Please select 3 correct answers
Correct
Incorrect
Question 4 of 14
4. Question
How will you open a file for reading as a text file? Please select 2 correct answers
Correct
Incorrect
Question 5 of 14
5. Question
Suppose you have two sets s1 = {1, 2, 3} and s2 = {3, 4, 5}. Which of the following statements give us their union? Please select 5 correct answers
Correct
Incorrect
Question 6 of 14
6. Question
Polymorphism is when a subclass can modify the behavior of its superclass.
Correct
Incorrect
Question 7 of 14
7. Question
What will be the output of the following code? >>> scores = {‘Ayushi’: 97, ‘Megha’: 98} >>> if scores[‘Ayushi’]>97: print(“Scholar”) elif scores[‘Megha’]>97: print(“Topper”) elif scores[‘Melanie’]>97: print(“Teacher”) else: print(“Nobody topped”)
Correct
Incorrect
Question 8 of 14
8. Question
What is the output of the following code? >>> list = [‘a’, ‘b’, ‘c’] >>> list += ‘de’ >>> print(list)
Correct
Incorrect
Question 9 of 14
9. Question
What is the output of the following code? >>> val = 154 >>> while(not(val)): val**=2 else: val//=2
>>> print(val)
Correct
Incorrect
Question 10 of 14
10. Question
What will this code print? >>> from random import randint
>>> for i in range(5): print(random(1, 5))
Correct
Incorrect
Question 11 of 14
11. Question
Choose the correct output for this code: >>> a=1 >>> def func(a): return a**2
>>> a = func(a)**2 >>> print(func(a))
Correct
Incorrect
Question 12 of 14
12. Question
How many levels deep are sublists in this list? >>> l = list() >>> l.append([1, 2, [3, 4]]) >>> l.extend([5, 6, 7]) >>> print(l)
Correct
Incorrect
Question 13 of 14
13. Question
How many stars does this program output? i=7 while i>0: i-=3 print(‘*’) if i<=2: break else: print(‘*’)
Correct
Incorrect
Question 14 of 14
14. Question
Select the incorrect statements: I. Constructors cannot return values II. The __bases__ attribute will give you the names of the direct parent classes III. issubclass(A, B) returns True if A is an object derived from class B IV. Function overloading is an effective way to implement polymorphism in Python
Correct
Incorrect
Here we come to the end of the Python Quiz. Hope you enjoyed it!!!
Do share your feedback and score in the comments section.
Did we exceed your expectations? If Yes, share your valuable feedback on Google
DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.
In Quiz Second, 13th question is wrong according to your correct answer. Two * gonna be print if and only if the code is such as: i=7 while i>0: i-=3 if i<=2: print('*') break else: print('*')
In Quiz Second, 13th question is wrong according to your correct answer.
Two * gonna be print if and only if the code is such as:
i=7
while i>0:
i-=3
if i<=2:
print('*')
break
else:
print('*')
and According to your code three * will be print.
I agree
yes, 3 stars is the correct answer.
i=7
while i>0:
i-=3
print(‘*’)
if i<=2:
break
else:
print(‘*’)
this will print three * so i think the answer is wrong
3 is correct answer
its saying all my answers are correct even when they are worng
Python MCQ
Hello
same this will print 3 *
i=7
while i>0:
i-=3
print(‘*’)
if i<=2:
break
else:
print(‘*’)
this will print three * so i think the answer is wrong
I need explanation
i=7
while i>0:
i-=3
print(‘*’)
if i<=2:
break
else:
print('*')
answers is 3 and you said 2 so it is wrong sir,please check it sir
question number 8 the correct answer should be an error or exception