Write a python program to enter a temperature in Celsius (C) and convert it into Fahrenheit (F) using function.

Tech Programmer
0

 WRITE A PYTHON PROGRAM TO ENTER A TEMPERATURE IN (C) CONVERT (C) INTO (F) USING FUNCTIONS.


CODE FOR THE ABOVE  PYTHON  PROGRAM :



# write a py pro to enter a temperature in C and convert it into F by using functions.
def convert_temp(scaletemp):
    if scale == "C":
        return'F', (temp*(9/5)+32)
    elif scale == "F":
        return'C', (temp-32)*(5/9)
    else:
        print("its not in F or C")

#drivencode
scale = input("select (F) or (C) : ")
temp = int(input("enter the temperature:"))
st = convert_temp(scaletemp)
print(temp,"degrees",scale,"is",t,"degrees",s)


WRITTEN CODE FOR THE ABOVE PROGRAM :


# write a py pro to enter a temperature in C and convert it into F by using functions.

def convert_temp(scale, temp):

    if scale == "C":

        return'F', (temp*(9/5)+32)

    elif scale == "F":

        return'C', (temp-32)*(5/9)

    else:

        print("its not in F or C")

 

#drivencode

scale = input("select (F) or (C) : ")

temp = int(input("enter the temperature:"))

s, t = convert_temp(scale, temp)

print(temp,"degrees",scale,"is",t,"degrees",s)


OUTPUT :





Post a Comment

0Comments
Post a Comment (0)

Featured Highlighted Categories

You'll discover all of the most up-to-date bring innovative here.

Python List theory with List Programs
Get complete python lists theory and list basic and insane programs for your practice.
CBSE SAMPLE PAPERS
Get CBSE sample and question papers of last 7 years with answers to get best practice for your Board Exams
Python String theory and String Programs
Python strings complete theory with illustrations and practice programs for free