1. First open the software
2. In the mac environment, enter Command+N (windows: Ctrl+N) to create a file window, enter the following code and then save Command+S (windows: Ctrl+S) and finally run (Fn+F5)
#Input(数据输入)
TempStr=input('请输入带单位的温度值:')
#Process(数据处理)
if (TempStr[-1] in ['F','f']):
C=(eval(TempStr[0:-1])-32)/1.8
#Output(数据输出)
print('转换后的温度值为:{:.2f}C'.format(C))
elif(TempStr[-1] in ['C','c']):
F=eval(TempStr[0:-1])*1.8+32
print('转换后的温度值为:{:.2f}F'.format(F))
else:
print('输入数据错误,请重新输入')
The running diagram is as follows, you can start to convert each other