1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Unit conversion using Python

Discussão em 'Python' iniciado por Stack, Abril 7, 2025.

  1. Stack

    Stack Membro Participativo

    I am going through Learn Python the Hard Way, On Ex-5 Study Drills, it states


    Try to write some variables that convert inches and pounds to centimeters and kilos. Do not just type in the measurements. Work out the math in Python.
    ​

    So far I have done this:

    inches = 1
    centimeters = 1
    convert = centimeters * 2.54
    print inches
    print centimeters
    print "1 inch is %s centimeters." % convert


    Now that will display the conversion of 1 inch, How would I be able to change it so that the user would input an amount in inches or centimeters, and it would correctly display the conversion?

    And am I right in thinking that for it to successfully convert values, I would have to enter the values in manually or is there a way to do this already made in Python?

    Continue reading...

Compartilhe esta Página