[Tutor] Is this overkill?
catherine curley
catherine.curley at gmail.com
Thu Jan 26 23:33:41 CET 2006
Bradly
I'm new to python also. Have you come across any good exercises that a
beginner try.
I've spend some time going throught the many available turorials, but find
it hard to get good exercises to try out what you learn.
Catherine
On 1/21/06, Bradly McConnell <bradly.mcconnell at gmail.com> wrote:
>
> Greetings all:
>
> I'm new to Python, and have come across and exercise that basically
> counts to 100. The idea is to accept user input for an initial
> number, and then let the user add additional numbers. I wanted to
> give feedback if a number selected would bring the total above 100, so
> the user would select a lower number. It looks like I have it
> working, but it doesn't seem very efficient. I would like any hints,
> help, or comments that you can provide. Below is what I have so far.
>
> number = input("Please enter a number: ")
> while number != 100:
> additional_number = input("Please enter an additional number: ")
> if additional_number + number > 100:
> lower_number = input("please enter a lower number: ")
> if lower_number + number > 100:
> lower_number = input("Lower!")
> else:
> number = lower_number + number
> elif additional_number + number < 100:
> number = additional_number + number
> else:
> continue
>
> print "Done", number
>
>
> Brad
> _______________________________________________
> 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/20060126/4e59c89a/attachment.htm
More information about the Tutor
mailing list