Re: [Tutor] exercise problem

2010-08-27 Thread Alan Gauld
"Dave Angel" wrote while teller < len(u): getal1 = u[teller] + v[teller] uitkomst = uitkomst + str(getal1) But then I get a list of string instead of integers. You're close. Now that you've initialized the result variable to [], you can use + just as you're doing. Just

Re: [Tutor] exercise problem

2010-08-27 Thread Dave Angel
Roelof Wobben wrote: Date: Fri, 27 Aug 2010 14:27:34 -0400 From: da...@ieee.org To: rwob...@hotmail.com CC: alan.ga...@btinternet.com; tutor@python.org Subject: Re: [Tutor] exercise problem The other problem is you're confusing the variables inside the function with the ones dec

Re: [Tutor] exercise problem

2010-08-27 Thread Francesco Loffredo
We are close to the solution, keep trying! On 27/08/2010 19.56, Roelof Wobben wrote: Hello, Now I have this : def add_vectors(u, v): """ >>> add_vectors([1, 0], [1, 1]) [2, 1] >>> add_vectors([1, 2], [1, 4]) [2, 6] >>> add_vectors([1, 2, 1], [1, 4, 3]) [2, 6, 4] >>> add_vectors([11, 0, -4,

Re: [Tutor] exercise problem

2010-08-27 Thread Roelof Wobben
> Date: Fri, 27 Aug 2010 14:27:34 -0400 > From: da...@ieee.org > To: rwob...@hotmail.com > CC: alan.ga...@btinternet.com; tutor@python.org > Subject: Re: [Tutor] exercise problem > > (Don't top-post, it loses all the context) > > Roelof Wobben wrote: > &g

Re: [Tutor] exercise problem

2010-08-27 Thread Dave Angel
(Don't top-post, it loses all the context) Roelof Wobben wrote: Hello, Now I have this : def add_vectors(u, v): """ >>> add_vectors([1, 0], [1, 1]) [2, 1] >>> add_vectors([1, 2], [1, 4]) [2, 6] >>> add_vectors([1, 2, 1], [1, 4, 3]) [2, 6, 4]

Re: [Tutor] exercise problem

2010-08-27 Thread Roelof Wobben
e. Roelof Date: Fri, 27 Aug 2010 10:19:30 -0700 From: alan.ga...@btinternet.com Subject: Re: [Tutor] exercise problem To: rwob...@hotmail.com >u v, result first example. u : [1.0] v: [1,1] result [2.1] OK, Great, you got that. first split u en v in only numbers. No, you shoul

Re: [Tutor] exercise problem

2010-08-27 Thread christopher . henk
Roelof Wobben wrote on 08/27/2010 12:18:01 PM: > > > > Date: Fri, 27 Aug 2010 12:00:23 -0400 > > From: bgai...@gmail.com > > To: rwob...@hotmail.com > > CC: tutor@python.org > > Subject: Re: [Tutor] exercise problem > > > > I have been reading yo

Re: [Tutor] exercise problem

2010-08-27 Thread Francesco Loffredo
On 27/08/2010 17.05, Roelof Wobben wrote: Hello, My first try : def add_vectors(u, v): """ >>> add_vectors([1, 0], [1, 1]) [2, 1] >>> add_vectors([1, 2], [1, 4]) [2, 6] >>> add_vectors([1, 2, 1], [1, 4, 3]) [2, 6, 4] >>> add_vectors([11, 0, -4, 5], [2, -4, 17, 0]) [13, -4, 13, 5] """ teller

Re: [Tutor] exercise problem

2010-08-27 Thread Roelof Wobben
> Date: Fri, 27 Aug 2010 12:00:23 -0400 > From: bgai...@gmail.com > To: rwob...@hotmail.com > CC: tutor@python.org > Subject: Re: [Tutor] exercise problem > > I have been reading your posts and responses. I find myself frustrated > with your lack of understanding of

[Tutor] exercise problem

