Tiger12506 wrote:
>> Nope, if you read the code you'll see the only mapping done is up to 20
>> and then by tens up to 100, that's all.
>> The same code could be used with a list, you'd only have to change the
>> exception name.
>
> I see. There were "..." in between each of the tens entries which
> Nope, if you read the code you'll see the only mapping done is up to 20
> and then by tens up to 100, that's all.
> The same code could be used with a list, you'd only have to change the
> exception name.
I see. There were "..." in between each of the tens entries which I took to
mean that "big
Tiger12506 wrote:
>> Isn't dictionary access faster than list access? Why are three lists
>> 'much more efficient'?
>
> Oh no, no, no. Dictionaries are faster when you are *searching through* for
> a particular value. If you already know the index of the item in the list,
> lists are much faste
Danny Yoo wrote:
> [snip]
> First, it ignores zero, which is a cardinal sin.
Or is it an ordinal sin?
[snip]
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On 24/01/2008, Ricardo Aráoz <[EMAIL PROTECTED]> wrote:
> Isn't dictionary access faster than list access? Why are three lists
> 'much more efficient'?
Well, not necessarily.
If you want a dictionary, you could use a list of tuples:
myDict = [('a', 'one'), ('b', 'two), ('c', 'three')]
Then you
> Isn't dictionary access faster than list access? Why are three lists
> 'much more efficient'?
Oh no, no, no. Dictionaries are faster when you are *searching through* for
a particular value. If you already know the index of the item in the list,
lists are much faster.
Dictionaries are hash ba
> This could be written much more efficiently. It can be done with only
> these
> lists~
> ones =
> ['zero','one','two','three','four','five','six','seven','eight','nine']
> teens =
> ['ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']
What is it
Tiger12506 wrote:
>> up to a thousand (not tested)
>>
>> words = {0:'zero', 1:'one', 2:'two', 3:'three', ... , 10:'ten',
>> 11:'eleven', 12:'twelve', ..., 19:'nineteen',
>> 20:'twenty', , 90:'ninety', 100:'one hundred' }
>> def digitToString(n) :
>>try :
>>retStr = words[n]
> up to a thousand (not tested)
>
> words = {0:'zero', 1:'one', 2:'two', 3:'three', ... , 10:'ten',
> 11:'eleven', 12:'twelve', ..., 19:'nineteen',
> 20:'twenty', , 90:'ninety', 100:'one hundred' }
> def digitToString(n) :
>try :
>retStr = words[n]
>except KeyError :
>
Danny Yoo wrote:
> Hi Jason,
>
>
> Looking back at that Java code:
>
>
> static String convertDigitToEnglish(int d) {
> switch ( d )
> {
>case 1: return "one";
>case 2: return "two";
>case 3
Hi Jason,
Looking back at that Java code:
static String convertDigitToEnglish(int d) {
switch ( d )
{
case 1: return "one";
case 2: return "two";
case 3: return "three";
case 4: retu
Terry Carroll wrote:
> I'm no Java expert, but isn't Java's Map more or less equivalent to
> Python's dictionary?
More or less, except Python dicts are about 10x easier to use.
Some (overly complicated) examples here:
http://personalpages.tds.net/~kent37/stories/00017.html
Kent
On Wed, 23 Jan 2008, Jason Massey wrote:
> An example routine to translate a number into [its] english equivalent
> was given (again, this is Java):
> static String convertDigitToEnglish(int d) {
> switch ( d )
> {
>
> case 1: return "one";
> case 2: return "two"
On Jan 22, 2008 5:10 PM, Damian Archer <[EMAIL PROTECTED]> wrote:
> So anyone have any good project ideas, perhaps projects that people have
> undertaken before??
>
>
I'm taking a Java class this semester and our first program is a number
translator. Here's the assignment:
*Below is a sample
Damian Archer wrote:
> So anyone have any good project ideas, perhaps projects that people have
> undertaken before??
This just came up on the list:
http://mail.python.org/pipermail/tutor/2008-January/059653.html
Kent
___
Tutor maillist - Tutor@pyth
On Tue, Jan 22, 2008 at 11:10:18PM +, Damian Archer wrote:
>So anyone have any good project ideas, perhaps projects that people
>have
>undertaken before??
I am in the same situation as you are. What I now did was doing
something practical and some fun stuff: such as writing a sta
Guys and Gals,
Firstly 'Hi'. So I am new to Python have been learning it for about two
months now on and off between working and playing.
Its the first language I have tried to learn, I am taking to it quite well
and enjoying it, which is always good.
The problem I am having is finding proje
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of josipSent:
Monday, June 19, 2006 8:39 AMTo:
tutor@python.orgSubject: [Tutor] projects for
beginners
Hi!
I have read learning python and mede some smaller examples.
Now I want to make smoe project
Hi! I have read learning python and mede some smaller examples. Now I want to make smoe project, I'm thinking about text editor. Can someone give me pointers like (where and how to start, etc.)? Or maybe another project suitable for beginners.
Sneak preview the all-new Yahoo.com. It
Hi there, This list is great! I really like the aspect of mentor-mentee relationship. Ok, I have been programming in various languages for many many years, and here is my dilemna. I jump into a huge project such as Zope or Mambo (php side) and spend a couple of weeks on it, get frustrated, and
20 matches
Mail list logo