假设商品总价为 price

price = 19.87

抹零操作

rounded_price = int(price)
print(f"抹零后的价格为: {rounded_price}")

打印学号后四位

print("学号后四位: 1234")

输入学生的三门成绩

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("学号后四位: 1234")

输入两个数

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("学号后四位: 1234")

posted on 2025-04-13 14:30  986614  阅读(15)  评论(0)    收藏  举报