Skip to content

Commit b78270f

Browse files
committed
correction and minor fixes
1 parent 623a552 commit b78270f

File tree

8 files changed

+84
-83
lines changed

8 files changed

+84
-83
lines changed

02_Day_Variables_builtin_functions/02_variables_builtin_functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Python Variable Name Rules
6363
- A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and \_ )
6464
- Variable names are case-sensitive (firstname, Firstname, FirstName and FIRSTNAME) are different variables)
6565

66-
Let us se valid variable names
66+
Here are some example of valid variable names:
6767

6868
```shell
6969
firstname

04_Day_Strings/04_strings.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ Now, let us see the use of the above escape sequences with examples.
102102
```py
103103
print('I hope everyone is enjoying the Python Challenge.\nAre you ?') # line break
104104
print('Days\tTopics\tExercises') # adding tab space or 4 spaces
105-
print('Day 1\t3\t5')
106-
print('Day 2\t3\t5')
107-
print('Day 3\t3\t5')
108-
print('Day 4\t3\t5')
105+
print('Day 1\t5\t5')
106+
print('Day 2\t6\t20')
107+
print('Day 3\t5\t23')
108+
print('Day 4\t1\t35')
109109
print('This is a backslash symbol (\\)') # To write a backslash
110110
print('In every programming language it starts with \"Hello, World!\"') # to write a double quote inside a single quote
111111

@@ -328,16 +328,16 @@ print(challenge.expandtabs(10)) # 'thirty days of python'
328328

329329
```py
330330
challenge = 'thirty days of python'
331-
print(challenge.find('y')) # 16
332-
print(challenge.find('th')) # 17
331+
print(challenge.find('y')) # 5
332+
print(challenge.find('th')) # 0
333333
```
334334

335335
- rfind(): Returns the index of the last occurrence of a substring, if not found returns -1
336336

337337
```py
338338
challenge = 'thirty days of python'
339-
print(challenge.rfind('y')) # 5
340-
print(challenge.rfind('th')) # 1
339+
print(challenge.rfind('y')) # 16
340+
print(challenge.rfind('th')) # 17
341341
```
342342

343343
- format(): formats string into a nicer output

05_Day_Lists/05_lists.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ print(second_last) # mango
163163
### Unpacking List Items
164164

165165
```py
166-
lst = ['item','item2','item3', 'item4', 'item5']
166+
lst = ['item1','item2','item3', 'item4', 'item5']
167167
first_item, second_item, third_item, *rest = lst
168168
print(first_item) # item1
169169
print(second_item) # item2
@@ -175,7 +175,7 @@ print(rest) # ['item4', 'item5']
175175
```py
176176
# First Example
177177
fruits = ['banana', 'orange', 'mango', 'lemon','lime','apple']
178-
first_fruit, second_fruit, third_fruit, *rest = lst
178+
first_fruit, second_fruit, third_fruit, *rest = fruits
179179
print(first_fruit) # banana
180180
print(second_fruit) # orange
181181
print(third_fruit) # mango

07_Day_Sets/07_sets.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,12 @@ Set is a collection of items. Let me take you back to your elementary or high sc
4848

4949
### Creating a Set
5050

51-
We use curly brackets, {} to create a set or the *set()* built-in function.
51+
We use the _set()_ built-in function.
5252

5353
- Creating an empty set
5454

5555
```py
5656
# syntax
57-
st = {}
58-
# or
5957
st = set()
6058
```
6159

@@ -80,7 +78,7 @@ We use **len()** method to find the length of a set.
8078
```py
8179
# syntax
8280
st = {'item1', 'item2', 'item3', 'item4'}
83-
len(set)
81+
len(st)
8482
```
8583

8684
**Example:**
@@ -131,7 +129,7 @@ fruits.add('lime')
131129
```
132130

133131
- Add multiple items using _update()_
134-
The *update()* allows to add multiple items to a set. The *update()* takes a list argument.
132+
The _update()_ allows to add multiple items to a set. The _update()_ takes a list argument.
135133

136134
```py
137135
# syntax
@@ -174,7 +172,6 @@ fruits = {'banana', 'orange', 'mango', 'lemon'}
174172
removed_item = fruits.pop()
175173
```
176174

177-
178175
### Clearing Items in a Set
179176

180177
If we want to clear or empty the set we use _clear_ method.
@@ -427,7 +424,6 @@ age = [22, 19, 24, 25, 26, 24, 25, 24]
427424
1. Explain the difference between the following data types: string, list, tuple and set
428425
2. _I am a teacher and I love to inspire and teach people._ How many unique words have been used in the sentence? Use the split methods and set to get the unique words.
429426

430-
431427
🎉 CONGRATULATIONS ! 🎉
432428

433429
[<< Day 6](../06_Day_Tuples/06_tuples.md) | [Day 8 >>](../08_Day_Dictionaries/08_dictionaries.md)

10_Day_Loops/10_loops.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ while condition:
127127
count = 0
128128
while count < 5:
129129
if count == 3:
130+
count = count + 1
130131
continue
131132
print(count)
132133
count = count + 1

17_Day_Exception_handling/17_exception_handling.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
[<< Day 16](../16_Day_Python_date_time/16_python_datetime.md) | [Day 18 >>](../18_Day_Regular_expressions/18_regular_expressions.md)
1717

1818
![30DaysOfPython](../images/30DaysOfPython_banner3@2x.png)
19+
1920
- [📘 Day 17](#-day-17)
2021
- [Exception Handling](#exception-handling)
2122
- [Packing and Unpacking Arguments in Python](#packing-and-unpacking-arguments-in-python)
@@ -128,6 +129,7 @@ I alway run.
128129
```
129130

