Objective
Create a Python program that compares two objects of a dataclass: @dataclass automatically generates __eq__, which compares attribute by attribute.
Instructions
- Define
@dataclass class Productwithname: strandprice: int. - Read two lines, each with the format
name price(the name is a single word), and create a product with each one. - Show the two products with
print, one per line, and on the third lineEqualorDifferentdepending on the result of==.
pan 2
pan 2
Product(name='pan', price=2)
Product(name='pan', price=2)
Equal
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise