Skip to content
Quiz · Classes · lesson 4 of 11

Quiz — __str__ and __repr__

What does the program print?

Python
class Point:
    def __init__(self, x):
        self.x = x

    def __repr__(self):
        return f"Point({self.x})"

    def __str__(self):
        return f"point {self.x}"


print(Point(1), [Point(2)])

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way