[Courses]Need a little help with extremely basic Python
programming
Mary
mary-linuxchix at puzzling.org
Fri Aug 22 08:30:06 EST 2003
Hi Jason,
You might be better off asking your question on linuxchix's
programming at linuxchix.org mailing list (Cc-ed).
-Mary
On Thu, Aug 21, 2003, Jason Kappel wrote:
>
> I have a quick question about the program in question. I wrote a
> version that not only adds up to 100, but won't let the user go over,
> and now I'm looking for a way to check if the input is actually a
> number, so I don't get an error when text is entered as an input. Is
> there a function to check if an input is either an integer or floating
> point?
>
> #this takes number inputs from the user untill the sum reaches 100
> sum = 0.0
> while (sum < 100):
> remaining = 100.0-sum
> print "Please choose a number no larger than",remaining
> number = input ("> ")
> sum = sum+number
> while (number > remaining): #while input too large, subtract and
> try again
> sum = sum-number
> print "That was bigger than",remaining,"try again"
> number = input ("> ")
> sum = sum+number
> print "Good for you! You can add to",sum
>
>
> I have a quick question
> _________________________________________________________________
>
> [1]MSN 8: Get 6 months for $9.95/month.
>
> References
>
> 1. http://g.msn.com/8HMFENUS/2728??PS=
> --
> Courses mailing list
> Courses at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/courses
>
More information about the Courses
mailing list