Skip to content

Commit 769dae3

Browse files
authored
Merge branch 'Asabeneh:master' into master
2 parents e667064 + 923a3f6 commit 769dae3

File tree

60 files changed

+39007
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+39007
-156
lines changed

01_Day_Introduction/helloworld.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# Introduction
44
# Day 1 - 30DaysOfPython Challenge
55

6-
print(2 + 3) # addition(+)
7-
print(3 - 1) # subtraction(-)
8-
print(2 * 3) # multiplication(*)
6+
print(3 + 2) # addition(+)
7+
print(3 - 2) # subtraction(-)
8+
print(3 * 2) # multiplication(*)
99
print(3 / 2) # division(/)
1010
print(3 ** 2) # exponential(**)
1111
print(3 % 2) # modulus(%)
@@ -21,3 +21,5 @@
2121
print(type({'name':'Asabeneh'})) # Dictionary
2222
print(type({9.8, 3.14, 2.7})) # Set
2323
print(type((9.8, 3.14, 2.7))) # Tuple
24+
print(type(3 == 3)) # Bool
25+
print(type(3 >= 3)) # Bool

02_Day_Variables_builtin_functions/02_variables_builtin_functions.md

Lines changed: 23 additions & 21 deletions
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
@@ -180,7 +180,7 @@ There are several data types in Python. To identify the data type we use the _ty
180180
## Checking Data types and Casting
181181

182182
- Check Data types: To check the data type of certain data/variable we use the _type_
183-
**Example:**
183+
**Examples:**
184184

185185
```py
186186
# Different python data types
@@ -193,22 +193,22 @@ city= 'Helsinki' # str
193193
age = 250 # int, it is not my real age, don't worry about it
194194

195195
# Printing out types
196-
print(type('Asabeneh')) # str
197-
print(type(first_name)) # str
198-
print(type(10)) # int
199-
print(type(3.14)) # float
200-
print(type(1 + 1j)) # complex
201-
print(type(True)) # bool
202-
print(type([1, 2, 3, 4])) # list
203-
print(type({'name':'Asabeneh','age':250, 'is_married':250})) # dict
204-
print(type((1,2))) # tuple
205-
print(type(zip([1,2],[3,4]))) # set
196+
print(type('Asabeneh')) # str
197+
print(type(first_name)) # str
198+
print(type(10)) # int
199+
print(type(3.14)) # float
200+
print(type(1 + 1j)) # complex
201+
print(type(True)) # bool
202+
print(type([1, 2, 3, 4])) # list
203+
print(type({'name':'Asabeneh'})) # dict
204+
print(type((1,2))) # tuple
205+
print(type(zip([1,2],[3,4]))) # zip
206206
```
207207

208208
- Casting: Converting one data type to another data type. We use _int()_, _float()_, _str()_, _list_, _set_
209209
When we do arithmetic operations string numbers should be first converted to int or float otherwise it will return an error. If we concatenate a number with a string, the number should be first converted to a string. We will talk about concatenation in String section.
210210

211-
**Example:**
211+
**Examples:**
212212

