Python Quiz Questions – Upskill yourself with Fun

After the completion of the Python tutorial series, we are presenting you with the Python quiz series to master and evaluate your skills and knowledge of Python in a fun manner. This is the first Python quiz, therefore, we have included basic and some intermediate level questions. So, don’t worry, if you are new to Python, it will help you to test your knowledge of basic concepts.

Q.1. How many CPUs will the threading library use?

Correct! Wrong!

threading only uses a single CPU. For running code on different processors, you can use the multiprocessing library.

Q.2. Which of the following codes raises an exception?

Correct! Wrong!

The backslash line continuation character should be the last thing in line.

Q.3. Which of the following follow PEP8?

Please select 2 correct answers

Correct! Wrong!

There should not be space between a function’s name and its parentheses. There should not be a space after the element in a tuple with a single element. There should not be space before a semicolon.

Q.4. What will this code print?

a=7 - Python Quiz
Correct! Wrong!

This code will raise an exception because you cannot put whitespace before a statement. It raises a SyntaxError for unexpected indent.

Q.5. What is the maximum value for an integer in Python 3?

Correct! Wrong!

There is no limit on the maximum value of an integer like in Python 2.

Q.6. How do you denote the end of a block in Python 3?

Correct! Wrong!

Since there are no curly braces in Python, indentation is mandatory

Q.7. Which of these if-statements work?

Please select 2 correct answers

Correct! Wrong!

You cannot put a nested if-statement on the same line as its parent. You cannot put else on the same line as if.

Q.8. In this list, how will you access the letter ‘t’ in ‘bat’?

list - Python Quiz
Correct! Wrong!

‘t’ is at index 2 in the string at index 1 in the list at index 2 in the list at index 1.

Q.9. How will you turn the list a = [1, 2, 7, 8] into [1, 2, 3, 4, 5, 6, 7, 8]?

Please select 2 correct answers

Correct! Wrong!

a[2:2] adds elements between 2 and 7. a[2:3] also replaces 7.

Q.10. What is the value of y?

xyz - Python Quiz
Correct! Wrong!

Q.11. What is the result of {1, 2, 3} & {4, 5, 6}?

Correct! Wrong!

Their intersection is an empty set. {} is an empty dictionary, not an empty set.

Q.12. Which statements delete the value ‘milk’ from the set s = {‘milk’, ‘cheese’, ‘butter’, ‘buttermilk’}?

Please select 4 correct answers

Correct! Wrong!

You cannot index a set. You cannot subtract a string from a set, you can subtract a set from a set. pop() will not necessarily remove ‘milk’.

Q.13. In the following code, how many objects and references does Python create?

name and fname - Python Quiz
Correct! Wrong!

There is only one string object ‘Ayushi’ and two references to it. name and fname refer to this object.

Q.14. According to PEP 8, what case should you use for variable names with more than one word?

Correct! Wrong!

A variable list style type should be written as list_style_type. This is snake case.

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

nums - Python Quiz
Correct! Wrong!

nums is [[], [0], [0, 1]]. We print a star for each value in each sublist if the value is less than 2.

This was all in the Python quiz by DataFlair. How many questions did you get correct? Share your experience and score of the Python quiz in the comments. If you didn’t score well, no need to worry just revise the concepts from the sidebar in which you are lacking.

21 Responses

  1. Amar says:

    14 correct answer

  2. Gautam Kumar says:

    Q. 4 Ans will be 8 .It is showing Wrong
    Kindly check


  3. Marc says:

    Missing closing parenthesis in Q12

  4. Lokesh Yadav says:

    7 out of 15

  5. Pavan Kumar Korlakunta says:

    can anyone elaborate the 15th

  6. Vikas Gupta says:

    It’s very awful for me I was able to do give only 6 right answer

  7. sandeep kumar says:

    14 answers correct

  8. Laxminarayan says:

    print (a+1)

    Correct ans is 8 ,but its showing me wrong,
    Kindly check all.


    14/15 are I scored

  10. Deepak Manglani says:


  11. Deepa says:

    10 / 15 I scored

    can just explain que. 10 Ans.
    How it is 6

  12. Lakshmeesha Kadamannaya says:

    I scored 11/15

  13. Parminder Singh says:

    15 correct!!! yayyyyy i guess teaching well!! thank you lol

  14. saswati sinha says:


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.