Python KG to POUNDS and Vice Versa

By | April 15, 2022

Python Program to convert kilo grams into pounds and vice versa.

Formula to convert kg to pounds and vice versa

Formula to convert kg to pounds and vice versa

To convert pounds into kilograms, divide the number of pounds you have by 2.2046.

Program statements kg to pounds and vice versa

Python program kg to pounds and vice versa

'''
Python Program to convert kg to pounds and vice versa

'''

'''
Python Program to convert kg to pounds and vice versa

'''

print("**** Program Menu ****")
print("1. Convert KG to Pounds")
print("2. Convert Pounds to Kg")
print("Enter your choice:")
choice = int(input())
if choice == 1:
   kg=float(input("Enter Kg:"))
   pounds = kg * 2.2046
   print(kg,' Kg ', 'are equal to ',pounds,' Pounds')
elif choice==2:
   pounds=float(input("Enter Pounds:"))
   kg = pounds / 2.2046
   print(pounds,' Pounds ', 'are equal to ',kg,' Kg')
else:
   print('Wrong Choice')

How this Python Program works?

First of all we use print() to display a menu for the user. This menu consists of two choices as follows:

**** Program Menu ****
1. Convert KG to Pounds
2. Convert Pounds to Kg

After this menu the user will enter her choice. Then we will use an if-elif statement to select the proper block of statements for execution on the basis of user’s choice.
After the input by the user that is in kg or pounds, the result is shown on the screen properly after conversion. Moreover, if the use will enter a number other than one or two then this program will show a message “Wrong Choice”.  We have used print(), input(), if-elif and float() functions in this Python program to get the required results.

 

 730 total views,  3 views today

Leave a Reply

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