How to convert from Fahrenheit to Celsius in python | 5 simple projects of python | alltechinfo|

1. How to convert from Fahrenheit to Celsius.



Code :-

x = int(input("Insert a Fehrenheit value: "))
x = round((x-32)*(5/9))
print(str(x)+'C')



Output :-



2. How to create a simple Thermometer


Code :-

x = input("Insert any value of 'C' or 'F' : ")

unit = x[-1]
x = int(x[0:-1])

if unit == 'C' or unit == 'c':
    x = round(x*(9/5)+32)
    print(str(x) + 'F')
elif unit == 'F' or unit == 'f':
    x = round((x-32)*(5/9))
    print(str(x) + 'C')

Output :-




3. How to calculate Mass, Density and Volume.


Code:-

mdv = input("Choose one to calculate(m,d,v) : ")

if mdv == 'm':
    d = float(input("Density: "))
    v = float(input("Volume: "))
    result = d*v #This is for mass
elif mdv == 'd':
    m = float(input("Mass: "))
    v = float(input("Volumn: "))
    result = m/v #This is for density
elif mdv == 'v':
    m = float(input("Mass: "))
    d = float(input("Density: "))
    result = m/d;
print("%.2f" % result)

Output :-




4. How to determine the quadrant of a point


Code :-

x = float(input("Insert coordinate of point x: "))
y = float(input("Insert coordinate of point y: "))

if x > 0 and y > 0:
    print("The first quadrant")
elif x < 0 and y >0:
    print("The second quadrant")
elif x < 0 and y  < 0:
    print("The third quadrant")
elif x < 0 and y < 0:
    print("The forth quadrant")
elif x == 0 and y == 0:
    print("Point of origin")
elif x == 0:
    print("x point")
elif y == 0:
    print("y point")

Output :-






Post a Comment

0 Comments