-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3_ weightConvertor.py
More file actions
34 lines (24 loc) · 996 Bytes
/
Copy path3_ weightConvertor.py
File metadata and controls
34 lines (24 loc) · 996 Bytes
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
#project3:
#weightConvertor(kg to gram/pound , pound to kg/gram , gram to kg/pound)
#greetings
print("==========WELCOME TO WEIGHT CONVERTOR===========")
#functioning of convertion
def convert(weight,user):
if user == "kg":
return "In grams:" ,weight * 1000, "g. \n In pounds :",weight * 2.2462 ,"lb."
elif user == "g":
return "In kg:", weight /1000, " kg. \n In pounds :" , weight * 0.002204622,"lb."
elif user == "pounds":
return "In kg :",weight /2.20462 ,"kg. \n In grams:" , weight /0.0022046,"g."
else:
return "Sorry ! Your unit is invalid."
#input from the user
while True :
weight = float(input("Add the weight:"))
user = input("Is you given weight in 'kg'/'pounds'/'g'?: ").lower()
print(convert(weight,user))
choice = input("Enter 'yes' to stay and 'no' to exit:").lower()
if choice == "no":
break
else:
continue