03
假设商品总价为 price
price = 19.87
抹零操作
rounded_price = int(price)
print(f"抹零后的价格为: {rounded_price}")
打印学号后四位
print("学号后四位: 3034")
04
输入学生的三门成绩
score1 = float(input("请输入第一门成绩: "))
score2 = float(input("请输入第二门成绩: "))
score3 = float(input("请输入第三门成绩: "))
计算最高分和最低分
max_score = max(score1, score2, score3)
min_score = min(score1, score2, score3)
计算分差
diff_score = max_score - min_score
计算平均分
average_score = (score1 + score2 + score3) / 3
print(f"分差为: {diff_score}")
print(f"平均分为: {average_score}")
打印学号后四位
print("学号后四位: 3034")
05
输入两个数
num1 = float(input("请输入第一个数: "))
num2 = float(input("请输入第二个数: "))
使用比较运算符比较大小
if num1 > num2:
print(f"{num1} 大于 {num2}")
elif num1 < num2:
print(f"{num1} 小于 {num2}")
else:
print(f"{num1} 等于 {num2}")
打印学号后四位
print("学号后四位: 3034")
06
输入手机原价
original_price = float(input("请输入手机原价: "))
输入折扣(如 8 折输入 0.8)
discount = float(input("请输入折扣: "))
计算折后价格
final_price = original_price * discount
print(f"折后价格为: {final_price}")
打印学号后四位
print("学号后四位: 3034")
浙公网安备 33010602011771号