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):
    celsius = int(sys.argv[1])
else:
    celsius = int(input("What is the Celsius temperature? "))
 
fahrenheit = 9.0 / 5.0 * celsius + 32
print("The temparature is", fahrenheit, "degrees Fahrenheit.")

Example with the command line argument:

$ python convertc2f.py 100
The temparature is  212.0  degrees Fahrenheit.

Without any argument:

$ python convertc2f.py
What is the Celsius temperature? 100
The temparature is  212.0  degrees Fahrenheit.