Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

Multiple Choice Quiz About Python - Part 2

Review Multiple Choice Quiz About Python - Part 2 with focused questions, clear answer guidance, and practical takeaways to strengthen your understanding.

Table of Contents

This article presents Multiple Choice Quiz About Python - Part 2 in a clear, structured format. It helps readers review key concepts, test their understanding, and learn from the material.

Understanding Multiple Choice Quiz About Python

  • Question 1: Which assertion is correct when talking about the following code:
    def printHello ():
    print ("Hello")
    a = printHello ()
    • printHello () is a function and a is a variable. Both are not objects.
    • Both printHello () and a represent the same object.
    • printHello () and a are two different objects.
    • Syntax error. Cannot assign functions to a variable in Python.
  • Question 2: What is the output of the program below?
    def outerFunction ():
    global a
    a = 20
    def innerFunction ():
    global a
    a = 30
    print ('a =', a)
    a = 10
    outerFunction ()
    print ('a =', a)
    • a = 10 a = 30
    • a = 10
    • a = 20
    • a = 30
  • Question 3: Which of the following statements is true?
    • Class (class) is a detailed plan for the object.
    • Only one object can be created from a given class.
    • Both answers are correct.
    • There is no exact answer.
  • Question 4: What is the result of the code below?
    class Foo:
    def printLine (self, line='Python'):
    print (line)
    o1 = Foo ()
    o1.printLine ('Java')
    • Python
    • line
    • Java
    • Java Python
  • Question 5: What is the meaning of __init __ () function in Python?
    • Create a class to use.
    • Called when a new object is initialized.
    • Initialize and bring all data attributes to 0 when called.
    • There is no right answer.
  • Question 6: What is the output of the program below?
    class Point:
    def __init__(self, x = 0, y = 0):
    self.x = x+1
    self.y = y+1
    p1 = Point ()
    print (p1.x, p1.y)
    • 0 0
    • 1 1
    • None
    • xy
  • Question 7: Which of the following code uses Python's inheritance feature?
    • class Foo:
      Pass
    • class Foo (object):
      pass
      class Hoo (object)
      pass
    • class Foo:
      pass
      class Hoo (Foo):
      pass
    • There is no exact answer.
  • Question 8: What is a class inherited from two different classes of attributes?
    • Multi-level inheritance (Multilevel Inheritance)
    • Multiple Inheritance
    • Hierarchical Inheritance
    • Inheritance
  • Question 9: Which of the following statements is true?
    • In Python, an operator may have different operations depending on the operand used.
    • You can change the way operators work in Python.
    • __add () __ is called when the '+' operator is used.
    • All answers are correct.
  • Question 10: The results of the program below are:
    class Point:
    def __init__(self, x = 0, y = 0):
    self.x = x
    self.y = y
    def __sub__(self, other):
    x = self.x + other.x
    y = self.y + other.y
    return Point (x, y)
    p1 = Point (3, 4)
    p2 = Point (1, 2)
    result = p1-p2
    print (result.x, result.y)
    • 2 2
    • forty six
    • 0 0
    • 1 1

FAQ

What is the main point of Multiple Choice Quiz About Python - Part 2?

Question 1: Which assertion is correct when talking about the following code: def printHello (): print ("Hello") a = printHello () printHello () is a function and a is a variable. Both printHello () and a represent the same object.

Why is Multiple Choice Quiz About Python - Part 2 important?

Multiple Choice Quiz About Python - Part 2 matters because it can affect how readers understand, choose, use, or respond to the subject discussed in the article.

What should readers verify about Multiple Choice Quiz About Python - Part 2?

Check the date, product or software version, compatibility, and any current guidance before acting, especially when technology, security, health, or pricing is involved.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.