-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtemperature.py
More file actions
39 lines (33 loc) Β· 1.19 KB
/
temperature.py
File metadata and controls
39 lines (33 loc) Β· 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 12 05:03:02 2019
@author: aot
"""
unit1=str(input("Enter the unit of the temperature (C/K/F)="))
temp=float(input("Enter the temperature:"))
if(unit1=="K"):
c=str(input("Enter the unit of temperature you want to convert to (C/F)="))
if (c=="C"):
result= temp-273.15
print("The temperature in Celsius is ",result)
elif (c=="F"):
result= (temp*(9/5))-459.67
print("The temperature in Fahrenheit is ",result)
elif(unit1=="C"):
c=str(input("Enter the unit of temperature you want to convert to (K/F)="))
if (c=="K"):
result= temp+273.15
print("The temperature in Celsius is ",result)
elif (c=="F"):
result= (temp*(9/5))+32
print("The temperature in Fahrenheit is ",result)
elif(unit1=="F"):
c=str(input("Enter the unit of temperature you want to convert to (K/C)="))
if (c=="K"):
result= ((temp-32)*(5/9))+273.15
print("The temperature in Kelvin is ",result)
elif (c=="C"):
result= (temp-32)*(5/9)
print("The temperature in Celsius is ",result)
else:
print("Invalid entry, please try again !")