[Tutor] bug in exam score conversion program

Dragos Ionescu idragos at ymail.com
Sat Oct 4 21:42:30 CEST 2008


----- Original Message ----
From: bob gailer <bgailer at gmail.com>
To: David <ldl08 at gmx.net>
Cc: tutor at python.org
Sent: Saturday, October 4, 2008 10:15:10 PM
Subject: Re: [Tutor] bug in exam score conversion program

Lots of good responses. And now for something completely different:

import string
x = string.maketrans('567891', 'FDCBAA')
score = raw_input('score>')
print "Your grade is:", score[0].translate(x)

-- 
Bob Gailer
Chapel Hill NC 
919-636-4239

When we take the time to be aware of our feelings and 
needs we have more satisfying interatctions with others.

Nonviolent Communication provides tools for this awareness.

As a coach and trainer I can assist you in learning this process.

What is YOUR biggest relationship challenge?

_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor



Wow! Bob Gailer's solution is so elegant. Can someone plese explain what is the algorithm behind  string.maketrans. More exactly, how is this function doing the coding? 
 http://scripts.mit.edu/~dionescu/pyworld/



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20081004/c39764f5/attachment.htm>


More information about the Tutor mailing list