Python Forum
Made my First function.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Made my First function.
#1
def my_fibonacci():
	p = 0
	c = 1
	result = (p + c)
	print(result,"",end = "")
	while result < 5000:
		p = c
		c = result
		result = p + c
		print(result,"",end = "")
	


my_fibonacci()
Hello everybody,
Made my first function today. Had a look at other functions on this subject and got lost with the code, it looked so complex.... so i thought to myself, there has to be a simple way of doing this.
So out came the pen & paper. I wrote the Fibonacci formula down and ask myself , now how do i put this into python code...?
I believe it took me about an hour or so to come up with the function above. hope it display correctly.

Am pleased with myself... What would you do differently, but at the same time keeping it as simple as possible.
At this time , I do not care if it runs slow or fast. As long as I can understand the code.

Rdgs.
Gribouillis write Aug-28-2022, 10:38 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
Made my First function. - by PythonBorg - Aug-28-2022, 10:33 AM
RE: Made my First function. - by Gribouillis - Aug-28-2022, 10:47 AM
RE: Made my First function. - by rob101 - Aug-28-2022, 10:50 AM
RE: Made my First function. - by deanhystad - Aug-28-2022, 10:19 PM
RE: Made my First function. - by ndc85430 - Aug-29-2022, 05:55 AM
RE: Made my First function. - by PythonBorg - Sep-03-2022, 08:44 AM
RE: Made my First function. - by deanhystad - Sep-03-2022, 12:43 PM
RE: Made my First function. - by buran - Sep-20-2022, 09:48 AM

Forum Jump:

User Panel Messages

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