Python3 # Temperature in celsius degreecelsius =40# Converting the temperature to# fehrenheit using the above# mentioned formulafahrenheit = (celsius *1.8) +32# printing the resultprint('%.2f Celsius is equivalent to:%.2f Fahrenheit'%(celsius, fahrenheit)) 輸出: 40.00 Celsius is equivalent to...
创建将华氏度转换为摄氏度的函数: python def fahrenheit_to_celsius(fahrenheit): """ 将华氏度转换为摄氏度 :param fahrenheit: 华氏度温度值 :return: 转换后的摄氏度温度值 """ return (fahrenheit - 32) * 5/9 测试上述两个函数: python # 测试摄氏度转换为华氏度 print(celsius_to_fahrenheit(0)...
在Python中,转换摄氏度到华氏度的核心原理是使用上述公式进行数学运算。接下来,我将简化这一过程,通过表格展示不同温度单位之间的对应关系,并提供类图描述温度转换的实现方法。 defcelsius_to_fahrenheit(celsius):'''Function to convert Celsius to Fahrenheit'''returncelsius*9/5+32 1. 2. 3. TemperatureConverte...
Program to convert temperature from Fahrenheit to Celsius in Kotlinpackage com.includehelp import java.util.* //Main Function , Entry point of Program fun main(args: Array<String>) { //Input Stream val scanner = Scanner(System.`in`) //Input temperature in Fahrenheit print("Enter temperature ...
PYthon二级程序题:温度转换 II 程序描述 温度的刻画有两个不同体系:摄氏度(Celsius)和华氏度(Fabrenheit)。请编写程序将用户输入华氏度转换为摄氏度,或将输入的摄氏度转换为华氏度。转换算法如下:(C表示摄氏度、F表示华氏度)C = ( F - 32 ) / 1.8 F = C * 1.8 + 32 要求如下:(1) 输入...
Input the temperature you like to convert? (e.g., 45F, 102C etc.) : 104f The temperature in Celsius is 40 degrees. Flowchart: For more Practice: Solve these Related Problems: Write a Python program to convert a list of temperatures in Celsius to Fahrenheit and vice versa, outputting bo...
import java.util.Scanner; public class Program { //your code goes here static double fahr(int celsius){ double result = (1.8*celsius)+32; return result; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); double c = sc.nextDouble(); int convert= (int)...