""" Exercise 4.5 from "A primer on...". Extend the program from Ex. 4.2 to handle errors caused by missing or wrong input. The exercise only asks us to handle IndexError (missing argument), but we extended it to also handle ValueError (wrong format). """ import sys try: F = sys.argv[1] F = float(F) except IndexError: print('Det mangler et kommandolinjeargument') exit() except ValueError: print('Feil format på kommandolinjeargument') exit() C = (F - 32) * 5 / 9 print(C) """ Terminal> python f2c_cml_exc.py Det mangler et kommandolinjeargument Terminal> python f2c_cml_exc.py 56f Feil format på kommandolinjeargument Terminal> f2c_cml_exc.py 56 13.333333333333334 """