Day 39: Converting Inches In Fractions To Millimetres

 

I am back – it’s been a week. It was an unplanned break since my son got a fever and than I got an unexpected job offer.

 

I own a very beautiful Gibson Les Paul guitar that I love very much. But the action – the distance between fret and string – is a bit too far off.

 

That is no problem because the Gibson website tells me exactly that the correct distance should be 3/64 inches! Ok. What?

 

First of all I am European. Inches are not unheard of and I know that one inch are 25.4 millimetres. But 3/64 inches? Come on!

 

Thank god for Python:

 

inches = "3/64"                                 # the inch value

slash_pos = inches.find("/") + 1                # look where the slash seperates the numbers

first_num = inches[0]                           # get the numerator
sec_num = inches[slash_pos:]                    # get the denominator

dec_inch = 1 / int(sec_num) * int(first_num)    # create a decimal inch value

get_mm = 25.4 * dec_inch                        # convert it to mm

print(inches + " inches are ""%.2f" % get_mm + " mm")  # round the float to to decimals


# Output: 3/64 inches are 1.19 mm

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.