213213
```py
214214
# int to float
@@ -229,8 +229,10 @@ print(num_str) # '10'
229229

230230
# str to int or float
231231
num_str = '10.6'
232-
print('num_int', int(num_str)) # 10
232+
num_float = float(num_str)
233233
print('num_float', float(num_str)) # 10.6
234+
num_int = int(num_float)
235+
print('num_int', int(num_int)) # 10
234236

235237
# str to list
236238
first_name = 'Asabeneh'
@@ -281,13 +283,13 @@ Number data types in Python:
281283
1. Using the _len()_ built-in function, find the length of your first name
282284
1. Compare the length of your first name and your last name
283285
1. Declare 5 as num_one and 4 as num_two
284-
1. Add num_one and num_two and assign the value to a variable total
285-
2. Subtract num_two from num_one and assign the value to a variable diff
286-
3. Multiply num_two and num_one and assign the value to a variable product
287-
4. Divide num_one by num_two and assign the value to a variable division
288-
5. Use modulus division to find num_two divided by num_one and assign the value to a variable remainder
289-
6. Calculate num_one to the power of num_two and assign the value to a variable exp
290-
7. Find floor division of num_one by num_two and assign the value to a variable floor_division
286+
1. Add num_one and num_two and assign the value to a variable total
287+
1. Subtract num_two from num_one and assign the value to a variable diff
288+
1. Multiply num_two and num_one and assign the value to a variable product
289+
1. Divide num_one by num_two and assign the value to a variable division
290+
1. Use modulus division to find num_two divided by num_one and assign the value to a variable remainder
291+
1. Calculate num_one to the power of num_two and assign the value to a variable exp
292+
1. Find floor division of num_one by num_two and assign the value to a variable floor_division
291293
1. The radius of a circle is 30 meters.
292294
1. Calculate the area of a circle and assign the value to a variable name of _area_of_circle_
293295
2. Calculate the circumference of a circle and assign the value to a variable name of _circum_of_circle_

04_Day_Strings/04_strings.md

Lines changed: 10 additions & 9 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
@@ -373,8 +373,9 @@ print(challenge.index(sub_string, 9)) # error
373373
```py
374374
challenge = 'thirty days of python'
375375
sub_string = 'da'
376-
print(challenge.rindex(sub_string)) # 8
376+
print(challenge.rindex(sub_string)) # 7
377377
print(challenge.rindex(sub_string, 9)) # error
378+
print(challenge.rindex('on', 8)) # 19
378379
```
379380

380381
- isalnum(): Checks alphanumeric character

05_Day_Lists/05_lists.md

Lines changed: 4 additions & 4 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
@@ -364,7 +364,7 @@ print(fruits) # []
364364

365365
### Copying a List
366366

367-
It is possible to copy a list by reassigning it to a new variable in the following way: list2 = list1. Now, list2 is a reference of list1, any changes we make in list2 will also modify the original, list2. But there are lots of case in which we do not like to modify the original instead we like to have a different copy. One of way of avoiding the problem above is using _copy()_.
367+
It is possible to copy a list by reassigning it to a new variable in the following way: list2 = list1. Now, list2 is a reference of list1, any changes we make in list2 will also modify the original, list1. But there are lots of case in which we do not like to modify the original instead we like to have a different copy. One of way of avoiding the problem above is using _copy()_.
368368

369369
```py
370370
# syntax
@@ -562,7 +562,7 @@ To sort lists we can use _sort()_ method or _sorted()_ built-in functions. The _
562562
back_end = ['Node','Express', 'MongoDB']
563563
```
564564

565-
27. After joining the lists in question 26. Copy the joined list and assign it to a variable full_stack. Then insert Python and SQL after Redux.
565+
27. After joining the lists in question 26. Copy the joined list and assign it to a variable full_stack, then insert Python and SQL after Redux.
566566

567567
### Exercises: Level 2
568568

07_Day_Sets/07_sets.md

Lines changed: 5 additions & 9 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.
@@ -346,7 +343,7 @@ dragon.difference(python) # {'d', 'r', 'a', 'g'}
346343

347344
### Finding Symmetric Difference Between Two Sets
348345

349-
It returns the the symmetric difference between two sets. It means that it returns a set that contains all items from both sets, except items that are present in both sets, mathematically: (A\B) ∪ (B\A)
346+
It returns the symmetric difference between two sets. It means that it returns a set that contains all items from both sets, except items that are present in both sets, mathematically: (A\B) ∪ (B\A)
350347

351348
```py
352349
# syntax
@@ -383,7 +380,7 @@ st2.isdisjoint(st1) # False
383380

384381
```py
385382
even_numbers = {0, 2, 4 ,6, 8}
386-
even_numbers = {1, 3, 5, 7, 9}
383+
odd_numbers = {1, 3, 5, 7, 9}
387384
even_numbers.isdisjoint(odd_numbers) # True, because no common item
388385

389386
python = {'p', 'y', 't', 'h', 'o','n'}
@@ -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)

08_Day_Dictionaries/08_dictionaries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ person = {
8989
'last_name':'Yetayeh',
9090
'age':250,
9191
'country':'Finland',
92-
'is_marred':True,
92+
'is_married':True,
9393
'skills':['JavaScript', 'React', 'Node', 'MongoDB', 'Python'],
9494
'address':{
9595
'street':'Space street',

0 commit comments

Comments
 (0)