Python Forum
Help with define a def function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with define a def function
#1
Hi,
I have this code:
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]

i = 0

freq=int(input("Enter a fundamental frequency: "))
print(f"the fundumental frequency is: {freq}")

while i < len(ratio):

    nfreq=freq*(ratio[i])
    print(f"{ordinal[i]} note is: " + str(round(nfreq,3)))
    i += 1
for hours now I try to convert the above code to a def function so I can use it with gui interface(or call it when ever I need it)
I just can't get it.
can someone help me with convert the above? I cant figure what I'm missing.

Thanks
Reply


Messages In This Thread
Help with define a def function - by Omer_ - Sep-20-2020, 06:25 PM
RE: Help with define a def function - by ndc85430 - Sep-20-2020, 06:29 PM
RE: Help with define a def function - by deanhystad - Sep-20-2020, 06:48 PM
RE: Help with define a def function - by Omer_ - Sep-20-2020, 06:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Struggling for the past hour to define function and call it back godlyredwall 2 2,158 Oct-29-2020, 02:45 PM
Last Post: deanhystad
  How to define a function to create a resorted list? sparkt 6 2,739 Aug-08-2020, 04:10 PM
Last Post: sparkt
  Cant define turtle color with function argument Wrightys99 2 2,196 Apr-22-2020, 01:43 PM
Last Post: Wrightys99
  How to define a function that calculates the BMI from dataframe DavidGG 2 5,769 May-30-2019, 03:35 PM
Last Post: volcano63
  How to define two functions run simultaneously within a function? Alberto 4 3,969 Feb-06-2018, 10:08 PM
Last Post: Alberto

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020