[Tutor] creating strings

Pujo Aji ajikoe at gmail.com
Sun Sep 25 13:11:41 CEST 2005


I will use simple function:
 def getscore(val):
if 90 < val <=100:
return 'A'
elif val >= 80:
return 'B'
elif val >= 70:
return 'C'
elif val >= 60:
return 'D'
else:
return 'F'

def main():
g = input('Enter score:')
print 'the score of the exam is %s' % (getscore(int(g)))

Cheers,
pujo
 On 9/25/05, Goofball223 at wmconnect.com <Goofball223 at wmconnect.com> wrote:
>
> Hello
>
> 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
>
> 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()
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050925/6022a035/attachment.html


More information about the Tutor mailing list