2010-08-27 Thread Roelof Wobben
workspace\oefeningen\src\test.py", line 28, in uitkomst = add_vectors(u,v) File "C:\Users\wobben\workspace\oefeningen\src\test.py", line 17, in add_vectors getal1 = getal1 + u[teller,0] + v[teller,0]TypeError: list indices must be integers, not tuple Roelof Date: Fri, 27 Aug

Re: [Tutor] exercise problem

2010-08-27 Thread bob gailer
I have been reading your posts and responses. I find myself frustrated with your lack of understanding of Python fundamentals and the time and energy others are putting in that seems to help only a little. I recommend you take a very basic tutorial, and be sure you understand the basic concep

Re: [Tutor] exercise problem

2010-08-27 Thread Walter Prins
Hi Roelof, See below On 27 August 2010 16:05, Roelof Wobben wrote: > > uitkomst = add_vectors[u,v] > > But now I get this error message : > > > Traceback (most recent call last): > *File "C:\Users\wobben\workspace\oefeningen\src\test.py", line 27, in > * > > uitkomst = add_vectors[u,v] > > Type

Re: [Tutor] exercise problem

2010-08-27 Thread Roelof Wobben
#x27;function' object is not subscriptable So it seems that I can't use vectors as a variable in a function. Roelof From: rwob...@hotmail.com To: tutor@python.org Subject: RE: [Tutor] exercise problem Date: Fri, 27 Aug 2010 14:38:23 + Oke, That's also

Re: [Tutor] exercise problem

2010-08-27 Thread Roelof Wobben
; Date: Sat, 28 Aug 2010 00:15:15 +1000 > Subject: Re: [Tutor] exercise problem > > On Fri, 27 Aug 2010 08:23:06 pm Roelof Wobben wrote: > > > > Write a function add_vectors(u, v) that takes two lists of > > > > numbers > [...] > > My new idea is that u i

Re: [Tutor] exercise problem

2010-08-27 Thread Steven D'Aprano
On Fri, 27 Aug 2010 08:23:06 pm Roelof Wobben wrote: > > > Write a function add_vectors(u, v) that takes two lists of > > > numbers [...] > My new idea is that u is the number which must be calculated and v is > the vector which containts the outcome or u is the outcome of the > first numbers and v

Re: [Tutor] exercise problem

2010-08-27 Thread Francesco Loffredo
On 27/08/2010 12.23, Roelof Wobben wrote: From: rwob...@hotmail.com To: alan.ga...@btinternet.com Subject: RE: [Tutor] exercise problem Date: Fri, 27 Aug 2010 07:04:39 + > To: tutor@python.org > From: a

Re: [Tutor] exercise problem

2010-08-27 Thread Roelof Wobben
From: rwob...@hotmail.com To: alan.ga...@btinternet.com Subject: RE: [Tutor] exercise problem Date: Fri, 27 Aug 2010 07:04:39 + > To: tutor@python.org > From: alan.ga...@btinternet.com > Date: Thu, 26 Aug 2010 23:54:19 +0100 > Subject: Re: [Tutor] exercise problem

Re: [Tutor] exercise problem

2010-08-26 Thread Alan Gauld
"Roelof Wobben" wrote Write a function add_vectors(u, v) that takes two lists of numbers I think that u is the name of the new list and v is the number which represent the number which must be eveluated. No. It sounds like you don't really understand the basic concepts behind functions yet

Re: [Tutor] exercise problem

2010-08-26 Thread Emile van Sebille
On 8/26/2010 12:02 PM Roelof Wobben said... Hello, I have this exercise: Lists can be used to represent mathematical vectors. In this exercise and several that follow you will write functions to perform standard operations on vectors. Create a file named vectors.py and write Python code to m

[Tutor] exercise problem

2010-08-26 Thread Roelof Wobben
Hello, I have this exercise: Lists can be used to represent mathematical vectors. In this exercise and several that follow you will write functions to perform standard operations on vectors. Create a file named vectors.py and write Python code to make the doctests for each function pass. W