HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Earth and Environmental Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Quizzes
  2. /A class defines __add__ but not __iadd__. A second name points to the first object before += is used. What does the program print?
Python ProgrammingHardHigh School (11–12)Python Going Further › Inheritance and Special MethodsPCAP (Python Institute)
+2 more exams
A-LevelIB
A-LevelIBPCAP (Python Institute)
StemPy LabCreated by StemPy Lab

A class defines __add__ but not __iadd__. A second name points to the first object before += is used. class Vec: def __init__(self, x, y): self.x, self.y = x, y def __add__(self, o): return Vec(self.x + o.x, self.y + o.y) def __str__(self): return f"({self.x}, {self.y})" a = Vec(1, 2) b = a a += Vec(3, 4) print(a, b, a is b) What does the program print?

Log in to save
← All Quizzes
← A thermometer reading should turn into text through its own special method. The method gives back the stored number as it is. What happens when the program runs?A film object should report its kind through a method title. But the constructor stores the film's name in capitals under that same name. What happens when the program runs? →
More onPython Going Further › Inheritance and Special Methods

Discussion (0)

Log in to join the discussion.

Loading…

More questions on this topic

  1. Three classes form a chain. Each one sets its own rate, and Premium extends the cost method with…Hard
  2. A thermometer reading should turn into text through its own special method. The method gives back…Hard
  3. The class Plane has two base classes, Wing and Tail. Both set the class variable mark, and only…Hard
  4. A list holds a Shape, a Circle and a number. The program counts its objects in two different ways.…Hard
  5. A class defines __len__, and its objects are then used as True or False. What does the program…Hard
All questions on this topic →

Problems on this topic

  1. For each pair, say whether you would use inheritance (is a) or composition (has a), and why…Easy
  2. A class Note has an attribute rupees. Write __lt__ and __str__ so that sorted puts a list of notes…Medium
  3. For each line of code, name the special method that Python calls…Easy
  4. The loop below works for any animal. Add a class Bird that says Tweet, and a class Parrot built on…Medium
All problems on this topic →