Skip to content

Commit 22dd72d

Browse files
committed
Update
1 parent 091b13d commit 22dd72d

File tree

3 files changed

+39
-20
lines changed

3 files changed

+39
-20
lines changed

.idea/workspace.xml

Lines changed: 18 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

6_Loops/10_ForLoop.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
'''
2-
In a list of numbers from 1 to 100, make a list of numbers which are divisible by the number user inputs.
2+
In a list of numbers from 1 to 100, make a list of numbers which are divisible by,
3+
the number which user inputs.
34
'''
45

56
list1 = []
67
list2 = []
78
for number in range(1, 101):
9+
'''
10+
To loop through a set of code a specified number of times, we can use the range() function,
11+
The range() function returns a sequence of numbers, starting from 0 by default,
12+
and increments by 1 (by default), and ends at a specified number.
13+
'''
814
list1.append(number)
915
print(list1)
1016

@@ -16,6 +22,11 @@
1622
if (divNum % divisor == 0 and divNum != divisor):
1723
count += 1
1824
list2.append(divNum)
19-
print("Output List: ",list2)
25+
print("Output List: ", list2)
2026

21-
print("Count is: ",count)
27+
print("Count is: ", count)
28+
29+
'''
30+
A "for" loop is used for iterating over a sequence
31+
that is either a list, a tuple, a dictionary, a set, or a string.
32+
'''

6_Loops/11_WhileLoop.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,11 @@
99
print(fruit_new)
1010
index = index + 1
1111

12-
# while True: # this is an infinite loop
12+
# while True: # Uncomment this, it is an infinite loop
1313
# print("a")
14+
15+
'''
16+
The "while" loop can execute a set of statements as long as a condition is true.
17+
The "break" statement can stop the loop even if the while condition is true.
18+
The continue statement can stop the current iteration, and continue with the next.
19+
'''

0 commit comments

Comments
 (0)