diff --git a/02_Day_Variables_builtin_functions/02_variables_builtin_functions.md b/02_Day_Variables_builtin_functions/02_variables_builtin_functions.md
index d1927f2d..4646285e 100644
--- a/02_Day_Variables_builtin_functions/02_variables_builtin_functions.md
+++ b/02_Day_Variables_builtin_functions/02_variables_builtin_functions.md
@@ -63,7 +63,7 @@ Python Variable Name Rules
- A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and \_ )
- Variable names are case-sensitive (firstname, Firstname, FirstName and FIRSTNAME) are different variables)
-Let us se valid variable names
+Here are some example of valid variable names:
```shell
firstname
diff --git a/04_Day_Strings/04_strings.md b/04_Day_Strings/04_strings.md
index 699e7ca6..5b5648ba 100644
--- a/04_Day_Strings/04_strings.md
+++ b/04_Day_Strings/04_strings.md
@@ -102,10 +102,10 @@ Now, let us see the use of the above escape sequences with examples.
```py
print('I hope everyone is enjoying the Python Challenge.\nAre you ?') # line break
print('Days\tTopics\tExercises') # adding tab space or 4 spaces
-print('Day 1\t3\t5')
-print('Day 2\t3\t5')
-print('Day 3\t3\t5')
-print('Day 4\t3\t5')
+print('Day 1\t5\t5')
+print('Day 2\t6\t20')
+print('Day 3\t5\t23')
+print('Day 4\t1\t35')
print('This is a backslash symbol (\\)') # To write a backslash
print('In every programming language it starts with \"Hello, World!\"') # to write a double quote inside a single quote
@@ -328,16 +328,16 @@ print(challenge.expandtabs(10)) # 'thirty days of python'
```py
challenge = 'thirty days of python'
-print(challenge.find('y')) # 16
-print(challenge.find('th')) # 17
+print(challenge.find('y')) # 5
+print(challenge.find('th')) # 0
```
- rfind(): Returns the index of the last occurrence of a substring, if not found returns -1
```py
challenge = 'thirty days of python'
-print(challenge.rfind('y')) # 5
-print(challenge.rfind('th')) # 1
+print(challenge.rfind('y')) # 16
+print(challenge.rfind('th')) # 17
```
- format(): formats string into a nicer output
diff --git a/05_Day_Lists/05_lists.md b/05_Day_Lists/05_lists.md
index b3fb49f6..fea7f515 100644
--- a/05_Day_Lists/05_lists.md
+++ b/05_Day_Lists/05_lists.md
@@ -163,7 +163,7 @@ print(second_last) # mango
### Unpacking List Items
```py
-lst = ['item','item2','item3', 'item4', 'item5']
+lst = ['item1','item2','item3', 'item4', 'item5']
first_item, second_item, third_item, *rest = lst
print(first_item) # item1
print(second_item) # item2
@@ -175,7 +175,7 @@ print(rest) # ['item4', 'item5']
```py
# First Example
fruits = ['banana', 'orange', 'mango', 'lemon','lime','apple']
-first_fruit, second_fruit, third_fruit, *rest = lst
+first_fruit, second_fruit, third_fruit, *rest = fruits
print(first_fruit) # banana
print(second_fruit) # orange
print(third_fruit) # mango
diff --git a/07_Day_Sets/07_sets.md b/07_Day_Sets/07_sets.md
index d47a662a..12bc2ca4 100644
--- a/07_Day_Sets/07_sets.md
+++ b/07_Day_Sets/07_sets.md
@@ -48,14 +48,12 @@ Set is a collection of items. Let me take you back to your elementary or high sc
### Creating a Set
-We use curly brackets, {} to create a set or the *set()* built-in function.
+We use the _set()_ built-in function.
- Creating an empty set
```py
# syntax
-st = {}
-# or
st = set()
```
@@ -80,7 +78,7 @@ We use **len()** method to find the length of a set.
```py
# syntax
st = {'item1', 'item2', 'item3', 'item4'}
-len(set)
+len(st)
```
**Example:**
@@ -131,7 +129,7 @@ fruits.add('lime')
```
- Add multiple items using _update()_
- The *update()* allows to add multiple items to a set. The *update()* takes a list argument.
+ The _update()_ allows to add multiple items to a set. The _update()_ takes a list argument.
```py
# syntax
@@ -174,7 +172,6 @@ fruits = {'banana', 'orange', 'mango', 'lemon'}
removed_item = fruits.pop()
```
-
### Clearing Items in a Set
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]
1. Explain the difference between the following data types: string, list, tuple and set
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.
-
🎉 CONGRATULATIONS ! 🎉
[<< Day 6](../06_Day_Tuples/06_tuples.md) | [Day 8 >>](../08_Day_Dictionaries/08_dictionaries.md)
diff --git a/10_Day_Loops/10_loops.md b/10_Day_Loops/10_loops.md
index e80a392d..f03265a9 100644
--- a/10_Day_Loops/10_loops.md
+++ b/10_Day_Loops/10_loops.md
@@ -127,6 +127,7 @@ while condition:
count = 0
while count < 5:
if count == 3:
+ count = count + 1
continue
print(count)
count = count + 1
diff --git a/17_Day_Exception_handling/17_exception_handling.md b/17_Day_Exception_handling/17_exception_handling.md
index b9378ed9..b9d53350 100644
--- a/17_Day_Exception_handling/17_exception_handling.md
+++ b/17_Day_Exception_handling/17_exception_handling.md
@@ -16,6 +16,7 @@
[<< Day 16](../16_Day_Python_date_time/16_python_datetime.md) | [Day 18 >>](../18_Day_Regular_expressions/18_regular_expressions.md)
![30DaysOfPython](../images/30DaysOfPython_banner3@2x.png)
+
- [📘 Day 17](#-day-17)
- [Exception Handling](#exception-handling)
- [Packing and Unpacking Arguments in Python](#packing-and-unpacking-arguments-in-python)
@@ -128,6 +129,7 @@ I alway run.
```
It is also shorten the above code as follows:
+
```py
try:
name = input('Enter your name:')
@@ -223,9 +225,9 @@ print(sum_all(1, 2, 3, 4, 5, 6, 7)) # 28
def packing_person_info(**kwargs):
# check the type of kwargs and it is a dict type
# print(type(kwargs))
- # Printing dictionary items
+ # Printing dictionary items
for key in kwargs:
- print("{key} = {kwargs[key]}")
+ print(f"{key} = {kwargs[key]}")
return kwargs
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
```py
lst_one = [1, 2, 3]
lst_two = [4, 5, 6, 7]
-lst = [0, *list_one, *list_two]
+lst = [0, *lst_one, *lst_two]
print(lst) # [0, 1, 2, 3, 4, 5, 6, 7]
country_lst_one = ['Finland', 'Sweden', 'Norway']
country_lst_two = ['Denmark', 'Iceland']
@@ -257,7 +259,7 @@ print(nordic_countries) # ['Finland', 'Sweden', 'Norway', 'Denmark', 'Iceland']
## Enumerate
-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.
+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.
```py
for index, item in enumerate([20, 30, 40]):
@@ -301,4 +303,4 @@ print(fruits_and_veges)
🎉 CONGRATULATIONS ! 🎉
-[<< Day 16](../16_Day_Python_date_time/16_python_datetime.md) | [Day 18 >>](../18_Day_Regular_expressions/18_regular_expressions.md)
\ No newline at end of file
+[<< Day 16](../16_Day_Python_date_time/16_python_datetime.md) | [Day 18 >>](../18_Day_Regular_expressions/18_regular_expressions.md)
diff --git a/18_Day_Regular_expressions/18_regular_expressions.md b/18_Day_Regular_expressions/18_regular_expressions.md
index f8366d26..4492c91b 100644
--- a/18_Day_Regular_expressions/18_regular_expressions.md
+++ b/18_Day_Regular_expressions/18_regular_expressions.md
@@ -59,11 +59,11 @@ import re
To find a pattern we use different set of *re* character sets that allows to search for a match in a string.
-* *re.match()*: searches only in the beginning of the first line of the string and returns matched objects if found, else returns None.
-* *re.search*: Returns a match object if there is one anywhere in the string, including multiline strings.
-* *re.findall*: Returns a list containing all matches
-* *re.split*: Takes a string, splits it at the match points, returns a list
-* *re.sub*: Replaces one or many matches within a string
+- *re.match()*: searches only in the beginning of the first line of the string and returns matched objects if found, else returns None.
+- *re.search*: Returns a match object if there is one anywhere in the string, including multiline strings.
+- *re.findall*: Returns a list containing all matches
+- *re.split*: Takes a string, splits it at the match points, returns a list
+- *re.sub*: Replaces one or many matches within a string
#### Match
@@ -129,7 +129,7 @@ substring = txt[start:end]
print(substring) # first
```
-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.
+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.
#### Searching for All Matches Using *findall*
@@ -240,38 +240,39 @@ matches = re.findall(regex_pattern, txt)
print(matches) # ['Apple', 'apple']
```
+
* []: A set of characters
- * [a-c] means, a or b or c
- * [a-z] means, any letter from a to z
- * [A-Z] means, any character from A to Z
- * [0-3] means, 0 or 1 or 2 or 3
- * [0-9] means any number from 0 to 9
- * [A-Za-z0-9] any single character, that is a to z, A to Z or 0 to 9
-* \\: uses to escape special characters
- * \d means: match where the string contains digits (numbers from 0-9)
- * \D means: match where the string does not contain digits
-* . : any character except new line character(\n)
-* ^: starts with
- * r'^substring' eg r'^love', a sentence that starts with a word love
- * r'[^abc] means not a, not b, not c.
-* $: ends with
- * r'substring$' eg r'love$', sentence that ends with a word love
-* *: zero or more times
- * r'[a]*' means a optional or it can occur many times.
-* +: one or more times
- * r'[a]+' means at least once (or more)
-* ?: zero or one time
- * r'[a]?' means zero times or once
-* {3}: Exactly 3 characters
-* {3,}: At least 3 characters
-* {3,8}: 3 to 8 characters
-* |: Either or
- * r'apple|banana' means either apple or a banana
-* (): Capture and group
+ - [a-c] means, a or b or c
+ - [a-z] means, any letter from a to z
+ - [A-Z] means, any character from A to Z
+ - [0-3] means, 0 or 1 or 2 or 3
+ - [0-9] means any number from 0 to 9
+ - [A-Za-z0-9] any single character, that is a to z, A to Z or 0 to 9
+- \\: uses to escape special characters
+ - \d means: match where the string contains digits (numbers from 0-9)
+ - \D means: match where the string does not contain digits
+- . : any character except new line character(\n)
+- ^: starts with
+ - r'^substring' eg r'^love', a sentence that starts with a word love
+ - r'[^abc] means not a, not b, not c.
+- $: ends with
+ - r'substring$' eg r'love$', sentence that ends with a word love
+- *: zero or more times
+ - r'[a]*' means a optional or it can occur many times.
+- +: one or more times
+ - r'[a]+' means at least once (or more)
+- ?: zero or one time
+ - r'[a]?' means zero times or once
+- {3}: Exactly 3 characters
+- {3,}: At least 3 characters
+- {3,8}: 3 to 8 characters
+- |: Either or
+ - r'apple|banana' means either apple or a banana
+- (): Capture and group
![Regular Expression cheat sheet](../images/regex.png)
-Let us use examples to clarify the meta characters above
+Let us use examples to clarify the meta characters above
### Square Bracket
@@ -367,7 +368,7 @@ print(matches) # ['6', '2019', '8', '2021']
### Cart ^
-* Starts with
+- Starts with
```py
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)
print(matches) # ['This']
```
-* Negation
+- Negation
```py
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']
## 💻 Exercises: Day 18
### Exercises: Level 1
+
1. What is the most frequent word in the following paragraph?
+
```py
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.
```
@@ -423,9 +426,9 @@ print(matches) # ['6,', '2019', '8', '2021']
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.
```py
-points = ['-1', '2', '-4', '-3', '-1', '0', '4', '8']
-sorted_points = [-4, -3, -1, -1, 0, 2, 4, 8]
-distance = 8 -(-4) # 12
+points = ['-12', '-4', '-3', '-1', '0', '4', '8']
+sorted_points = [-12, -4, -3, -1, -1, 0, 2, 4, 8]
+distance = 8 -(-12) # 20
```
### Exercises: Level 2
@@ -453,4 +456,4 @@ distance = 8 -(-4) # 12
🎉 CONGRATULATIONS ! 🎉
-[<< Day 17](../17_Day_Exception_handling/17_exception_handling.md) | [Day 19>>](../19_Day_File_handling/19_file_handling.md)
\ No newline at end of file
+[<< Day 17](../17_Day_Exception_handling/17_exception_handling.md) | [Day 19>>](../19_Day_File_handling/19_file_handling.md)
diff --git a/readme.md b/readme.md
index 8af2c85e..5bd0eb88 100644
--- a/readme.md
+++ b/readme.md
@@ -1,4 +1,4 @@
-# 🐍 30 Days Of Python
+# 🐍 30 Days Of Python
|# Day | Topics |
|------|:---------------------------------------------------------:|
@@ -15,11 +15,11 @@
| 11 | [Functions](./11_Day_Functions/11_functions.md)|
| 12 | [Modules](./12_Day_Modules/12_modules.md)|
| 13 | [List Comprehension](./13_Day_List_comprehension/13_list_comprehension.md)|
-| 14 | [Higher Order Functions](./14_Day_Higher_order_functions/14_higher_order_functions.md)|
-| 15 | [Python Type Errors](./15_Day_Python_type_errors/15_python_type_errors.md)|
-| 16 | [Python Date time](./16_Day_Python_date_time/16_python_datetime.md) |
-| 17 | [Exception Handling](./17_Day_Exception_handling/17_exception_handling.md)|
-| 18 | [Regular Expressions](./18_Day_Regular_expressions/18_regular_expressions.md)|
+| 14 | [Higher Order Functions](./14_Day_Higher_order_functions/14_higher_order_functions.md)|
+| 15 | [Python Type Errors](./15_Day_Python_type_errors/15_python_type_errors.md)|
+| 16 | [Python Date time](./16_Day_Python_date_time/16_python_datetime.md) |
+| 17 | [Exception Handling](./17_Day_Exception_handling/17_exception_handling.md)|
+| 18 | [Regular Expressions](./18_Day_Regular_expressions/18_regular_expressions.md)|
| 19 | [File Handling](./19_Day_File_handling/19_file_handling.md)|
| 20 | [Python Package Manager](./20_Day_Python_package_manager/20_python_package_manager.md)|
| 21 | [Classes and Objects](./21_Day_Classes_and_objects/21_classes_and_objects.md)|
@@ -55,7 +55,6 @@
-
[Day 2 >>](./02_Day_Variables_builtin_functions/02_variables_builtin_functions.md)
![30DaysOfPython](./images/30DaysOfPython_banner3@2x.png)
@@ -99,11 +98,11 @@ If you would like to actively engage in the challenge, you may join the [30DaysO
## Introduction
-Python is a high-level programming language for general-purpose programming. It is an open source, interpreted, objected-oriented programming language. Python was created by a Dutch programmer, Guido van Rossum. The name of Python programming language was derived from a British sketch comedy series, *Month Python's Flying Circus*. The first version was released on February 20, 1991. This 30 days of Python challenge will help you learn the latest version of Python, Python 3 step by step. The topics are broken down into 30 days, where each day contains several topics with easy-to-understand explanations, real-world examples, many hands on exercises and projects.
+Python is a high-level programming language for general-purpose programming. It is an open source, interpreted, objected-oriented programming language. Python was created by a Dutch programmer, Guido van Rossum. The name of Python programming language was derived from a British sketch comedy series, _Monty Python's Flying Circus_. The first version was released on February 20, 1991. This 30 days of Python challenge will help you learn the latest version of Python, Python 3 step by step. The topics are broken down into 30 days, where each day contains several topics with easy-to-understand explanations, real-world examples, many hands on exercises and projects.
This challenge is designed for beginners and professionals who want to learn python programming language. It may take 30 to 100 days to complete the challenge, people who actively participate on the telegram group have a high probability of completing the challenge.
-This challenge is easy to read, written in conversational English, engaging, motivating and at the same time, it is very demanding. You need to allocate much time to finish this challenge. If you are a visual learner, you may get the video lesson on Washera YouTube channel. You may start from [Python for Absolute Beginners video](https://youtu.be/OCCWZheOesI). Subscribe the channel, comment and ask questions on YouTube vidoes and be proactive, the author will eventually notice you.
+This challenge is easy to read, written in conversational English, engaging, motivating and at the same time, it is very demanding. You need to allocate much time to finish this challenge. If you are a visual learner, you may get the video lesson on Washera YouTube channel. You may start from [Python for Absolute Beginners video](https://youtu.be/OCCWZheOesI). Subscribe the channel, comment and ask questions on YouTube vidoes and be proactive, the author will eventually notice you.
The author likes to hear your opinion about the challenge, share the author by expressing your thoughts about the 30DaysOfPython challenge. You can leave your testimonial on this [link](https://testimonial-vdzd.onrender.com/)
@@ -166,11 +165,11 @@ Python will give you results if you write scripts that Python understands, if no
As you can see from the returned error, Python is so clever that it knows the mistake we made and which was _Syntax Error: invalid syntax_. Using x as multiplication in Python is a syntax error because (x) is not a valid syntax in Python. Instead of (**x**) we use asterisk (*) for multiplication. The returned error clearly shows what to fix.
-The process of identifying and removing errors from a program is called *debugging*. Let us debug it by putting * in place of **x**.
+The process of identifying and removing errors from a program is called _debugging_. Let us debug it by putting * in place of **x**.
![Fixing Syntax Error](./images/fixing_syntax_error.png)
-Our bug was fixed, the code ran and we got a result we were expecting. As a programmer you will see such kind of errors on daily basis. It is good to know how to debug. To be good at debugging you should understand what kind of errors you are facing. Some of the Python errors you may encounter are *SyntaxError*, *IndexError*, *NameError*, *ModuleNotFoundError*, *KeyError*, *ImportError*, *AttributeError*, *TypeError*, *ValueError*, *ZeroDivisionError* etc. We will see more about different Python **_error types_** in later sections.
+Our bug was fixed, the code ran and we got a result we were expecting. As a programmer you will see such kind of errors on daily basis. It is good to know how to debug. To be good at debugging you should understand what kind of errors you are facing. Some of the Python errors you may encounter are _SyntaxError_, _IndexError_, _NameError_, _ModuleNotFoundError_, _KeyError_, _ImportError_, _AttributeError_, _TypeError_, _ValueError_, _ZeroDivisionError_ etc. We will see more about different Python **_error types_** in later sections.
Let us practice more how to use Python interactive shell. Go to your terminal or command prompt and write the word **python**.
@@ -180,11 +179,11 @@ The Python interactive shell is opened. Let us do some basic mathematical operat
Let us do some maths first before we write any Python code:
-- 2 + 3 = 5
-- 3 - 2 = 1
-- 3 \* 2 = 6
-- 3 / 2 = 1.5
-- 3 ^ 2 = 3 x 3 = 9
+- 2 + 3 is 5
+- 3 - 2 is 1
+- 3 \* 2 is 6
+- 3 / 2 is 1.5
+- 3 ** 2 is the same as 3 * 3
In python we have the following additional operations:
@@ -330,7 +329,7 @@ Python list is an ordered collection which allows to store different data type i
#### Dictionary
-A Python dictionary object is an unordered collection of data in a key value pair format.
+A Python dictionary object is an unordered collection of data in a key value pair format.
**Example:**
@@ -382,7 +381,7 @@ To check the data type of certain data/variable we use the **type** function. In
First open your project folder, 30DaysOfPython. If you don't have this folder, create a folder name called 30DaysOfPython. Inside this folder, create a file called helloworld.py. Now, let's do what we did on python interactive shell using visual studio code.
-The Python interactive shell was printing without using **print** but on visual studio code to see our result we should use a built in function *print(). The *print()* built-in function takes one or more arguments as follows *print('arument1', 'argument2', 'argument3')*. See the examples below.
+The Python interactive shell was printing without using **print** but on visual studio code to see our result we should use a built in function _print(). The _print()_ built-in function takes one or more arguments as follows _print('arument1', 'argument2', 'argument3')_. See the examples below.
**Example:**
@@ -410,7 +409,7 @@ print(type({9.8, 3.14, 2.7})) # Set
print(type((9.8, 3.14, 2.7))) # Tuple
```
-To run the python file check the image below. You can run the python file either by running the green button on Visual Studio Code or by typing *python helloworld.py* in the terminal .
+To run the python file check the image below. You can run the python file either by running the green button on Visual Studio Code or by typing _python helloworld.py_ in the terminal .
![Running python script](./images/running_python_script.png)
@@ -455,4 +454,4 @@ To run the python file check the image below. You can run the python file either
🎉 CONGRATULATIONS ! 🎉
-[Day 2 >>](./02_Day_Variables_builtin_functions/02_variables_builtin_functions.md)
\ No newline at end of file
+[Day 2 >>](./02_Day_Variables_builtin_functions/02_variables_builtin_functions.md)