[Tutor] creating strings
Andrei
project5 at redrival.net
Sun Sep 25 13:33:36 CEST 2005
Goofball223 at wmconnect.com wrote:
> How would I get the following program to accept inputs of exam scores
> from 0-100 with A being 100-90, B being 89-80, C being 79-70, D being
> 69-60, and F being everything less than 60?
>
> import string
There's no point in importing string.
> def main():
>
> scores = ["F", "D", "C", "B", "A"]
> g = input("Enter a score number (0-100): ")
>
> print "The score of your exam is", scores [g-0] + "."
> main()
You could chain a bunch of if-statements.
if g is between X1 and Y1: result is Z1
else if g is between X2 and Y2: result is Z2
else if ...
--
Yours,
Andrei
=====
Mail address in header catches spam. Real contact info:
''.join([''.join(s) for s in zip(
"poet at aao.l pmfe!Pes ontuei ulcpss edtels,s hr' one oC.",
"rjc5wndon.Sa-re laed o s npbi ot.Ira h it oteesn edt C")])
More information about the Tutor
mailing list