python 写一个超市结账界面

python 写一个超市结账界面_第1张图片

product_name1 = '白菜'
product_name2 = '冬瓜'
product_name3 = '椰黄包'
product_name4 = '橙汁'
product_name5 = '营养麦片'

quantity1 = 0.8
quantity2 = 1.6
quantity3 = 1
quantity4 = 2
quantity5 = 1

price1 = 6.8
price2 = 5.2
price3 = 6.5
price4 = 4.0
price5 = 12.0

subtotal1 = round(price1 * quantity1, 2)
subtotal2 = round(price2 * quantity2, 2)
subtotal3 = round(price3 * quantity3, 2)
subtotal4 = round(price4 * quantity4, 2)
subtotal5 = round(price5 * quantity5, 2)

total = round(subtotal1 + subtotal2 + subtotal3 + subtotal4 + subtotal5, 2)

x1 = '*' * 13  # 生成13个星的字符串
x2 = x1 + '*' * 3  # 生成16个星的字符串
print(x2 + "欢迎光临好客超市" + x2)
head = "\t商品\t\t\t 数量\t\t单价\t\t\t小计"
print(head)
line1 = f"\t{product_name1}\t\t\t{quantity1}千克\t\t{price1}\t\t\t{subtotal1}"
print(line1)

line2 = f"\t{product_name2}\t\t\t{quantity2}千克\t\t{price2}\t\t\t{subtotal2}"
print(line2)

line3 = f"\t{product_name3}\t\t{quantity3}个\t\t\t{price3}\t\t\t{subtotal3}"

print(line3)

line4 = f"\t{product_name4}\t\t\t{quantity4}瓶\t\t\t{price4}\t\t\t{subtotal4}"

print(line4)

line5 = f"\t{product_name5}\t\t{quantity5}袋\t\t\t{price5}\t\t{subtotal5}"

print(line5)

print(f'\t合计:\t\t\t\t\t\t\t\t{total}')
print(x1 + "感谢您惠顾,欢迎再次光临" + x1)

你可能感兴趣的:(Python,python,开发语言)