Skip to content

Commit b0c402b

Browse files
committed
made range function definition clearer
1 parent ff24ab2 commit b0c402b

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

10_Day_Loops/10_loops.md

Lines changed: 13 additions & 13 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.
@@ -284,15 +284,15 @@ for number in numbers:
284284
print('outside the loop')
285285
```
286286

287-
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.
287+
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.
288288

289289
### The Range Function
290290

291-
The _range()_ function is used 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).
291+
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).
292292
Creating sequences using range
293293

294294
```py
295-
lst = list(range(11))
295+
lst = list(range(11))
296296
print(lst) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
297297
st = set(range(1, 11)) # 2 arguments indicate start and end of the sequence, step set to default 1
298298
print(st) # {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
@@ -431,26 +431,26 @@ for number in range(6):
431431
6. Iterate through the list, ['Python', 'Numpy','Pandas','Django', 'Flask'] using a for loop and print out the items.
432432
7. Use for loop to iterate from 0 to 100 and print only even numbers
433433
8. Use for loop to iterate from 0 to 100 and print only odd numbers
434-
434+
435435
### Exercises: Level 2
436-
436+
437437
1. Use for loop to iterate from 0 to 100 and print the sum of all numbers.
438438

439-
```sh
440-
The sum of all numbers is 5050.
441-
```
439+
```sh
440+
The sum of all numbers is 5050.
441+
```
442442

443443
1. Use for loop to iterate from 0 to 100 and print the sum of all evens and the sum of all odds.
444444

445-
```sh
446-
The sum of all evens is 2550. And the sum of all odds is 2500.
447-
```
445+
```sh
446+
The sum of all evens is 2550. And the sum of all odds is 2500.
447+
```
448448

449449
### Exercises: Level 3
450450

451451
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_.
452452
1. This is a fruit list, ['banana', 'orange', 'mango', 'lemon'] reverse the order using loop.
453-
2. 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.
453+
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.
454454
1. What are the total number of languages in the data
455455
2. Find the ten most spoken languages from the data
456456
3. Find the 10 most populated countries in the world

0 commit comments

Comments
 (0)