Python MCQ Quiz – Reach next level in Python programming!

After playing the first Python quiz of the series, let’s move on to the second part of the Python MCQ quiz by DataFlair. This quiz is a bit difficult when compared to the previous one and includes intermediate-level Python MCQs.

Q.1. What is the output of this code?

a,b - python mcq
Correct! Wrong!

^ is the XOR operator in Python. In the last statement, a=a^b is a=1^1, which is 0.

Q.2. What is the value of this expression?

Correct! Wrong!

The ** operator is evaluated right to left. So, 2**2**3**1 is 2**2**3, which is 2**8, which is 256.

Q.3. Select all the correct statements.

Please select 3 correct answers

Correct! Wrong!

You cannot change the order of positional arguments. A function can take both positional and keyword arguments- positional must be before keyword arguments.

Q.4. How will you open a file for reading as a text file?

Please select 2 correct answers

Correct! Wrong!

The default mode for opening a file is reading in text mode.

Q.5. 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! Wrong!

The union() method can take a list, but the | operator cannot.

Q.6. Polymorphism is when a subclass can modify the behavior of its superclass.

Correct! Wrong!

Q.7. What will be the output of the following code?

scores - Python MCQ Quiz
Correct! Wrong!

Q.8. What is the output of the following code?

list a b c - Python MCQ Quiz
Correct! Wrong!

list += ‘de’ iterates over ‘de’ and adds ‘d’ and ‘e’ separately to list.

Q.9. What is the output of the following code?

while not val - python mcq quiz
Correct! Wrong!

The condition for while is False. else is executed and val//=2 makes it 77.

Q.10. What will this code print?

random import randint - python mcq
Correct! Wrong!

This code gives us a NameError as the name ‘random’ is not defined.

Q.11. Choose the correct output for this code:

def func a - python mcq
Correct! Wrong!

1 raised to the power of anything is 1.

Q.12. How many levels deep are sublists in this list?

l.append - python mcq quiz
Correct! Wrong!

l is [[1, 2, [3, 4]], 5, 6, 7]

Q.13. How many stars does this program output?

i=7 - Python MCQ
Correct! Wrong!

The else-clause after a while loop does not execute if we break out of the loop.

Q.14. 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! Wrong!

How was the experience of the Python MCQ quiz? Did you find it difficult to answer? Do share your views in the comment section.

31 Responses

  1. Nagasrinivasu says:

    Need some more questions like this…

  2. Sk says:

    Only 6 right answers
    Thought I was at intermediate level before attempting this quiz. My bad

  3. Sk says:

    6 correct answers. Question no.13 doesn’t have input. Please check.

  4. Allen says:

    That was a nice experience….even though i am a beginner….i jus gave it a try and scored 8 out of 14….want some more…..

  5. Gk says:

    It was good experience

    • DataFlair Team says:

      Hi Gk,

      Thanks for your kind words. Share the Python quiz on Facebook and Linkedin & let others also take benefit from it.

  6. Chandra Shekhar says:

    Good test…
    Made 7 correct attempts:)

    • DataFlair Team says:

      Hi Yogesh,

      No need to worry, if you got only 5 correct answers. Revise the Python concepts from the sidebar and strengthen your knowledge and skills.

  7. Sagar Suryawanshi says:

    Please check qsn no 12’s output and 13’s program is not available

  8. Ashokkumar Pola says:

    Not much tough, but requires complete basics to score out of.

  9. Rishabh says:

    I score 10 out of 14 experience is pretty good. The question cleared some dought. Thanks you!!

  10. Cassin Thangam says:

    8 correct ones. Was a little bit perplexed even though I know the concepts well.

  11. Prasad Desai says:

    It was really good. Thank you…

  12. A VENKATA BHANU says:

    All 14 are correct

  13. Naveen Noel says:

    Helped in brushing up my concepts. Thanks 🙂

  14. Bhupender Sharma says:

    I love nd enjoyed this quiz, especially explanation part which shows the reason where m wrong or what mistake i hv done,. Thanks alot to all team.

    • DataFlair Team says:

      Hi Bhupender,

      Do share the Python MCQ Quiz on social media platforms and spread the knowledge to all the Python aspirants.

  15. Nalla Shiva Kumar says:

    Very good, by this kind of test we can know what we are. Thanks for the quiz and we expecting some more quiz like this by very soon.

  16. Prithvi says:

    The final output for question 12 given by the test is incorrect. The answer 3 is correct though. The final list output should be [[1,2,[3,4]],5,6,7]

    I scored 9 out of 14

  17. Rohan Meshram says:

    It was very easy

  18. Rohan Meshram says:


  19. charlene says:

    i got 11/14


    14 out of 14 I scored

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.