Python Practice – Ask weight in pound and convert it to kg

python-convert-pound-kg
In this python practice, we will ask user to input weight in pound and convert the weight in kg.

1
2
3
weight_pound = input("what is your weight in pound? ")
weight_kg = int(weight_pound) * 0.45
print("Your weight in KG is " + str(weight_kg))

Code Explanation

On line 1:
we ask user to input weight in pound.

1
weight_pound = input("what is your weight in pound? ")

On line 2:
Input function always return string type value. So, we have converted weight_pound to integer type and multiplied it by 0.45. The result is saved as weight_kg

1
weight_kg = int(weight_pound) * 0.45

On line 3:
We print the value of weight_kg

1
print("Your weight in KG is " + str(weight_kg))

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *