for and while loops
Simon Forman
rogue_pedro at yahoo.com
Wed Jun 28 18:46:45 EDT 2006
kydavis77 at gmail.com wrote:
> i was wondering if anyone could point me to some good reading about the
> for and while loops
>
> i am trying to write some programs
> "Exercise 1
>
> Write a program that continually reads in numbers from the user and
> adds them together until the sum reaches 100. Write another program
> that reads 100 numbers from the user and prints out the sum. "
>
> but im not quite grasping those functions..
>
> please bear im mind i am an extreme newbie at this...thanks in advance
while loops test a condition every time through the loop and keep
running as long as it's true.
for loops run through a finite (usually) set of things and do something
"for" each thing.
Check out one or more python tutorials such as
http://docs.python.org/tut/tut.html (and especially this part
http://docs.python.org/tut/node6.html), a quick search an google can
turn up more.
(Hint: you're probably gonna want to use a while loop for the first
program and a for loop for the second.)
Hope that helps,
~Simon
More information about the Python-list
mailing list