I just learned how to implement basic command-line argument with Python. Hence, I would like to incoporate this feature in the previous Temperature Conversion program.
`# convertc2f.py
Version: 0.2
A program to convert Celsius temps to Fahrenheit
Date: 4/13/06
by: S. San (Kenno)`
import sys
if (len(sys.argv) == 2):<br /> celsius = int(sys.argv[1])<br /> else:<br /> celsius = int(input("What is the Celsius temperature? "))
fahrenheit = 9.0 / 5.0 * celsius + 32<br /> print "The temparature is ", fahrenheit, " degrees Fahrenheit."<br />
Example with the command line argument:
$ python convertc2f.py 100<br /> The temparature is 212.0 degrees Fahrenheit.
Without any argument: <br />
$ python convertc2f.py<br /> What is the Celsius temperature? 100<br /> The temparature is 212.0 degrees Fahrenheit.