Advertisement
MGakowski

Imperial and Metric Spanner/Socket Converter

Apr 7th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. from fractions import Fraction
  2.  
  3. while True:
  4.     select = str(raw_input("To convert to metirc type 'm', or imperial type 'i':  "))
  5.  
  6.     if select == str("m"):
  7.         mm = float(25.4)
  8.         numer = int(raw_input("Top number(numerator)? "))
  9.         denom = int(raw_input("Bottom number(denominator)? "))
  10.         answer = float(mm/denom*numer)
  11.         print str(answer)+"mm"
  12.         numer = int(0)
  13.         denom = int(0)
  14.         answer = int(0)
  15.  
  16.     if select == str("i"):
  17.         sixteenth = float(1.587)
  18.         mm = float(raw_input("Millimeters(mm)? "))
  19.         answer = float(mm/sixteenth)
  20.         decimal = float(round(answer))/16
  21.         print str(Fraction(decimal))
  22.         decimal = int(0)
  23.         mm = int(0)
  24.         answer = float(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement