Sep-20-2020, 06:48 PM
My first impulse is this:
def weird_function(): ordinal = ['2nd','3rd','4th','5th','6th','7th','8th','9th','10th','11th','12th'] ratio = [1.222223, 1.25, 1.33,4.3,1.23,2.323] freq=int(input("Enter a fundamental frequency: ")) print(f"the fundumental frequency is: {freq}") for r, ord in zip(ratio, ordinal): print(f"{ord} note is: " + str(round(freq*r,3))) weird_function()But as the name implies, I think this is a weird function. It is unusual for a function to contain "input" and "print" commands. Maybe this makes perfect sense in this case, but you mentioned using this in a gui interface and "input" and "print" don't work for those. I would be inclined to write this as a function that takes a frequency and returns a list of notes.
def weird_function(note): ratios = [1.0, 1.222223, 1.25, 1.33,4.3,1.23,2.323] return [note * ratio for ratio in ratios] freq = int(input("Enter a fundamental frequency: ")) print(*weird_function(freq))