Home > MCQs > IT & Programming > Python MCQs

Python MCQ

Python Quick Quiz

Question 1 of 10
  • What does the pass statement do?

    Answer & Explanation

    Correct Answer: Nothing. It can be used when a statement is needed syntactically.

    Note: This Question is unanswered, help us to find answer for this one

  • How would you write the following with a list comprehension? x = [] for i in range(5): x.append([]) for j in range(10): x[-1].append(j)

    Answer & Explanation

    Correct Answer: x = [[i for i in range(10)] for j in range(5)]

    Note: This Question is unanswered, help us to find answer for this one

  • In a Python 2 new-style class declared as "Child(Base)", what is the correct way for a method "foo()" to call its base implementation?

    Answer & Explanation

    Correct Answer: super(Child, self).foo()

    Note: This Question is unanswered, help us to find answer for this one

  • A loop controlled by the user is a type of ____ loop.

    Answer & Explanation

    Correct Answer: Incrementing

    Note: This Question is unanswered, help us to find answer for this one

  • The function apply has the same functionality as:

    Answer & Explanation

    Correct Answer: *args, **kwargs

    Note: This Question is unanswered, help us to find answer for this one

  • What is htmllib?

    Answer & Explanation

    Correct Answer: An HTML parser based on the sgmllib SGML parser.

    Note: This Question is unanswered, help us to find answer for this one

  • Which of the following is a valid class declaration?

    Answer & Explanation

    Correct Answer: class NameClass(object): def __init__(self, var1, var2): self.var1 = var1 self.var2 = var2

    Note: This Question is unanswered, help us to find answer for this one

  • According to PEP8 python programs should generally be indented with:

    Answer & Explanation

    Correct Answer: 4 spaces

    Note: This Question is unanswered, help us to find answer for this one

  • What is the name of a feature invoked by the following: "This is a string"[3:9]

    Answer & Explanation

    Correct Answer: Slices

    Note: This Question is unanswered, help us to find answer for this one

  • Which statement does NOT describe the object-oriented programming concept of encapsulation?

    Answer & Explanation

    Correct Answer: It only allows the data to be changed by methods.

    Note: This Question is unanswered, help us to find answer for this one

  • Python Quick Quiz

    battery

    Poor Results!

    You need a lot of improvement.

    Just don't give up!

    Correct Answers: 0/10

    Start Practicing with our MCQs given below.