Scott J FrankAbout MeBlogMusicArtworkPhotosLinksResume

church

church

church

Convert Kg and Lb to Stone (Python)

I needed to wake my brain up this morning, so I wrote a quick conversion script in Python to convert pounds or kilograms into stone over coffee. (Really, I’m just procrastinating my errands. Humor me.)

 

#!/usr/bin/python
condition = 1
while condition == 1:
  weight_type = raw_input(“Do you prefer [i]mperial or [m]etric? “)
  if weight_type == ‘m’:
    weight_kg = int(input(“Provide your weight in kilograms: “))
    weight_stone = weight_kg * 2.2 / 14
    print “You weigh” , weight_stone , “stone.”
    condition = 0
  elif weight_type == ‘i’:
    weight_lb = int(input(“Provide your weight in pounds: “))
    weight_stone = weight_lb * .071429
    print “You weigh” , weight_stone , “stone.”
    condition = 0
  else:
    print(“Please choose i for imperial or m for metric.”)
    condition = 1