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 method of a class is a generator. The object's text is changed after the generator is made, but before it is read. What does the program print?
Python ProgrammingAdvancedHigh School (11–12)Python Going Further › Classes and ObjectsPCAP (Python Institute)
+2 more exams
A-LevelIB
A-LevelIBPCAP (Python Institute)
StemPy LabCreated by StemPy Lab

A method of a class is a generator. The object's text is changed after the generator is made, but before it is read. class Poem: def __init__(self, text): self.text = text def lines(self): for n, line in enumerate(self.text.split("/"), 1): yield str(n) + ":" + line.strip() p = Poem("roses / violets /sugar") g = p.lines() p.text = "new" print(list(g), len(list(p.lines()))) What does the program print?

Log in to save
← All Quizzes
← A parser class splits a line at a separator kept in a class variable. Two child classes are made from it. What does the program print?A generator function gives the characters of a text up to a stop character, and then ends with return. What does the program print? →
More onPython Going Further › Classes and Objects

Discussion (0)

Log in to join the discussion.

Loading…

More questions on this topic

  1. A class Point takes one required parameter and one with a default value. Each option below is run…Medium
  2. A film object should report its kind through a method title. But the constructor stores the film's…Medium
  3. A class uses an empty list as the default value of a parameter of __init__. What does the program…Advanced
  4. In its constructor, a badge object gives itself a level that hides the one on the class. Straight…Advanced
  5. Two cars are built around the same engine object. What does the program print?Hard
All questions on this topic →

Problems on this topic

  1. A class Dog has the attributes name and age…Medium
  2. A class Basket has def __init__(self, items=[]) and self.items = items…Medium
  3. Class or object attribute?Medium
  4. Using the BankAccount class of the lesson, add a method transfer(other, amount) that moves money…Medium
All problems on this topic →