Python 第4页

Python_封装和继承_练习

使用继承机制,为Car类创建两个子类:赛车(Racing_Car)类和公交车(Bus)类。为Car类定义属性最高时速(Top_speed)属性和核载人数(Nuclear_Number)方法,并分别通过子类对象调用父类中的成...
北梦的头像-北梦の博客SVIP北梦1年前
0798

Python_练习_24.3.22

class School_number(): def __init__(self, name, age): self.name = name self.age = age def describe(self): print(f'我的名字是{self.name},我的年龄是{self.age}') class Student(School...
北梦的头像-北梦の博客SVIP北梦1年前
07615

Python_练习_24.3.28

class ShoppingCart: def __init__(self): self.items = [] def add_items(self, item): if item in items_price: self.items.append(item) print(f'{item}已添加到购物车') else: print(f'没有...
北梦的头像-北梦の博客SVIP北梦1年前
0785
python购物车练习-北梦の博客

python购物车练习

class Shopping: def __init__(self): self.car = [] def shopping_car(self, itme): self.car.append(itme) def shopping_del(self, itme): self.car.remove(itme) def shopping_all(self): if...
koniaoer的头像-北梦の博客koniaoer1年前
0779

Python_练习_24.3.29

选择题 try-except-else-finally练习 编写程序,按用户输人的半径计算圆的面积,若半径为负值则抛出异常
北梦的头像-北梦の博客SVIP北梦1年前
0421

Python_练习_24.4.7

练习1 def GetAge(age): try: if age <= 0: raise Exception('输入的年龄不符合要求') except ValueError: print('年龄必须大于0') raise GetAge(-1) 练习2 num_one = int(input('请输入被除...
北梦的头像-北梦の博客SVIP北梦1年前
0531