Computer Science Canada

Accumulator

Author:  burmantanya [ Wed Oct 08, 2008 6:46 pm ]
Post subject:  Accumulator

Hey Everyone

I have some question about python programming.. i m new to it..willin to learn to my best abilities! Anwers/suggestions will be really appreciated!

- What is an accumulator? what is its purpose ? how does it work ?
- what is index?
- What is the difference between python shell and writer(where u write programs)?

Author:  Insectoid [ Wed Oct 08, 2008 7:09 pm ]
Post subject:  RE:Accumulator

I suppose an index would refer to an element of an array or string. For example, my_array (6) would refer to the 6th index of my_array. Syntax is wrong, I don't know much python.

a shell is like the command line. It executes as you type (pain in the arse, IMO). a writer/editor will allow you to write the code, save, run, compile, etc. I think.

Author:  SNIPERDUDE [ Wed Oct 08, 2008 8:27 pm ]
Post subject:  RE:Accumulator

That's a pretty good educated guess there insectoid. Kudos.
I'm not sure about Python either... so I can't help you there, although insectoid gave a pretty good idea of each element. And yes, shells are annoying.

Author:  gitoxa [ Wed Oct 08, 2008 10:05 pm ]
Post subject:  RE:Accumulator

An accumulator refers to a variable acting as a counter. It keep accumulating (getting larger) until a certain goal is accomplished.

An index, like insectoid said, is a concept for the element in an array. An index is like an accumulator, where the goal is to search your way through an array (in python, lists, or string variables).

Python comes with a shell that doesn't execute as you type, IDLE. Well, it does, but it allows you to write out entire structures and finish them, and allows you to edit previously entered lines.
And a writer is just simply a word processor, such as notepad.

Author:  burmantanya [ Sun Oct 12, 2008 12:00 am ]
Post subject:  RE:Accumulator

Thank you guyz
thanx a tonn!!!

Author:  wtd [ Sun Oct 12, 2008 12:44 am ]
Post subject:  RE:Accumulator

Note: interactive interpreters are awesome.

code:
>>> my_list = [1, 2, 3]
>>> accumulator = 0
>>> for x in my_list:
...     accumulator = accumulator + x
...
>>> accumulator
6
>>>


: