程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python exchange rate conversion

編輯:Python

Python currency converter

Title Description

According to the design idea of temperature conversion program in the textbook , according to 1 dollar = 6 The exchange rate of RMB prepares the two-way exchange procedure between USD and RMB .

Input

Enter a line of string , Indicates the amount of RMB or US dollars . Ensure that the last bit of the string is A-Z The letter of , All other positions are numbers .
     The last place of RMB must be ‘R’ perhaps ‘r’
     The last dollar must be ‘D’ perhaps ‘d’

Output

Output the converted result . The result is expressed as a string , Output an integer in front , Last bit output “R” perhaps “D” Means RMB or US dollar .
If you can't convert , Output “Error!” .

The sample input

12R

Sample output

2D

Run code

str1=input()
digit=''
eng=''
for i in range(0, len(str1)):
if(str1[i].isdigit()):
digit=digit+str1[i]
else:
eng=eng+str1[i]
if((eng=='D')|(eng=='d')):
printnum=int(digit)*6
outstr1=str(printnum)+'R'
print(outstr1)
elif((eng=='R')|(eng=='r')):
printnum=int(int(digit)/6)
outstr2=str(printnum)+'D'
print(outstr2)
else:
print('Error!')

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved