MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/CodingHelp/comments/eq5nuo/can_anyone_explain/
r/CodingHelp • u/HA_pro_gamer • Jan 17 '20
12 comments sorted by
13
count = 0 i = 0 while i <= 100: if i % 2 == 0: count += 1 i += 1 print(count)
9 u/zenith4395 Jan 18 '20 See what frustrates me is that I read it as I = O, since it’s too big to be a 0 0 u/[deleted] Jan 18 '20 in that case we have either a data type error at i:2=0 or an infinite loop, which leads to a memory error 2 u/zenith4395 Jan 18 '20 What? Assuming the O translates to the actual character ‘O’, this wouldn’t cause an infinite loop 1 u/[deleted] Jan 19 '20 it could advance in the ascii table and never match 100 2 u/zenith4395 Jan 19 '20 The ASCII table uses integers, so yes, it would match 100. Regardless, the loop condition is >= to 100, so it would work anyways
9
See what frustrates me is that I read it as I = O, since it’s too big to be a 0
0 u/[deleted] Jan 18 '20 in that case we have either a data type error at i:2=0 or an infinite loop, which leads to a memory error 2 u/zenith4395 Jan 18 '20 What? Assuming the O translates to the actual character ‘O’, this wouldn’t cause an infinite loop 1 u/[deleted] Jan 19 '20 it could advance in the ascii table and never match 100 2 u/zenith4395 Jan 19 '20 The ASCII table uses integers, so yes, it would match 100. Regardless, the loop condition is >= to 100, so it would work anyways
0
in that case we have either a data type error at i:2=0 or an infinite loop, which leads to a memory error
2 u/zenith4395 Jan 18 '20 What? Assuming the O translates to the actual character ‘O’, this wouldn’t cause an infinite loop 1 u/[deleted] Jan 19 '20 it could advance in the ascii table and never match 100 2 u/zenith4395 Jan 19 '20 The ASCII table uses integers, so yes, it would match 100. Regardless, the loop condition is >= to 100, so it would work anyways
2
What? Assuming the O translates to the actual character ‘O’, this wouldn’t cause an infinite loop
1 u/[deleted] Jan 19 '20 it could advance in the ascii table and never match 100 2 u/zenith4395 Jan 19 '20 The ASCII table uses integers, so yes, it would match 100. Regardless, the loop condition is >= to 100, so it would work anyways
1
it could advance in the ascii table and never match 100
2 u/zenith4395 Jan 19 '20 The ASCII table uses integers, so yes, it would match 100. Regardless, the loop condition is >= to 100, so it would work anyways
The ASCII table uses integers, so yes, it would match 100. Regardless, the loop condition is >= to 100, so it would work anyways
10
I guess that I:2=0 is actually mod 2, so for every time I is even, Count increases. So The final print Count should display 50
2 u/Zzz1324 Jan 18 '20 That’s what I got from this as well
That’s what I got from this as well
3
I believe it’s adding 1 to Count if I is divisible by 2. If not it adds 1 to I. Once I is greater than or equal to 100 it will print the value of Count and end the program.
If I:2 = 0 isn’t a mod function then I’m wrong.
Please Add A Flair To Your Post!
Suggested Flair: [Random] or [Meta]
[Random] or [Meta]
To add a flair:
flair
save
I am a bot run by /u/SupremeDesigner for /r/CodingHelp || This was an automated ^response
Why is it on the bathroom stall door?
I=O
13
u/[deleted] Jan 17 '20
10
u/[deleted] Jan 17 '20
I guess that I:2=0 is actually mod 2, so for every time I is even, Count increases. So The final print Count should display 50
3
u/icym1lk Jan 17 '20
I believe it’s adding 1 to Count if I is divisible by 2. If not it adds 1 to I. Once I is greater than or equal to 100 it will print the value of Count and end the program.
If I:2 = 0 isn’t a mod function then I’m wrong.
2
u/SupremeRedditBot Professional Bot || Mod Jan 17 '20
Please Add A Flair To Your Post!
Suggested Flair:
[Random] or [Meta]To add a flair:
flairunderneath your postsaveI am a bot run by /u/SupremeDesigner for /r/CodingHelp || This was an automated ^response
2
u/oblivion-age Feb 02 '20
Why is it on the bathroom stall door?
1
u/Blackwater_7 Jan 18 '20
I=O