有没有python大佬帮帮忙?

Python014

有没有python大佬帮帮忙?,第1张

代码如下:

amount_pen = int(input("铅笔数量:"))

amount_stu = int(input("学生人数:"))

result_1 = amount_pen // amount_stu

result_2 = amount_pen % amount_stu

print("平均每人分得%d只铅笔,余%d只。" %(result_1, result_2))

输出结果示例:

铅笔数量:20

学生人数:6

平均每人分得3只铅笔,余2只。

代码如下:

price = input("请输入商品价格以空格分割:").strip()

price = list(map(int,price.split(' ')))

amount = len(price)

if amount >= 5:

print(f"购买了{amount}件商品,享受八折优惠。优惠后的价格为:{sum(price)*0.8},优惠金额为:{sum(price)*0.2}")

else:

print(f"购买了{amount}件商品。总价为:{sum(price)}")

输出如下: