[Tutor] hello

Liam Clarke cyresse at gmail.com
Thu Jul 21 01:58:31 CEST 2005

On this tutor list, we're not able to provide solutions to assignments or 
homework, but I'll help as I can. I'm also forwarding this to the list, as 
other people can probably help better than I.

The problem you've been given is simple, (well, the Python bit is), but they 
haven't explained it very well. 

Check out this - http://www.freenetpages.co.uk/hp/alan.gauld/

It's a tutorial written by Alan Gauld, who answers emails on this list, look 
under - 
"The Raw Materials" and read about collections, as this is what your problem 
involves ( I assume you are ok with HTML.... :/)

So, in your assignment, each cheque's details will look like this - 

>>> cheque = [ 1, 12.00, "foo" ]

The [ ] bits mean that cheque is a list containing 1, 12.00 and "foo" as 

(You might want to play around with the Python interpreter.)

Ok... that part is reasonably straight forward. Now, you can access each 
item in a list by using it's index. 

Remember that computers start counting at 0... ask a computer to count to 
ten and it will count 0,1,2,3,4,5,6,7,8,9 ....so, the 1st item of a list is 
actually item zero.

Ok. So, to access the first item of cheque, you would do something like this 
at the Python prompt - 

>>> print cheque[0] 
>>>print cheque[1]
>>>print cheque[2]

Does that make sense?

You can also have a list of lists. 

>>> manyCheques = [ [ 1, 12.00, "foo"], [2, 13.88, "bar"] ]

Now, if you print the first item of manyCheques like so 

>>>print manyCheques[0]
[1, 12.00, "foo"]

So, the first item of manyCheques is a list too, (the square brackets.)

So how to access the third item of the second list?

>>> print manyCheques[1][2] (remember, computers start at 0)

It's just a shorthand way of saying "print the 3rd item of the 2nd item of 


You'll also need to learn a wee bit about looping, so I really do suggest 
starting with Alan's tutorial.

Good luck, 

On 7/21/05, dina lenning <dlenning at shaw.ca> wrote:
> YES...heres my problem
> I am a university student..will be a teacher in 2 years hopefully..and
> have taken a first year computing course that said it required NO PRIOR
> knowledge, but i am having great difficulty. The students (71 of them)
> are all complaining, including myself , as we all find it too hard.
> Anyway..i am having a heck of a time, but can not fail becasue i am on
> student loans. I am looking for help for this assignment:
> http://www.cs.sfu.ca/CC/165/popowich/assign-1/assign4
> also, do you think this is easy and should it be in a first year, no
> prior knowledge course??
> Even if you can guide me to some resources that may help me work this
> out that would be great. Thank you.
> You could even just send the assignment code if you want :)
> thanks dina
> On 20-Jul-05, at 4:04 PM, Liam Clarke wrote:
> > Most likely. Are they questions regarding Python?
> >
> > On 7/21/05, dina lenning <dlenning at shaw.ca> wrote:
> >>
> >> _______________________________________________
> >> Tutor maillist-Tutor at python.org
> >> http://mail.python.org/mailman/listinfo/tutor
> >
> >
> >
> > --
> > 'There is only one basic human right, and that is to do as you damn
> > well please.
> > And with it comes the only basic human duty, to take the consequences.'

'There is only one basic human right, and that is to do as you damn well 
And with it comes the only basic human duty, to take the consequences.'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050721/020282b3/attachment-0001.htm

More information about the Tutor mailing list