-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMoneyTransfer.py
More file actions
executable file
·51 lines (32 loc) · 3.49 KB
/
Copy pathMoneyTransfer.py
File metadata and controls
executable file
·51 lines (32 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
# -*- coding:utf-8 -*-
__author__ = 'MFC'
__time__ = '2019-03-21 16:47'
"""
货币转换 I
描述
人民币和美元是世界上通用的两种货币之一,写一个程序进行货币间币值转换,其中:
人民币和美元间汇率固定为:1美元 = 6.78人民币。
程序可以接受人民币或美元输入,转换为美元或人民币输出。人民币采用RMB表示,美元USD表示,符号和数值之间没有空格。
注意:
(1) 这是一个OJ题目,获得输入请使用input() ;
(2) 不提示输出格式错误,结果小数点后保留两位。
输入
示例1:RMB123
示例2:USD20
输出
示例1:USD18.14
示例2:RMB135.60
PS:温度转换题的变种
"""
TempStr = input("")
if TempStr[:3] in ['USD']:
rmb = eval(TempStr[3:]) * 6.78
print("RMB{:.2f}".format(rmb))
elif TempStr[:3] in ['RMB']:
usd = eval(TempStr[3:]) / 6.78
print("USD{:.2f}".format(usd))
else:
print("")