On Thursday, June 23, 2016 at 12:17:23 AM UTC-4, Elizabeth Weiss wrote:
> CODE #1:
>
> i=0
> while 1==1:
>print(i)
>i=i+1
>if i>=5:
> print("Breaking")
> break
>
> --
> I understand that i=0 and i will only be printed if 1=1
> The results of this is
> 0
> 1
> 2
> 3
> 4
>
gt;
> i=i+1 adds 1 to the current value of i, then assigns that value to i.
>
> You can increment i by whatever you want:
> i=i+1
> i=i+2
> i=i+35
> etc.
>
>
>
>
> > 3. Do the results not include 2 of 5 because we wrote if i==2 and if i==5?
>
>
if i==2:
> > print("Skipping 2")
> > continue
> > if i==5:
> > print("Breaking")
> > break
> >print(i)
> >
> > --
> >
> > Questions:
> > 1. what does the word True have to do with an
On Thursday, June 23, 2016 at 12:49:30 AM UTC-4, Lawrence D’Oliveiro wrote:
> On Thursday, June 23, 2016 at 4:17:23 PM UTC+12, Elizabeth Weiss wrote:
> >
> > i=0
> > while 1==1:
> >print(i)
> >i=i+1
> >if i>=5:
> > print("Breaking")
> > break
> >
> > Why is Breaking going to
On Sun, 26 Jun 2016 05:32 pm, Lawrence D’Oliveiro wrote:
> On Thursday, June 23, 2016 at 11:58:01 PM UTC+12, Jon Ribbens wrote:
>> I seem to recall that Java originally insisted that only booleans
>> (excluding even Booleans, which are a different thing because of
>> course they are) could be chec
On Thursday, June 23, 2016 at 11:58:01 PM UTC+12, Jon Ribbens wrote:
> I seem to recall that Java originally insisted that only booleans
> (excluding even Booleans, which are a different thing because of
> course they are) could be checked for truth and it was one of
> Java's significant warts.
Ja
BartC wrote:
> But even with ordinary conditionals, False is False, but [False] is
> True. And [] is False, while [[]] is True. A class instance is always
> True, even when empty. And then "False" is True as well!
"Empty" is not "Nothing". To be empty, something must exist first.
--
Pierre-Al
In <639b00e0-7b9d-4ed4-96ad-6afbcd536...@googlegroups.com> Elizabeth Weiss
writes:
> i=0
> while 1==1:
>print(i)
>i=i+1
>if i>=5:
> print("Breaking")
> break
> Why is Breaking going to be printed if i only goes up to 4?
Your code prints i and THEN adds one to it.
So i is
On Fri, Jun 24, 2016 at 1:52 AM, BartC wrote:
> On 23/06/2016 12:39, Chris Angelico wrote:
>>
>> On Thu, Jun 23, 2016 at 8:15 PM, BartC wrote:
>>>
>>> Actually pretty much any expression can be used, because Python can
>>> interpret almost anything as either True or False. Don't ask for the
>>> r
On 23/06/2016 12:39, Chris Angelico wrote:
On Thu, Jun 23, 2016 at 8:15 PM, BartC wrote:
Actually pretty much any expression can be used, because Python can
interpret almost anything as either True or False. Don't ask for the rules
because they can be complicated, but for example, zero is False
On 2016-06-23, Chris Angelico wrote:
> On Thu, Jun 23, 2016 at 8:15 PM, BartC wrote:
>> Actually pretty much any expression can be used, because Python can
>> interpret almost anything as either True or False. Don't ask for the rules
>> because they can be complicated, but for example, zero is Fa
On Thu, Jun 23, 2016 at 8:15 PM, BartC wrote:
> Actually pretty much any expression can be used, because Python can
> interpret almost anything as either True or False. Don't ask for the rules
> because they can be complicated, but for example, zero is False, and any
> other number is True. I thin
On 23/06/2016 05:17, Elizabeth Weiss wrote:
CODE #1:
i=0
while True:
i=i+1
if i==2:
print("Skipping 2")
continue
if i==5:
print("Breaking")
break
print(i)
--
Questions:
2. i=i+1- I never understand this. Why isn't it i=i+2?
3. Do the results not include 2 of
On Wed, 22 Jun 2016 21:17:03 -0700, Elizabeth Weiss wrote:
> CODE #1:
>
> i=0 while 1==1:
>print(i)
>i=i+1 if i>=5:
> print("Breaking") break
>
> --
> I understand that i=0 and i will only be printed if 1=1 The results of
> this is 0
> 1
> 2
> 3
> 4
> Breaking
>
> Why is Breaki
starts off as 0. But then you increase it by 1 each time around the loop.
Can I ask, have you learned about for loops yet? There seems to be a fashion
among some teachers and educators to teach while loops before for loops. I
think that is a terrible idea, while loops are so much more compli
ing here?
> 2. i=i+1- I never understand this. Why isn't it i=i+2?
> 3. Do the results not include 2 of 5 because we wrote if i==2 and if i==5?
> 4. How is i equal to 2 or 5 if i=0?
>
> Thanks for all of your help!
I suggested in your other post (Subject While Loops)
that the
On Thursday, June 23, 2016 at 4:17:23 PM UTC+12, Elizabeth Weiss wrote:
>
> i=0
> while 1==1:
>print(i)
>i=i+1
>if i>=5:
> print("Breaking")
> break
>
> Why is Breaking going to be printed if i only goes up to 4? It does say if
> i>=5?
Because you incremented i after printi
CODE #1:
i=0
while 1==1:
print(i)
i=i+1
if i>=5:
print("Breaking")
break
--
I understand that i=0 and i will only be printed if 1=1
The results of this is
0
1
2
3
4
Breaking
Why is Breaking going to be printed if i only goes up to 4? It does say if
i>=5? Shouldn't this me
In <0cf9a94e-b84c-460d-b03d-edf6a941a...@googlegroups.com> Elizabeth Weiss
writes:
> Why is one of the results 5 since i=i+1? Should the maximum result
> be 4 since 4 +1=5?
"while i<=5" means "while i is less than or equal to 5". So the loop
will keep going at 5, and only stop when i is 6.
-
On Tue, 21 Jun 2016 20:50:24 -0700, Elizabeth Weiss wrote:
> i=1 while i<=5:
>print(i)
>i=i+1
>
> The result is:
> 1
> 2
> 3
> 4
> 5
>
> Why is one of the results 5 since i=i+1? Should the maximum result be 4
> since 4 +1=5?
>
> Thanks for your help!
check you loop condition
while i le
On 06/21/2016 09:50 PM, Elizabeth Weiss wrote:
> i=1
> while i<=5:
>print(i)
>i=i+1
>
> The result is:
> 1
> 2
> 3
> 4
> 5
>
> Why is one of the results 5 since i=i+1? Should the maximum result be 4 since
> 4 +1=5?
>
> Thanks for your help!
If you trace the execution through in your m
Elizabeth Weiss writes:
> Why is one of the results 5 since i=i+1?
What do you think ‘i = i + 1’ means? (Asking because your idea of what
that means may be affecting how you expect the loop to behave.)
> Should the maximum result be 4 since 4 +1=5?
Try “thinking like the computer”: perform the
On Wednesday, June 22, 2016 at 9:20:35 AM UTC+5:30, Elizabeth Weiss wrote:
> i=1
> while i<=5:
>print(i)
>i=i+1
>
> The result is:
> 1
> 2
> 3
> 4
> 5
>
> Why is one of the results 5 since i=i+1? Should the maximum result be 4 since
> 4 +1=5?
>
Not sure what your question is
But I gue
On Tue, 21 Jun 2016 20:50:24 -0700, Elizabeth Weiss wrote:
> i=1
> while i<=5:
>print(i)
>i=i+1
>
> The result is:
> 1
> 2
> 3
> 4
> 5
>
> Why is one of the results 5 since i=i+1? Should the maximum result be 4 since
> 4 +1=5?
>
> Thanks for your help!
The operator '<=' means less th
i=1
while i<=5:
print(i)
i=i+1
The result is:
1
2
3
4
5
Why is one of the results 5 since i=i+1? Should the maximum result be 4 since 4
+1=5?
Thanks for your help!
--
https://mail.python.org/mailman/listinfo/python-list
You're actually calling the read2() function from within read2(). This
is called recursion, and it is *not* what you want in this case, since
it unnecessarily fills up your call stack. Remember that a while loop
automatically goes back to the top without you having to re-call your
function. I w
oops, embarrassing, I created the while loop not to use recursion then
I still did...
--
http://mail.python.org/mailman/listinfo/python-list
ssecorp wrote:
in read2 it never quits when I write quit, why?
def read():
expr = raw_input("Lisp> ")
if expr != "quit":
print parse(expr)
read()
else:
print "Good session!"
def read2():
expr = ""
while expr != "quit":
expr = raw_input("Lisp>
def read2():
expr = ""
while expr != "quit":
expr = raw_input("Lisp> ")
print parse(expr)
read2()
^
print "Good session!"
You shouldn't call read2() inside read2()...
just remove that line and retry...
Each time you call read2() recursivel
in read2 it never quits when I write quit, why?
def read():
expr = raw_input("Lisp> ")
if expr != "quit":
print parse(expr)
read()
else:
print "Good session!"
def read2():
expr = ""
while expr != "quit":
expr = raw_input("Lisp> ")
print
On 6 avr, 01:53, [EMAIL PROTECTED] wrote:
> it seems to me from my results that when i use a while-loop it will
> execute once after the condition is met.
>
> ie the conditions is met the code executes one time more and then
> quits.
The problem is obviously in your code, but since you failed to p
On Apr 6, 4:53 am, [EMAIL PROTECTED] wrote:
> it seems to me from my results that when i use a while-loop it will
> execute once after the condition is met.
Perhaps your condition is wrong. Please provide the code where this
occured.
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 6, 9:53 am, [EMAIL PROTECTED] wrote:
> it seems to me from my results that when i use a while-loop it will
> execute once after the condition is met.
>
> ie the conditions is met the code executes one time more and then
> quits.
The syntax is this:
while condition:
do_something
> it seems to me from my results that when i use a while-loop it
> will execute once after the condition is met.
Nope.
> ie the conditions is met the code executes one time more and
> then quits.
Must be that your conditional is wrong, or your conditions are
not updated the way you think they a
it seems to me from my results that when i use a while-loop it will
execute once after the condition is met.
ie the conditions is met the code executes one time more and then
quits.
--
http://mail.python.org/mailman/listinfo/python-list
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 toget
[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 [&
[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 toget
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
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 read
42 matches
Mail list logo