首页 > 编程语言 > 详细

Python函数

时间:2018-10-19 19:37:31      阅读:201      评论:0      收藏:0      [点我收藏+]
Python中用函数计算汇率;
def convert_currency(im,er):
 out=im*er
 return out
USD_VS_RMB=6.77
#带单位的货币输入
currency_str_value=input(请输入带单位的货币金额:)
unit=currency_str_value[-3:]
if unit==CNY:
 exchange_rate=1/USD_VS_RMB
elif unit==USD:
 exchange_rate=USD_VS_RMB
else:
 exchange_rate=-1
if exchange_rate!=-1:
 in_money=currency_str_value[:-3]
 #调用函数
 out_money=convert_currency(in_money,exchange_rate)
 print(转换后的金额:,out_money)
else:
 print(不支持该种货币!)

 

 

Python函数

原文:https://www.cnblogs.com/llhhcc/p/9818343.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!