Bayazee a écrit :
> hi
>
> #Exercise 1 :
> s=0
> while 1:
> s+=input("Enter a num : ")
> if s>=100:
> print "The sum is greater than 100 : ",s
> break
Why do you manually check the condition when the construct is meant to
take care of it ?
the_sum = 0
while the_sum < 100:
try:
[EMAIL PROTECTED] 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
[EMAIL PROTECTED] a écrit :
> i was wondering if anyone could point me to some good reading about the
> for and while loops
There's not much to say.
while :
will execute as long as is True.
for in :
will execute for each in .
ie :
for letter in ["a", "b", "c"]:
do_something_wi
[EMAIL PROTECTED] schrieb:
> 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. W
hi
#Exercise 1 :
s=0
while 1:
s+=input("Enter a num : ")
if s>=100:
print "The sum is greater than 100 : ",s
break
#Exercise 2 :
s=0
for i in range(5):
s+=input("Enter num #%d > "%(i+1))
print "The Sum is : " , s
--
http://mail.python.org/mailman/listinfo/python-list
hi
#Exercise 1 :
s=0
while 1:
s+=input("Enter a num : ")
if s>=100:
print "The sum is greater than 100 : ",s
break
#Exercise 1 :
s=0
for i in range(5):
s+=input("Enter num #%d > "%(i+1))
print "The Sum is : " , s
--
http://mail.python.org/mailman/listinfo/python-list