130131
It is also shorten the above code as follows:
132+
131133
```py
132134
try:
133135
name = input('Enter your name:')
@@ -223,9 +225,9 @@ print(sum_all(1, 2, 3, 4, 5, 6, 7)) # 28
223225
def packing_person_info(**kwargs):
224226
# check the type of kwargs and it is a dict type
225227
# print(type(kwargs))
226-
# Printing dictionary items
228+
# Printing dictionary items
227229
for key in kwargs:
228-
print("{key} = {kwargs[key]}")
230+
print(f"{key} = {kwargs[key]}")
229231
return kwargs
230232

231233
print(packing_person_info(name="Asabeneh",
@@ -247,7 +249,7 @@ Like in JavaScript, spreading is possible in Python. Let us check it in an examp
247249
```py
248250
lst_one = [1, 2, 3]
249251
lst_two = [4, 5, 6, 7]
250-
lst = [0, *list_one, *list_two]
252+
lst = [0, *lst_one, *lst_two]
251253
print(lst) # [0, 1, 2, 3, 4, 5, 6, 7]
252254
country_lst_one = ['Finland', 'Sweden', 'Norway']
253255
country_lst_two = ['Denmark', 'Iceland']
@@ -257,7 +259,7 @@ print(nordic_countries) # ['Finland', 'Sweden', 'Norway', 'Denmark', 'Iceland']
257259

258260
## Enumerate
259261

260-
If we are interested in an index of a list, we use *enumerate* built-in function to get the index of each item in the list.
262+
If we are interested in an index of a list, we use _enumerate_ built-in function to get the index of each item in the list.
261263

262264
```py
263265
for index, item in enumerate([20, 30, 40]):
@@ -301,4 +303,4 @@ print(fruits_and_veges)
301303

302304
🎉 CONGRATULATIONS ! 🎉
303305

304-
[<< Day 16](../16_Day_Python_date_time/16_python_datetime.md) | [Day 18 >>](../18_Day_Regular_expressions/18_regular_expressions.md)
306+
[<< Day 16](../16_Day_Python_date_time/16_python_datetime.md) | [Day 18 >>](../18_Day_Regular_expressions/18_regular_expressions.md)

18_Day_Regular_expressions/18_regular_expressions.md

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ import re
5959

6060
To find a pattern we use different set of *re* character sets that allows to search for a match in a string.
6161

62-
* *re.match()*: searches only in the beginning of the first line of the string and returns matched objects if found, else returns None.
63-
* *re.search*: Returns a match object if there is one anywhere in the string, including multiline strings.
64-
* *re.findall*: Returns a list containing all matches
65-
* *re.split*: Takes a string, splits it at the match points, returns a list
66-
* *re.sub*: Replaces one or many matches within a string
62+
- *re.match()*: searches only in the beginning of the first line of the string and returns matched objects if found, else returns None.
63+
- *re.search*: Returns a match object if there is one anywhere in the string, including multiline strings.
64+
- *re.findall*: Returns a list containing all matches
65+
- *re.split*: Takes a string, splits it at the match points, returns a list
66+
- *re.sub*: Replaces one or many matches within a string
6767

6868
#### Match
6969

@@ -129,7 +129,7 @@ substring = txt[start:end]
129129
print(substring) # first
130130
```
131131

132-
As you can see, search is much better than match because it can look for the pattern throughout the text. Search returns a match object with a first match that was found, otherwise it returns _None_. A much better *re* function is *findall*. This function checks for the pattern through the whole string and returns all the matches as a list.
132+
As you can see, search is much better than match because it can look for the pattern throughout the text. Search returns a match object with a first match that was found, otherwise it returns *None*. A much better *re* function is *findall*. This function checks for the pattern through the whole string and returns all the matches as a list.
133133

134134
#### Searching for All Matches Using *findall*
135135

@@ -240,38 +240,39 @@ matches = re.findall(regex_pattern, txt)
240240
print(matches) # ['Apple', 'apple']
241241

