[Tutor] SUBJECTIVE

avi.e.gross at gmail.com avi.e.gross at gmail.com
Sun Aug 14 21:52:27 EDT 2022


Mats and Dave are more kind about such naïve requests so I will try to match
them as far as I can, which may not be far enough.

The following is a start at something I call a Fib Bonacci sequence.

Take a list and embed in it additional lists where each sublist contains as
many items as needed to satisfy the relationship of each new sublist having
as many members as the sum of the previous two.

So, to get started, the first list in the sequence starts with an empty list
followed by one containing a single item, such as '1':

[ [], [1] ]

Now the next item needs 0 items plus one item which happens to be [1] so he
first three are:


[ [], [1], [1] ]

The next adds having one item to having one item and I will populate it with
two twice:

[ [], [1], [1], [2,2] ]

The next item added ha to have two plus 1 items so I will populate it with
three thrice:

[ [], [1], [1], [2,2], [3,3,3] ]

Keep repeating this pattern to get:

[ [], [1], [1], [2,2], [3,3,3], [5,5,5,5,5], [8,8,8,8,8,8,8,8],
[13,13,13,13,13,13,13,13,13,13,13,13,13], ... ]

At some point you will get extremely bored, or your machine will run out of
memory and consider what is the point.

And why do need LISTS. Who ordered that?

So you go back to your teacher and find out nobody asked for a list. They
want you to produce a SEQUENCE using a computer program and it matters not
at all if you produce them in a tuple or list or set or any other data
structure other than producing them one at a time on demand.

Can you write an algorithm that prints out 0, then 1, then 1, then 2, then
3, then 5 and so on and eventually stops? That should be fine. But were you
given instructions on what you are allowed to use and what you are NOT
allowed to use? Can the solution be iterative or must it be recursive? As
stated earlier, what decides when your algorithm stops as the series is
endless? 

For the future, I suggest you begin replies and new threads with a SUBJECT
line so we have some idea of the topic. We tend to take such messages more
seriously. And as has been mentioned, you need to show you did some work and
are stuck somewhere. Otherwise, if you want free HW, or are just interested
in seeing an algorithm in some language, a brief web search should provide
plenty of INFO. The volunteers here may want to HELP but only in some ways.
Show that you already did your own work and research, please.

-----Original Message-----
From: Tutor <tutor-bounces+avi.e.gross=gmail.com at python.org> On Behalf Of
Mats Wichmann
Sent: Sunday, August 14, 2022 7:05 PM
To: tutor at python.org
Subject: Re: [Tutor] (no subject)

On 8/14/22 16:37, dn wrote:
> On 15/08/2022 04.48, Phindile Julia wrote:
>> Hey how to create a Fibonacci list?
> 
> 
> Hi Phindile,
> Is this your first post to the list? Welcome!
> 
> We volunteer help to learners (and Tutors) who are getting to grips 
> with Python. We will help *you* to learn Python and how best to use 
> it, but won't give 'homework' answers (wouldn't that be the 
> exact-opposite of 'you learning'?)
> 
> As it happens, I am currently drafting a coding-challenge, which will 
> feature a Fibonacci 'engine' to generate data. So, will be happy to 
> take a look at your code so-far and offer a critique.

The Fibonacci sequence is fascinating in its own right, but the topic is
often used to teach recursion to programming students where is it often hard
to explain "why would I want to do that?" - Fibonacci provides one of the
clearer ways to describe it.

It can also be used to illustrate some pretty advanced Python and computer
science topics - mainly because the more numbers you try to generate with
the "most obvious" implementation the slower it gets - and it gets slow
quite rapidly, so this is also a fruitful field for optimization strategies.
I mention this because while we here try to be as helpful as possible, we
sometimes get a bit carried away discussing nuances - so take what you need
from answers based on where you are in your learning path, and feel free to
tune us out in case the discussion ends up going on!!
_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list