Assignment 2 Instructions for Assignment 2: Fahrenheit/Celsius Conversion The se
ID: 3743084 • Letter: A
Question
Assignment 2 Instructions for Assignment 2: Fahrenheit/Celsius Conversion The second assignment is to demonstrate an initial use of variables. You can write two programs that convert from Fahrenheit to Celsius, and from Celsius to Fahrenheit. Your version must handle fractions of a degree. The equation for converting F to C is: (F-32) * 5/9 The equation for converting C to F is: C * 9 / 5 + 32 You can test your code on the following conversions: 10C-50F, 20C-68F, 40C-40F for first program 99.5F-37.5C, and 98.6F-37C. and for second program The python functions are named yournameF2C and second one yournameC2F Create the files with the same name for first project and second project respectively. . .First one yournameF2C converts from Fahrenheit to Celsius and second one yournameC2F converts from Celsius to farenheit The program outputs a pleasant greeting that introduces the program (e.g. "I will convert temperatures for you"). In each program the user should be able to input the temperature to convert with the aid of an useful message. . The program outputs a meaningful message about the conversion along with the result. .The program computes the correct result The program handles "decimal" values like 98.6 or 37.2 You can zip both files together and submit as one.zip or you can zip both files separate and submit separate. Make sure that the zip consists of the.py files.
Explanation / Answer
#This is first program Which converts fahrenheit to celsius
#!/usr/bin/python
#Definition of a function
def yourNameF2c( f ):
#converting fahrenheit to celsius
cel=(float(f)-32) * 5/9
f=f+"u00b0F" #u00b0 adds degree symbol
cel=str(cel)+"u00b0C" #concatinates degree C with the value
print(f," is equal to ",cel ) #Printing final result with a message
return; #End of function definition
print("Hello User we are happy to convert fahrenheit to celsius for you..
Enter Temprature in Fahrenheit:")
Fer = input() #User enters temptrature that stores into variable Fer
yourNameF2c(Fer) #function call and passes the value that user entered
#This program converts celsius to Fahrenheit
#!/usr/bin/python
# Function definition is here
def yourNameC2F( cel ):
fer=float(cel) * 9 / 5 +32 #converting Fahrenhites to celsius
cel=cel+"u00b0C"
fer=str(fer)+"u00b0F"
print(cel," is equal to ",fer ) #printing final result with a message
return; #End of function definition
print("Hello User we are happy to convert celsius into Fahrenheit for you..
Enter Temprature in Celsius:")
cel = input() #User enters temptrature that stores into variable cel
yourNameC2F(cel) #function call and passes the value that user entered