Site icon DataFlair

Python Quiz Questions and Answers

python quiz questions and answers

Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python

In this Python quiz, you will be able to practice advanced concepts of Python. This quiz contains 30 questions with answers, each question has four options and covers different concepts of Python. Let’s start the quiz. All the best!

Time limit: 0

Quiz Summary

0 of 30 Questions completed

Questions:

Information

You have already completed the quiz before. Hence you can not start it again.

Quiz is loading…

You must sign in or sign up to start the quiz.

You must first complete the following:

Results

Quiz complete. Results are being recorded.

Results

0 of 30 Questions answered correctly

Your time:

Time has elapsed

You have reached 0 of 0 point(s), (0)

Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)

Categories

  1. Not categorized 0%
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  1. Current
  2. Review / Skip
  3. Answered
  4. Correct
  5. Incorrect
  1. Question 1 of 30
    1. Question

    Which of the following is not true about self class in  Python?

    Correct
    Incorrect
  2. Question 2 of 30
    2. Question

    What is the output of the below code?

    def func1():

        n=10

        def func2():

            nonlocal n

            print(n)

        func2()

    func1()

    Correct
    Incorrect
  3. Question 3 of 30
    3. Question

    What is the output of the code given below?

    def func(a,b):

        a=a*b

        b=a//b

        return b,a 

     

    a=5

    b=7

    a,b=func(a,b)

    print(a,b)

    Correct
    Incorrect
  4. Question 4 of 30
    4. Question

    Which of the following is true regarding sets?

    Correct
    Incorrect
  5. Question 5 of 30
    5. Question

    Find the output of the following code.

    [ j for i,j in enumerate({1,2,3,4,5}) if j%2==0]

    Correct
    Incorrect
  6. Question 6 of 30
    6. Question

    Which of the following types of inheritance is not supported by Python?

    Correct
    Incorrect
  7. Question 7 of 30
    7. Question

    What is the output of the below code?

    def decor1(func):

    def fun():

    x = func()

    return x * x

    return fun

     

    def decor2(func):

    def fun():

    x = func()

    return 2 * x

    return fun

     

    @decor1

    @decor2

    def func():

    return 5

     

    print(func())

    Correct
    Incorrect
  8. Question 8 of 30
    8. Question

    What is pickling in Python?

    Correct
    Incorrect
  9. Question 9 of 30
    9. Question

    What is the output of the below code?

    def fib(n):

        x, y = 0, 1

        while x < n:

            yield x

            x, y = y, x + y

     

    x=fib(5)

    next(x)

    Correct
    Incorrect
  10. Question 10 of 30
    10. Question

    Which of the following is the wrong way to give type annotations to a function?

    Correct
    Incorrect
  11. Question 11 of 30
    11. Question

    What is the output of the below code?

    def func(*args,**kwargs):

        return len(args)-len(kwargs)

     

    func(1,3,’abs’,n=5,a=’g’)

    Correct
    Incorrect
  12. Question 12 of 30
    12. Question

    Which of the following is true about .pyc files in Python?

    Correct
    Incorrect
  13. Question 13 of 30
    13. Question

    A class is an instance of which of the following?

    Correct
    Incorrect
  14. Question 14 of 30
    14. Question

    What is the output of the below code?

    numpy.linspace(1,3,5)

    Correct
    Incorrect
  15. Question 15 of 30
    15. Question

    Which of the following is not true about GIL?

    Correct
    Incorrect
  16. Question 16 of 30
    16. Question

    What is the output of the below code?

    print(regex.subn(‘1′,’11’,’12413′)[1])

    Correct
    Incorrect
  17. Question 17 of 30
    17. Question

    Which of the following is true about method resolution order?

    Correct
    Incorrect
  18. Question 18 of 30
    18. Question

    What is the output of the below code?

    list1=[‘a’,’b’,’c’]

    list2=[‘a’,’b’,’c’]

    list1.append([1,2,3])

    list2.extend([1,2,3])

    print(list1[-1],”,”,list2[-1])

    Correct
    Incorrect
  19. Question 19 of 30
    19. Question

    Which of the following is true about the difference between classmethod and staticmethod?

    Correct
    Incorrect
  20. Question 20 of 30
    20. Question

    What is the output of the below code?

    s=’Python’

    s[::-1][::2]

    Correct
    Incorrect
  21. Question 21 of 30
    21. Question

    Which of these is the correct code to replace all NaN with 0?

    Correct
    Incorrect
  22. Question 22 of 30
    22. Question

    What is the output of the below code?

    try:

        x=[1,2,3,4,5][5]

    except:

        print(“Exception”)

    else:

        print(div)

    Correct
    Incorrect
  23. Question 23 of 30
    23. Question

    The code that is used to modify a method in a module or a class during runtime is called

    Correct
    Incorrect
  24. Question 24 of 30
    24. Question

    What is the output of the below code?

    def func(n):

        if(n==0):

            return

        func(n//2)

        print(n,end=’ ‘)

    func(10)

    Correct
    Incorrect
  25. Question 25 of 30
    25. Question

    Which of the following is true about the difference between a module and a package in Python?

    Correct
    Incorrect
  26. Question 26 of 30
    26. Question

    What is the output of the below code?

    li=[]

    for i in range(5):

        li.append(lambda :i*2)

    li[3]()

    Correct
    Incorrect
  27. Question 27 of 30
    27. Question

    What is the worst time complexity of the merge sort algorithm?

    Correct
    Incorrect
  28. Question 28 of 30
    28. Question

    Which of the following is not true about Django?

    Correct
    Incorrect
  29. Question 29 of 30
    29. Question

    Which of the following is not a method that is used to connect to a database using flask?

    Correct
    Incorrect
  30. Question 30 of 30
    30. Question

    What is the name of the event when the cache expires and the websites get multiple client requests at a time?

    Correct
    Incorrect

Summary

Hope you enjoyed taking this quiz. Please learn from your mistakes, if any. Do not forget to share your score in the comment section.

Exit mobile version