Skip to content

Commit 48e543a

Browse files
authored
Merge pull request #238 from chinnaji/python-loops-grammatical-error
made range function definition clearer
2 parents 4d7f24b + aeeb3c9 commit 48e543a

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

10_Day_Loops/10_loops.md

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<a href="https://www.linkedin.com/in/asabeneh/" target="_blank">Asabeneh Yetayeh</a><br>
1212
<small> Second Edition: July, 2021</small>
1313
</sub>
14+
1415
</div>
1516

1617
[<< Day 9](../09_Day_Conditionals/09_conditionals.md) | [Day 11 >>](../11_Day_Functions/11_functions.md)
@@ -85,7 +86,6 @@ else:
8586

8687
The above loop condition will be false when count is 5 and the loop stops, and execution starts the else statement. As a result 5 will be printed.
8788

88-
8989
### Break and Continue - Part 1
9090

9191
- Break: We use break when we like to get out of or stop the loop.
@@ -285,20 +285,15 @@ for number in numbers:
285285
print('outside the loop')
286286
```
287287

288-
In the example above, if the number equals 3, the step *after* the condition (but inside the loop) is skipped and the execution of the loop continues if there are any iterations left.
288+
In the example above, if the number equals 3, the step _after_ the condition (but inside the loop) is skipped and the execution of the loop continues if there are any iterations left.
289289

290290
### The Range Function
291291

292-
The _range()_ function is used to loop through a set of code a certain number of times. The _range(start,end, step)_ takes three parameters: starting, ending and increment.
293-
start: integer starting from which the sequence of integers is to be returned
294-
stop: integer before which the sequence of integers is to be returned.
295-
The range of integers end at stop – 1.
296-
step: integer value which determines the increment between each integer in the sequence
297-
By default it starts from 0 and the increment is 1. The range sequence needs at least 1 argument (end).
292+
The _range()_ function is used to return a list of numbers. The _range(start, end, step)_ takes three parameters: starting, ending and increment. By default it starts from 0 and the increment is 1. The range sequence needs at least 1 argument (end).
298293
Creating sequences using range
299294

300295
```py
301-
lst = list(range(11))
296+
lst = list(range(11))
302297
print(lst) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
303298
st = set(range(1, 11)) # 2 arguments indicate start and end of the sequence, step set to default 1
304299
print(st) # {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
@@ -441,26 +436,26 @@ for number in range(6):
441436
6. Iterate through the list, ['Python', 'Numpy','Pandas','Django', 'Flask'] using a for loop and print out the items.
442437
7. Use for loop to iterate from 0 to 100 and print only even numbers
443438
8. Use for loop to iterate from 0 to 100 and print only odd numbers
444-
439+
445440
### Exercises: Level 2
446-
441+
447442
1. Use for loop to iterate from 0 to 100 and print the sum of all numbers.
448443

449-
```sh
450-
The sum of all numbers is 5050.
451-
```
444+
```sh
445+
The sum of all numbers is 5050.
446+
```
452447

453448
2. Use for loop to iterate from 0 to 100 and print the sum of all evens and the sum of all odds.
454449

455-
```sh
456-
The sum of all evens is 2550. And the sum of all odds is 2500.
457-
```
450+
```sh
451+
The sum of all evens is 2550. And the sum of all odds is 2500.
452+
```
458453

459454
### Exercises: Level 3
460455

461456
1. Go to the data folder and use the [countries.py](https://github.com/Asabeneh/30-Days-Of-Python/blob/master/data/countries.py) file. Loop through the countries and extract all the countries containing the word _land_.
462-
2. This is a fruit list, ['banana', 'orange', 'mango', 'lemon'] reverse the order using loop.
463-
3. Go to the data folder and use the [countries_data.py](https://github.com/Asabeneh/30-Days-Of-Python/blob/master/data/countries-data.py) file.
457+
1. This is a fruit list, ['banana', 'orange', 'mango', 'lemon'] reverse the order using loop.
458+
1. Go to the data folder and use the [countries_data.py](https://github.com/Asabeneh/30-Days-Of-Python/blob/master/data/countries-data.py) file.
464459
1. What are the total number of languages in the data
465460
2. Find the ten most spoken languages from the data
466461
3. Find the 10 most populated countries in the world

0 commit comments

Comments
 (0)