On 1/30/2011 4:29 AM, Becky Mcquilling wrote:
I'm fairly new to python and I am trying to do some math with tuples.
If I have a tuple:
t =( (1000, 2000), (2, 4), (25, 2))
I want to loop through and print out the results of the multiplying
the two numbers like so:
1000 x 2000
2 x 4
The one-
"Becky Mcquilling" wrote
I'm fairly new to python and I am trying to do some math with
tuples.
If I have a tuple:
t =( (1000, 2000), (2, 4), (25, 2))
Thats a tuple of tuples. The pairs of numbers each make up a tuple.
And the triple of pairs makes up another tuple.
I want to loop through
Thanks Karim.
That's a way to go.
Cheers.
Sent from my BlackBerry wireless device from MTN
-Original Message-
From: Karim
Sender: tutor-bounces+delegbede=dudupay@python.org
Date: Sun, 30 Jan 2011 10:50:31
To: Becky Mcquilling; python mail list
Subject: Re: [Tutor] Pytho
Nice Steve,
No one does it better.
Weldone.
Sent from my BlackBerry wireless device from MTN
-Original Message-
From: Steven D'Aprano
Sender: tutor-bounces+delegbede=dudupay@python.org
Date: Sun, 30 Jan 2011 20:47:08
To:
Subject: Re: [Tutor] Python and Tuples
Becky Mcqui
Hello,
for x, y in t:
print x*y
Regards
Karim
On 01/30/2011 10:29 AM, Becky Mcquilling wrote:
I'm fairly new to python and I am trying to do some math with tuples.
If I have a tuple:
t =( (1000, 2000), (2, 4), (25, 2))
I want to loop through and print out the results of the multiplying
Becky Mcquilling wrote:
I'm fairly new to python and I am trying to do some math with tuples.
If I have a tuple:
t =( (1000, 2000), (2, 4), (25, 2))
I want to loop through and print out the results of the multiplying the two
Start with a basic loop through the objects in the tuple:
>>> t = (
I'm fairly new to python and I am trying to do some math with tuples.
If I have a tuple:
t =( (1000, 2000), (2, 4), (25, 2))
I want to loop through and print out the results of the multiplying the two
numbers like so:
1000 x 2000
2 x 4
etc.
I'm not sure of the syntax for that. Any ideas?
Bec