class Smartphone:
def __init__(self):
self.battery_level = 100
def use(self, amount):
self.battery_level -= amount
if self.battery_level < 0:
self.battery_level = 0
def charge(self, amount):
self.battery_level += amount
if self.battery_level > 100:
self.battery_level = 100
phone = Smartphone()
phone.use(30)
print(phone.battery_level)
phone.charge(30)
print(phone.battery_level)
To embed this project on your website, copy the following code and paste it into your website's HTML: