In: Computer Science
PYTHON: Write a script that imports the functions in the module below and uses all of the functions.
import math
def _main():
print("#" * 28, "\n", "Testing...1, 2, 3...testing!\n", "#" * 28, "\n", sep="")
f = -200
print("{:.2f} F is {:.2f} C".format(f, f2c(f)))
f = 125
print("{:.2f} F is {:.2f} C".format(f, f2c(f)))
c = 0
print("{:.2f} C is {:.2f} F".format(c, c2f(c)))
c = -200
print("{:.2f} C is {:.2f} F".format(c, c2f(c)))
def f2c(temp):
#Converts Fahrenheit tempature to Celcius
if temp < -459.67:
return False
c = (temp - 32) * (5 / 9)
return c
def c2f(temp):
#Converts Celcius to Fahrenheit
if temp < -273.15:
return False
f = (temp * 9 / 5) + 32
return f
if __name__ == '__main__':
_main()
Python code pasted below.
import math
def _main():
print("#" * 28, "\n", "Testing...1, 2, 3...testing!\n", "#" * 28,
"\n", sep="")
f = -200
print("{:.2f} F is {:.2f} C".format(f, f2c(f)))
f = 125
print("{:.2f} F is {:.2f} C".format(f, f2c(f)))
c = 0
print("{:.2f} C is {:.2f} F".format(c, c2f(c)))
c = -200
print("{:.2f} C is {:.2f} F".format(c, c2f(c)))
def f2c(temp):
#Converts Fahrenheit tempature to Celcius
if temp < -459.67:
return False
c = (temp - 32) * (5 / 9)
return c
def c2f(temp):
#Converts Celcius to Fahrenheit
if temp < -273.15:
return False
f = (temp * 9 / 5) + 32
return f
if __name__ == '__main__':
_main()
Python code in IDLE pasted below for better understanding of the indent.
Output Screen