Python 第4页
上课笔记以及平时作业记录

Python_上学期复习—课后作业

1.编写一个程序,能计算下面公式计算并输出 x 的值。 $$x=\frac{-b+\sqrt{b^{2}-4ac}}{2a}$$ 代码: a = int(input('请输入a的值:')) b = int(input('请输入b的值:')) c = int(input('请输入c...
北梦的头像-北梦の博客SVIP北梦1年前
02698

python-课堂笔记-5.9

import re str1 = 'my naaaame is iu' #从开始位置去进行匹配 # print(re.match('my', str1).group(0)) # #search()是从整个字符串中查找和正则表达式匹配的字符串 # print(re.search('iu', str...
iu不错哦的头像-北梦の博客iu不错哦1年前
0151

Python_练习_24.3.15

class Friend: def __init__(self): self.friend_li = {} # 实例方法 def welcome(self): print('欢迎来到好友管理系统') print('1.添加好友') print('2.删除好友') print('3.展示好友') print(...
北梦的头像-北梦の博客SVIP北梦1年前
012811

Python_封装和继承_练习

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

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年前
09215

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'没有...
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年前
0959

Python_练习_24.3.29

选择题 try-except-else-finally练习 编写程序,按用户输人的半径计算圆的面积,若半径为负值则抛出异常

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('请输入被除...

python课堂笔记

 
iu不错哦的头像-北梦の博客iu不错哦1年前
0181