# Celsius.py (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-04-18 File created. # 2022-12-16 Converted to Python 3. # The following data structure is a so-called tuple in Python. # Note that when the tuple values are listed inside parentheses ( ) # it is not necessary to use the backslash to continue the # statement on the following line. # A tuple is an immutable sequence of data items. You cannot add # new items to a tuple once it has been created. Otherwise, a tuple # behaves in the same way as a list. # Note that this program works only on Celsius scale 0 ... 39. array_of_degrees_fahrenheit = \ ( 32, 34, 36, 37, 39, 41, 43, 45, 46, 48, 50, 52, 54, 55, 57, 59, 61, 63, 64, 66, 68, 70, 72, 73, 75, 77, 79, 81, 82, 84, 86, 88, 90, 91, 93, 95, 97, 99, 100, 102 ) print( "\n This program converts temperatures given in" \ "\n degrees Celsius to degrees Fahrenheit." \ "\n Please, give a temperature in degrees Celsius: ", end=" " ) degrees_celsius = int( input() ) print( "\n %d degrees Celsius is %d degrees Fahrenheit. " % \ ( degrees_celsius, array_of_degrees_fahrenheit[ degrees_celsius ] ) )