Basic usage
Input
Product.set_discount(0.1); Product('Notebook', 100).discounted_price()
Output
90.0
Setting a 10% discount then creating a product with price 100 returns 90.0 after discount.
Full lesson preview
Practice using a class attribute shared across all instances and implement methods to read and update it. Observe how changing the class attribute affects existing and new instances.
Problem statement
Task
Examples
Input
Product.set_discount(0.1); Product('Notebook', 100).discounted_price()
Output
90.0
Setting a 10% discount then creating a product with price 100 returns 90.0 after discount.
Input format
Output format
Constraints
Samples
Input
Product.set_discount(0.25); Product('Lamp', 40).discounted_price()
Output
30.0
25% discount on 40 yields 30.0.