Wednesday, October 30, 2013

My laptop died

The title says it all, I had just completed one Python programming course on Coursea 93/100 and 2-3 week in to two more Python courses @ Rice Uin and Mit and bang, I get the windows 8 version of the Blue screen of death. It says it was counting to 100 and then going to restart lied it never did, so as it was still under warranty Its now in the 2 to 6 week hands of the guys from where I got it. Needless to say the back ups I had been doing hadn't yet been updated to take these courses into account. I'd also been quite ill recently along with some other major stresses so I'll just wait till things settle down and start again.

I have my desktop still running xp so I can still do some things so here completely free of charge lol is my Python code for calculating the fret positions for stringed instruments. I'm not sure if this is the very latest version but its all I've got until my laptop comes home. Enjoy.
It will work in mm or inches
Im = ''
const = 17.817 # Do not change this

def fretCal(ScaleLength, nofret):
'''(number, number)-> float
    Calculates the fret positions for any stringed instrument
    Given 'Scale length', 'number of frets' in inches or mm
    >>> fretCal(19, 18)
    Fret 1 from nut 1.066 inches
    Fret 2 from nut 2.073 inches
    >>> fretCal(635, 22)
    Fret 1 from nut 35.64 mm
    Fret 2 from nut 69.28 mm
if ScaleLength < 99:
    scale = ScaleLength
    Im = 'inches'
if ScaleLength > 100:
    scale = ScaleLength
Im = 'mm'

for i in range(1, nofret +1):
    ScaleLength = ScaleLength - (ScaleLength / const)
    print('Fret', i, 'from nut',round(scale - ScaleLength, 3),Im)

No comments:

Post a Comment