-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chapter 3 and 4 changes done #65
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job with a lot of changes! I have made a few comments; can you go through them?
- Multiple levels of nesting is possible. | ||
|
||
|
||
|
||
## `#!py while` versus `#!py for` | ||
|
||
`#!py for` loops are typically used in situations where the number of iterations can be quantified, whereas `#!py while` loops are used in situations where the number of iterations cannot be quantified exactly. This doesn't mean that the number of iterations in a `#!py for` loop is always constant. For example: | ||
`#!py for` loops are typically used in situations where the number of iterations can be quantified and is known in advance, whereas `#!py while` loops are used in situations where the number of iterations cannot be quantified exactly. This doesn't mean that the number of iterations in a `#!py for` loop is always constant. For example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is necessary to know the number of iterations in advance to use a for loop. For example,
for i in range(int(input())):
print(i)
I think the entire paragraph doesn't really apply to python but rather to some other language like C or Java. In python, for loops are used to iterate over sequences such as lists, sets, generators, strings, etc., whereas while loops are used to execute a block of code while a condition is true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually what I believe is being implied in this paragraph is that in for
loops, the number of times the code block is run can be determined in advance. Even in your example we know that the body of for
only needs to executed as much number of times as the input provided. And in case of iterable objects like lists, sets etc the for loop is run exactly as many times as the length of the object.
while
on the other is used commonly in cases where we don't have this knowledge in advance.. as you said we just know that it needs to be executed as long as some condition stays True
.
Many programming tutorials I've seen also introduce the use of while
and for
using the same idea. Technicalities and implementation of loops might vary across languages but this basic idea I think applies to all. What say?
@@ -1,6 +1,6 @@ | |||
# Lesson-3.5 | |||
|
|||
## Library | |||
## Library (Continued) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, can you tell me why you added "continued" in parantheses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a library lesson in some earlier chapter too where some other library was introduced.. so I thought we had to convey to the readers that this isn't the same lesson. Should I get rid of it 🫤? Or maybe we could do something like:
- Library - Part 1
- Library - Part 2
Thanks for reviewing.. going through the comments now!! |
No description provided.