python123外汇兑换程序,货币兑换程序python

我正在制作一个三明治店的程序,用户要求三明治,然后程序告诉你改变。

我是python新手,我对它有一点了解。在

这是我的代码:print "Welcome to the sandwich shop!"

name = raw_input("What is your name?")

print "The price of a sandwich is 0.5 dollars"

print "The price of a cookie is 0.05 dollars"

print "The price of a mint is 0.01 dollars"

sandwich = int(raw_input("How many sandwiches do you want?"))

cookie = int(raw_input("How many cookies do you want?"))

mint = int(raw_input("How many mints do you want?"))

sandwich_price = 0.5

cookie_price = 0.05

mint_price = 0.01

sandwich_price_total = sandwich * sandwich_price

cookie_price_total = cookie * cookie_price

mint_price_total = mint * mint_price

total_order = sandwich_price_total + cookie_price_total + mint_price_total

print "The order will be %r dollars!" % total_order

penny = 0.01

nickel = 0.05

dime = 0.10

quater = 0.25

dollar = 1

five = 5

twenty = 20

fifty = 50

print "Please pay in cash."

pay = int(raw_input("Insert your money!"))

change = pay - total_order

coins = [penny, nickel, dime, quater, dollar, five, twenty, fifty]

def change(n, coins_avaliable, coins_so_far):

if sum(coins_so_far) == change:

yield coins_so_far

elif sum(coins_so_far) > change:

pass

elif coins_avaliable == []:

pass

else:

for c in change(change, coins_avaliable[:], coins_so_far + [coins_avaliable]):

yield c

for c in change(change, coins_avaliable[1:], coins_so_far):

yield c

solution = [s for s in change(n, coins, [])]

for s in solution:

print s

什么也没发生!在

请帮忙!在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值