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 values.

(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]
1
>>>print cheque[1]
12.00
>>>print cheque[2]
foo

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)
bar

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

Um...

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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> wrote:
>>
>> _______________________________________________
>> Tutor [EMAIL PROTECTED]
>>  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 please.
And with it comes the only basic human duty, to take the consequences.'
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to