Temperature portray two different systems: degrees Celsius (Celsius) and ° F (Fahrenheit).
Please write programs to convert Fahrenheit to Celsius user input, or input conversion Celsius to Fahrenheit.
Conversion algorithm is as follows: (C indicates Celsius, F represents F)
C = ( F - 32 ) / 1.8
F = C * 1.8 + 32
Requirements are as follows:
(1) uses input and output Celsius initial capital letters C, the temperature may be an integer or decimal, such as: C12.34 refers to degrees Celsius 12.34;
F (2) input and output using uppercase letter F., The temperature may be an integer or decimal, such as: F87.65 refers to 87.65 degrees Fahrenheit;
(3) does not consider the issue of abnormal input, output to two decimal places;
(4) using the input () to get the test case input, not to increase the prompt string.
tempstr = input() l = len (tempStr) if tempStr [0] in [ ' F ' , ' f ' ]: C = (eval(tempstr[1:l])-32)/1.8 print("C{:.2f}".format(C)) elif tempstr[0] in ['C','c']: F = 1.8*eval(tempstr[1:l])+32 print("F{:.2f}".format(F))
RMB and US dollar is one of two common currency in the world, write a program conversion between currencies, in which:
Fixed exchange rate between the yuan and the dollar: 1 US dollar = 6.78 yuan.
Can accept renminbi, or $ input, converted into US dollars or RMB output. The use of RMB yuan, said the dollar USD, said there is no space between the sign and magnitude.
tempstr = input() l = len (tempstr) s1='RMB' s2='USD' if(tempstr[0:3]==s1): x = eval (tempstr [3 : l]) x/=6.78 print("USD{:.2f}".format(x)) else: x = eval (tempstr [3 : l]) x*=6.78 print("RMB{:.2f}".format(x))