2022年2月26日

Python: 练习 面向对象 烤地瓜

class SweetPotato: def __init__(self): self.cook_time = 0 self.state = "生的" self.flavour = [] def cook_program(self, time): self.cook_time += time if 0 <= self.cook_time < 3: self.state = "生的" elif 3 <= self.cook_time < 5: self.state = "半生" elif 5 <= self.cook_time < 8: self.state = "熟啦" elif self.cook_time >= 8: self.state = "糊了" def cook_flavour(self, flavour): self.flavour.append(flavour) d…
2022年2月23日

Python 练习:学员管理系统

# 学员管理系统 def welcome():     print("学员管理系统")     print("*" * 20)     print("1.增加学员 2.删除学员 3.修改学员 4.查询学员 5.显示所有学员 6.退出")     print("*" * 20)     input_num = int(input("请输入功能序号:"))     return input_num info = [] def get_stu_name():     stu_name = input("请输入学员姓名:")     return stu_name def add_stu_info():     stu_name = input('…
2022年2月14日

Python 第一个程序:石头,剪刀,布

import randomp = player = int(input("请出招(石头-0,剪刀-1,布-2):"))c = computer = random.randint(0, 2)# print(f"你:{p}")# print("电脑:%d" % c)# print(f"你:{p}\n电脑:{c}")print("你:%d\n电脑:%d" % (p, c))if (p == 0 and c == 1) or (p == 1 and c == 2) or (p == 2 and c == 0): print("You Win!")elif p == c: print("平局")else: print("You Lose!")…