Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help solve this python project. You will create a Python function, ctemp_

ID: 3661608 • Letter: P

Question

Please help solve this python project.

You will create a Python function, ctemp_to_ftemp, to compute a Celsius temperature to the corresponding Fahrenheit temperature. ctemp_to_ftemp will have one parameter, ctemp, a temperature in degrees Celsius. ctemp_to_ftempshould return the fahrenheit temperature, eg

[>>> ctemp_to_ftemp(100)

212.0]

The first step for this function is to follow the program design template presented in class to create a stub function, e.g.,ctemp_to_ftemp_stub. The stub function should have

header, including parameters

docstring, with

type contract

succinct description with references to parameters and returned value

simple examples of function calls

pass statement

return statement (with comment for returned value)

When ctemp_to_ftemp_stub is "working", make a copy and name the copyctemp_to_ftemp. Replace the pass statement with the code needed to compute the fahrenheit temperature as specified above. ctemp_to_ftemp should print correct values for the simple examples you included in your stub function, and also for the test cases given here.

[>>> ctemp_to_ftemp(30)

86.0

>>> ctemp_to_ftemp(21.1)

69.98]

Explanation / Answer

This is the program for converting celsius into faharenheit and vice versa:

def display_options()

print("Options:")

print(" 'print' to print options")

print(" 'c' convert from Celsius")

print(" 'f' convert from Fahrenheit"

print(" 'e' end the program")

def ctemp_to_ftemp_stub(c_temp)

return 9.0 / 5.0 * c_temp + 32

def ftemp_to_ctemp_stub(f_temp)

return (f_temp - 32.0) * 5.0 / 9

choice = "print"

while choice != "e"

if choice == "c":

c_temp = float(input("Celsius temperature: "))

        print("Fahrenheit:", ctemp_to_ftemp_stub(c_temp)

        choice = input("option: ")

    elif choice == "f":

        f_temp = float(input("Fahrenheit temperature: "))

      print("Celsius:", ftemp_to_ctemp_stub(f_temp))

        choice = input("option: ")

    elif choice == "print": # when the alternative choice != "e": so that print #when anything other than the given options is inputed

display_options()

       choice = input("option: ")

we can write the same program using classes and accesing it through objects:

class temperature:

def display_options()

print("Options:")

print(" 'print' to print options")

print(" 'c' convert from Celsius")

print(" 'f' convert from Fahrenheit"

print(" 'e' end the program")

def ctemp_to_ftemp_stub(c_temp)

return 9.0 / 5.0 * c_temp + 32

def ftemp_to_ctemp_stub(f_temp)

return (f_temp - 32.0) * 5.0 / 9

choice = "print"

while choice != "e"

if choice == "c":

c_temp = float(input("Celsius temperature: "))

        print("Fahrenheit:", ctemp_to_ftemp_stub(c_temp)

        choice = input("option: ")

    elif choice == "f":

        f_temp = float(input("Fahrenheit temperature: "))

      print("Celsius:", ftemp_to_ctemp_stub(f_temp))

        choice = input("option: ")

    elif choice == "print": # when the alternative choice != "e": so that print #when anything other than the given options is inputed

display_options()

       choice = input("option: ")

we can create an object t and call the functions

>>>>t.display_options()

>>>>t.ctemp_to_ftemp_stub(37)

>>>>t.ftemp_to_ctemp_stub(98)

output:

print(" 'print' to print options")

print(" 'c' convert from Celsius")

print(" 'f' convert from Fahrenheit"

print(" 'e' end the program")

98                                                  (converted to f scale)

37                                                    (converted to C scale

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote