Python实现华氏温度转摄氏温度:转换公式及代码示例
2025-04-26 09:48:11
戢季珺
高则绿植
写一个将华氏温度转换成摄氏温度的程序,转换的公式是:°F = (9/5)*°C + 32
程序公式如下:#incivine ; {danatfhash; {%f“&fohr;它是一定程度,胶合的起源至1 00度至1 00度,温度的1 00度至1 00度,至1 00度至1 00度,至1 00度至1 00度,温度至1 00度至1 00度。
测量,温度可以通过不同的温度来测量。
编程题:已知两种温度的换算公式C=(5/9)(F-32),试编写一个程序输入华氏度F,输出摄氏度。
使用python的方法是:val =输入(“请输入具有温度符号的温度值(例如:3 2 c)”)ifval [-1 ]在[“ C”,“ C”]中:f = 1 .8 *float(val [0:-1 ])+3 2 print(“转换温度为::” %.2 fF"%f)elifval[-1 ]in["F","f"]:c=(float(val[0:-1 ])-3 2 )/1 .8 print("Converted temperature is: %.2 fC"%c)else:print("Incorrect input") Extended information: Solve this problem in other languages: Solve this problem in C language: #include voidMain(){floatf,c; printf(“请输入您需要转换的华氏温度: publicClassPrinttable {publicStaticVoidMain(stringArgs []){int []华氏度= {0,2 0,4 0,6 0,8 0,1 00,1 00,1 2 0,1 4 0,1 4 0,1 6 0,1 6 0,1 8 0,2 00,2 2 0,2 2 0,2 2 0,2 4 0,2 6 0,2 6 0,2 8 0,3 00}; int [] centigrade = newint [5 0]; for(int = 0; i