On 8 March 2012 18:11, Sudip Bhattacharya sud...@sudipb.com wrote:
s=(1,2,3)
s=s+(4,5,6)
s
(1,2,3,4,5,6)
The tuple has changed.
I thought I read that tuples are sequences (like lists), but they are
immutable - They can't be changed once created. Could someone explain please
?
I'm just a
On 8 March 2012 18:27, Walter Prins wpr...@gmail.com wrote:
Just to add, notice that even for lists,
l = l + [7,8,9]
produces a new list, while
l += [7,8,9]
does not.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change
On 8 March 2012 18:51, Steven D'Aprano st...@pearwood.info wrote:
col speed wrote:
I was just thinking about the immutability of things and tried this
(which -at least I- find interesting:
id(1)
154579120
a = 1
id(a)
154579120
a += 2
id(a)
154579096
id(3)
154579096
a is 3
On 8 March 2012 19:18, John Jensen jensenjoh...@yahoo.com wrote:
From: Steven D'Aprano st...@pearwood.info
To: tutor@python.org
Sent: Thursday, March 8, 2012 7:51:33 AM
Subject: Re: [Tutor] Tuple - Immutable ?
col speed wrote:
I was just thinking about
On 8 March 2012 01:11, Dave Angel d...@davea.name wrote:
On 03/07/2012 12:07 AM, col speed wrote:
snip
Then we have:
a = tuple(range(10))
b = tuple(reversed(a))
any(a) in b
True
any(b) in a
True
any((a,b)) in (a,b)
False # I think I understand this now, but I must admit
On 7 March 2012 10:45, Mark Lawrence breamore...@yahoo.co.uk wrote:
On 07/03/2012 03:24, col speed wrote:
Hello again
Hope you are all well.
I'm trying to make a match 3 game, where you have a square grid and
have to put 3 matching shapes in a row.
I need a function that tells me
On 7 March 2012 11:50, Mark Lawrence breamore...@yahoo.co.uk wrote:
On 07/03/2012 04:36, col speed wrote:
On 7 March 2012 10:45, Mark Lawrencebreamore...@yahoo.co.uk wrote:
On 07/03/2012 03:24, col speed wrote:
I *think* I understand:
Where it says:
For the list and tuple types, ``x in y
I'm not sure in windows, but in Linux, press Ctrl_C
On 29 February 2012 21:33, Debashish Saha silid...@gmail.com wrote:
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
On 4 February 2012 20:29, Zafrullah Syed zafrullahme...@gmail.com wrote:
Hi,
I need urgent help:
Yes, I think you do.
Take notice of the last replies.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
your_weight = int(raw_input(Please enter your weight: ))
if your_weight 0:
print 'You're not Chris!'
elif your_weight == 170:
print 'You might be Chris! But...'
your_height = int(raw_input(Please enter your height: ))
if your_height 180:
print 'You're not Chris!
elif your_height ==
On 11 January 2012 20:11, Max S. maxskywalk...@gmail.com wrote:
I believe that line 3 raises an error. The because you contained the text
in single quotes, and then used the same character in 'you're not chris',
Python believes that you are trying to type you re not chris. You can
change the
That's exactly the point.
Very few people know about maketrans before they take the Python Challenge.
But that's the whole point of the challenge, as you go through it you will
discover new and powerful tools in the Python library that save you from
having to invent your own. (Look out for
On 17 December 2011 16:40, Dave Angel d...@davea.name wrote:
On 12/16/2011 03:29 AM, col speed wrote:
If anyone has the time, please have a look at the attached text file
and let me know any comments on how to improve it.
Thanks a lot
Col
I don't see any response for 24 hours, so I'd say
On 17 December 2011 16:49, Peter Otten __pete...@web.de wrote:
col speed wrote:
If anyone has the time, please have a look at the attached text file
and let me know any comments on how to improve it.
At first glance the code looks good. I think you can move to the next level
now
If anyone has the time, please have a look at the attached text file
and let me know any comments on how to improve it.
Thanks a lot
Col
#!usr/bin/env python
# title - baccarat2.py
import random
class Player(object):
simple Player object that
keeps tabs on bets and kitty
def
On 9 October 2011 13:17, Andreas Perstinger andreas.perstin...@gmx.netwrote:
On 2011-10-09 07:16, col speed wrote:
The part of the script that is causing the problem is as follows:
def point(num):
while True:
raw_input(Roll)
uno, dos = random.choice(dice
-- snip
if point(one+two) == win:
Here you go into the function point the first time. Inside the function
you are in an infinite while-loop where you only exit if the sum is either 7
(lose) or equal the given parameter (win). Then you compare the return
value. In the case of lose
Hi again, Once more I've come up with a problem I can't explain. It must be
something simple, but I can't work it out.
The part of the script that is causing the problem is as follows:
def point(num):
while True:
raw_input(Roll)
uno, dos = random.choice(dice),
On 5 July 2011 07:15, eire1...@gmail.com wrote:
I second this.
I have a second harddrive with Mint on it. Ithought it might be fun to
learn emacs. On windows I've been using eclipse for like 6 to 12 months or
however long ago I started.
I tried emacs for about two seconds and was like, uh
and?
On 21 June 2011 14:38, David Merrick merrick...@gmail.com wrote:
I need help using Class methods in another class. I have a class called
Critter and I want to create two critters in a farm Class Farm and use
Class Critter's methods
--
Dave Merrick
merrick...@gmail.com
Ph 03
On 19 June 2011 14:46, Lisi lisi.re...@gmail.com wrote:
On Sunday 19 June 2011 08:39:43 Alan Gauld wrote:
Lisi lisi.re...@gmail.com wrote
It does indeed. Thank you, both of you. I have clearly not got the
terms
command, method, function (and feature?) clearly sorted out in my
2011/6/19 Válas Péter suli...@postafiok.hu
Each time I send a message to this list, I get an autoreply like this. No,
I won't add myself to any stupid guestlists to use a public list. Could a
list moderator please show this user the exit?
-- Továbbított levél --
Feladó:
I think this is easily seen by a for loop:
for something in range(20):
print something
In the above something is a variable, in this case an int(which is
immutable). However, something is changed every time it goes through the
loop.
It's the equivalent of:
x = 0
x = 1
x = 2
and so on
Just
On 27 May 2011 17:31, Walter Prins wpr...@gmail.com wrote:
I find this thread very interesting.
I've been learning Python on and off for the past 3 years, as a hobby.
I am over 50 years old, so will never be a programmer. However:
1/ I've done a bit in Project Euler and have found many
I am a newbie too, but
from collections import defaultdict
Then you can do:
data = defaultdict(int)
Everything (all keys) start at 0, so you can do += with no problem.
I'm sure somebody else has a better solution though!
Cheers
Colin
On 25 March 2011 18:52, Robert Sjoblom
On 8 February 2011 16:20, tee chwee liong tc...@hotmail.com wrote:
hi all,
i have a function which returns a string. for eg: X='101110'. i want to
search for 0 and highlight the location.
i am thinking of defining X as a list. but how can i split 101110 as there
are no spaces in between?
You can always change the precision in decimal. Just an idea
On 31 January 2011 22:23, Richard D. Moores rdmoo...@gmail.com wrote:
Which is accurate to only 16 digits; my Windows Vista calculator gives
2.9231329473018093516404474158812 for 23.45**.34
And using mpmath with Python 2.6
You're missing a . that if your computer is the same as mine, looks like
something left behind by a mosquito
On 1 February 2011 18:33, Karim karim.liat...@free.fr wrote:
Hello,
He is {what}.format(what={wild})
'He is {wild}'
Regards
Karim
On 02/01/2011 09:44 AM, Becky Mcquilling
On 12 December 2010 07:10, Al Stern albst...@gmail.com wrote:
This was another execise in my book. Following is my code for a program
that uses dictionaries to find and edit pairs of fathers and sons. The
program works right up to the final step which is to find out if any given
father is
-- snip
However, even with countWords2, which is supposed to overcome this
problem, it feels as if I've entered an infinite loop.
Josep M.
Just my twopenneth, I'm a noob and I'm not going to try such a big file on
my old machine, but:
1. Maybe create a *set* from the wordlist, loop through
--
Message: 2
Date: Tue, 09 Nov 2010 12:35:26 +0100
From: Stefan Behnel stefan...@behnel.de
To: tutor@python.org
Subject: Re: [Tutor] List comprehension question
Message-ID: ibbblu$58...@dough.gmane.org
Content-Type: text/plain; charset=UTF-8; format=flowed
Message: 7
Date: Fri, 22 Oct 2010 21:48:29 -0700
From: Richard D. Moores rdmoo...@gmail.com
To: Steven D'Aprano st...@pearwood.info
Cc: tutor@python.org
Subject: Re: [Tutor] What does TypeError: 'int' object is not
iterable mean?
Message-ID:
Message: 6
Date: Tue, 28 Sep 2010 13:15:26 +0700
From: col speed ajarnco...@gmail.com
To: tutor@python.org
Subject: [Tutor] Pythonic nested lists
Message-ID:
aanlktimdykbkzxaacbaagpq_faz50ruy=bcr81dqx...@mail.gmail.com
Content-Type: text/plain; charset=iso-8859-1
Hi all,
I've been trying
Hi all,
I've been trying to write a programme that solves sudoku problems for a
while now. I'm getting close, but would like to ask a few questions about
the most pythonic way of doing some things.
I've decided to create nested lists (row order, column order and square
order) which correspond with
I apologise in advance for such a silly question. Normally, I start to write
to the list and work the answer out before sending the mail. Not this time.
I'm trying to work out which triangles contain the cartesian origin (0, 0)
and have the following:
t = [-340, 495, -153, -910, 835, -947]
print
On 7 July 2010 18:59, Evert Rol evert@gmail.com wrote:
The second number should be negative ( I WANT it to be negative). For
example:
print (0 - t[4])*(t[3] - t[5]) , (0 - t[5])*(t[2] - t[4]) gives :
-30895 -935636
And in the python shell:
-30895 -935636
-966531
No,
HI Guys,
I have a small programme, called shop.py, that I wish to make into a
frozen binary ( I think that's right - I'm using Linux Ubuntu 9.04
and I want the programme to work on a windows computer that doesn't
have Python installed).
I used freeze.py from examples/Tools and everything seemed
, mult
To: tutor@python.org
Message-ID: glp50q$3t...@ger.gmane.org
Content-Type: text/plain; format=flowed; charset=iso-8859-1;
reply-type=original
col speed ajarnco...@gmail.com wrote
I got the following function while googling:
def totient(n):
from operator import mult
if n == 1
again
Colin
2009/1/29 John Fouhy j...@fouhy.net
2009/1/29 col speed ajarnco...@gmail.com:
[...]
What I expected mult to do was (somehow)to work out what the powers
of
the prime factors would be. Another reason I didn't think it was mul is
the part that says prime_factors_mult(n
Hello there,
I got the following function while googling:
def totient(n):
calculate Euler's totient function.
If [[p_0,m_0], [p_1,m_1], ... ] is a prime factorization of 'n',
then the totient function phi(n) is given by:
(p_0 - 1)*p_0**(m_0-1) * (p_1 - 1)*p_1**(m_1-1) * ...
That's what I thought , but I tried it to no avail. Plus the syntax is
wrong.
Thanks anyway
Colin
2009/1/28 John Fouhy j...@fouhy.net
2009/1/28 col speed ajarnco...@gmail.com:
Hello there,
I got the following function while googling:
def totient(n):
calculate Euler's totient
Wow! I seem to have caused a great deal of comments!
I actually am looking to see if a number is a perfect cube. I will try out
all the suggestions.
Thanks a lot.
Colin
P.S.
I have a small programme that changes decimal to binary (I don't know if it
can be changed to work with fractions or not),
Hi there, just a quick one.
Is there a way to obtain cube roots in python?
I have been trying:
math.pow(n,1.0/3)
This works with some, but with 64, for example I get:
pow(64,1.0/3)
3.9996
However:
4**3
64
Any ideas?
Thanks
Colin
___
Tutor
Hello there, I am learning python as a hobby in my spare time. I enjoy doing
project euler, not that I am any good at maths, but it gives me problems
to solve in python!
Please Note: I do not expect (or want) you to give me the solution, if you
could just point me in the right direction - that
:
On Tue, Dec 23, 2008 at 8:20 PM, col speed ajarnco...@gmail.com wrote:
I've written a division function that gives more decimal places than
the
one already in python. What my poor old brain can't work out is how to
find
a recurring cycle which isn't disastrously complicated (as the cycle
45 matches
Mail list logo