-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconversions.py
More file actions
38 lines (30 loc) · 1.11 KB
/
conversions.py
File metadata and controls
38 lines (30 loc) · 1.11 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
# Define a function to convert weight in kilograms to pounds
def convertWeight():
try:
weight = int(input("Enter weight in kilograms:"))
pounds = weight * 2.20462
print(f"{weight}kg in pounds is", round(pounds, 1))
except ValueError:
print("Please enter a positive number.")
#define a function to convert temperature in degrees to fahrenheit
def convert_to_fahrenheit():
try:
tempt_in_deg = float(input("Temperature in degrees:"))
tempt_in_fah = (9/5*tempt_in_deg + 32)
print(f"{tempt_in_deg} degrees celsius in fahrenheit is", round(tempt_in_fah, 1))
except ValueError:
print("Please enter an integer value.")
while True:
print("Select from below what conversion you want:")
print("1. Convert from degrees to fahrenheit")
print("2. Convert from kilograms to pounds")
print("3. Exit")
choice = input("Enter Your Choice:")
if choice == "1":
convert_to_fahrenheit()
elif choice == "2":
convertWeight()
elif choice == "3":
break
else:
print("Please enter a valid choice")