Please enable / Bitte aktiviere JavaScript!
Veuillez activer / Por favor activa el Javascript![ ? ]
How to make a program that converts pounds to kilograms and grams in python? - bug-code.com Q&A

How to make a program that converts pounds to kilograms and grams in python?

0 like 0 dislike
42 views
How to make a program that converts pounds to kilograms and grams in python?
asked by (4.3k points) | 42 views

2 Answers

0 like 0 dislike

To make such a program, you need a code which would prompt the number of pounds and convert it accordingly to kilograms and grams. Try something like this:

def poundsToMetric(pounds):

    kilograms = pounds / 2.2

    grams = kilograms * 1000

    return int(kilograms), grams % 1000

 

pounds = float(input("How many Pounds? "))

kg, g = poundsToMetric(pounds)

print('The amount of pounds you entered is {}. '\

      'This is {} kilograms and {} grams.'.format(pounds, kg, g))

answered by (8.5k points)
0 like 0 dislike
# We consider weight
     elif convertation == 2:
         massa = int (input ('1. Kilograms -> pounds \ n 2. Grams -> ounces \ n'))
         if massa == 1:
             value_massa = float (input ('How many kilograms?: \ n'))
             print (value_massa, 'kilogram make up', round ((value_massa * 2.20462), 2), 'pounds')
         elif massa == 2:
             value_massa = float (input ('How many grams?: \ n'))
             print (value_massa, 'grams make up', round ((value_massa * 0.035274), 2), 'ounces')
answered by (2.9k points)
Welcome to Bug-code Q&A, where you can ask questions and receive answers from other members of the community.

24.8k questions

46.2k answers

0 comments

12.7k users

24,788 questions
46,220 answers
0 comments
12,685 users