Basic usage
Input
InventoryItem.set_tax_rate(0.2); InventoryItem(100).price_with_tax()
Output
120.0
Setting the class tax_rate to 0.2 makes a 100 unit item cost 120.0 with tax.
Full lesson preview
Use a class method to update class-level state that affects instances of that class. Learn how classmethods are bound to the calling class, making subclass behavior predictable.
Problem statement
Task
Examples
Input
InventoryItem.set_tax_rate(0.2); InventoryItem(100).price_with_tax()
Output
120.0
Setting the class tax_rate to 0.2 makes a 100 unit item cost 120.0 with tax.
Input format
Output format
Constraints
Samples
Input
InventoryItem.set_tax_rate(0.05); InventoryItem(200).price_with_tax()
Output
210.0
A 5% tax on 200 yields 210.0.