242242
```
243+
243244
* []: A set of characters
244-
* [a-c] means, a or b or c
245-
* [a-z] means, any letter from a to z
246-
* [A-Z] means, any character from A to Z
247-
* [0-3] means, 0 or 1 or 2 or 3
248-
* [0-9] means any number from 0 to 9
249-
* [A-Za-z0-9] any single character, that is a to z, A to Z or 0 to 9
250-
* \\: uses to escape special characters
251-
* \d means: match where the string contains digits (numbers from 0-9)
252-
* \D means: match where the string does not contain digits
253-
* . : any character except new line character(\n)
254-
* ^: starts with
255-
* r'^substring' eg r'^love', a sentence that starts with a word love
256-
* r'[^abc] means not a, not b, not c.
257-
* $: ends with
258-
* r'substring$' eg r'love$', sentence that ends with a word love
259-
* *: zero or more times
260-
* r'[a]*' means a optional or it can occur many times.
261-
* +: one or more times
262-
* r'[a]+' means at least once (or more)
263-
* ?: zero or one time
264-
* r'[a]?' means zero times or once
265-
* {3}: Exactly 3 characters
266-
* {3,}: At least 3 characters
267-
* {3,8}: 3 to 8 characters
268-
* |: Either or
269-
* r'apple|banana' means either apple or a banana
270-
* (): Capture and group
245+
- [a-c] means, a or b or c
246+
- [a-z] means, any letter from a to z
247+
- [A-Z] means, any character from A to Z
248+
- [0-3] means, 0 or 1 or 2 or 3
249+
- [0-9] means any number from 0 to 9
250+
- [A-Za-z0-9] any single character, that is a to z, A to Z or 0 to 9
251+
- \\: uses to escape special characters
252+
- \d means: match where the string contains digits (numbers from 0-9)
253+
- \D means: match where the string does not contain digits
254+
- . : any character except new line character(\n)
255+
- ^: starts with
256+
- r'^substring' eg r'^love', a sentence that starts with a word love
257+
- r'[^abc] means not a, not b, not c.
258+
- $: ends with
259+
- r'substring$' eg r'love$', sentence that ends with a word love
260+
- *: zero or more times
261+
- r'[a]*' means a optional or it can occur many times.
262+
- +: one or more times
263+
- r'[a]+' means at least once (or more)
264+
- ?: zero or one time
265+
- r'[a]?' means zero times or once
266+
- {3}: Exactly 3 characters
267+
- {3,}: At least 3 characters
268+
- {3,8}: 3 to 8 characters
269+
- |: Either or
270+
- r'apple|banana' means either apple or a banana
271+
- (): Capture and group
271272

272273
![Regular Expression cheat sheet](../images/regex.png)
273274

274-
Let us use examples to clarify the meta characters above
275+
Let us use examples to clarify the meta characters above
275276

276277
### Square Bracket
277278

@@ -367,7 +368,7 @@ print(matches) # ['6', '2019', '8', '2021']
367368

368369
### Cart ^
369370

370-
* Starts with
371+
- Starts with
371372

372373
```py
373374
txt = 'This regular expression example was made on December 6, 2019 and revised on July 8, 2021'
@@ -376,7 +377,7 @@ matches = re.findall(regex_pattern, txt)
376377
print(matches) # ['This']
377378
```
378379

379-
* Negation
380+
- Negation
380381

381382
```py
382383
txt = 'This regular expression example was made on December 6, 2019 and revised on July 8, 2021'
@@ -388,7 +389,9 @@ print(matches) # ['6,', '2019', '8', '2021']
388389
## 💻 Exercises: Day 18
389390

390391
### Exercises: Level 1
392+
391393
1. What is the most frequent word in the following paragraph?
394+
392395
```py
393396
paragraph = 'I love teaching. If you do not love teaching what else can you love. I love Python if you do not love something which can give you all the capabilities to develop an application what else can you love.
394397
```
@@ -423,9 +426,9 @@ print(matches) # ['6,', '2019', '8', '2021']
423426
2. The position of some particles on the horizontal x-axis are -12, -4, -3 and -1 in the negative direction, 0 at origin, 4 and 8 in the positive direction. Extract these numbers from this whole text and find the distance between the two furthest particles.
424427

425428
```py
426-
points = ['-1', '2', '-4', '-3', '-1', '0', '4', '8']
427-
sorted_points = [-4, -3, -1, -1, 0, 2, 4, 8]
428-
distance = 8 -(-4) # 12
429+
points = ['-12', '-4', '-3', '-1', '0', '4', '8']
430+
sorted_points = [-12, -4, -3, -1, -1, 0, 2, 4, 8]
431+
distance = 8 -(-12) # 20
429432
```
430433

431434
### Exercises: Level 2
@@ -453,4 +456,4 @@ distance = 8 -(-4) # 12
453456

454457
🎉 CONGRATULATIONS ! 🎉
455458

456-
[<< Day 17](../17_Day_Exception_handling/17_exception_handling.md) | [Day 19>>](../19_Day_File_handling/19_file_handling.md)
459+
[<< Day 17](../17_Day_Exception_handling/17_exception_handling.md) | [Day 19>>](../19_Day_File_handling/19_file_handling.md)

0 commit comments

Comments
 (0)