Question: Run below program in Python and explain 1. F = raw_input(Enter a temperature in Fahrenheit: ) F = float(F) C = 5 / 9. *

Run below program in Python and explain

1.

F = raw_input("Enter a temperature in Fahrenheit: ")

F = float(F)

C = 5 / 9. * (F - 32)

print "%g Fahrenheit = %g Celsius" % (F, C)

2.

import sys

F = float(sys.argv[1])

C = 5 / 9. * (F - 32)

print "%g Fahrenheit = %g Celsius" % (F, C)

3.

import sys

try:

F = float(sys.argv[1])

except IndexError:

print 'You failed to provide a temperature in Fahrenheit '\

'as input on the command line!'

sys.exit(1)# abort

C = 5. / 9 * (F - 32)

print "%g Fahrenheit = %g Celsius" % (F, C)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!