Code Example (Input, Process, Output)

You are in a foreign country that uses Fahrenheit for temperature everywhere. However, you are only familiar with Celsius. Write a program to solve the problem.

Analysis:

Input: Ask user to key in a Fahrenheit value

Process: Convert it to Celsius value

Output: Display the Celsius value on the screen

Code:

#input
f = input("Enter temperature in F: ")
#process
f = float(f) #convert f from string to float
c = (f - 32) * 5 / 9
#output
print("Temperature in C is " + str(c) )


Last modified: Wednesday, 3 May 2017, 4:29 PM