Skip to content

Commit cb74247

Browse files
committed
big changes
1 parent b78270f commit cb74247

File tree

15 files changed

+96
-75
lines changed

15 files changed

+96
-75
lines changed

01_Day_Introduction/helloworld.py

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

4-
print(2 + 3) # addition(+)
5-
print(3 - 1) # subtraction(-)
6-
print(2 * 3) # multiplication(*)
4+
print(3 + 2) # addition(+)
5+
print(3 - 2) # subtraction(-)
6+
print(3 * 2) # multiplication(*)
77
print(3 / 2) # division(/)
88
print(3 ** 2) # exponential(**)
99
print(3 % 2) # modulus(%)
@@ -19,3 +19,5 @@
1919
print(type({'name':'Asabeneh'})) # Dictionary
2020
print(type({9.8, 3.14, 2.7})) # Set
2121
print(type((9.8, 3.14, 2.7))) # Tuple
22+
print(type(3 == 3)) # Bool
23+
print(type(3 >= 3)) # Bool

02_Day_Variables_builtin_functions/02_variables_builtin_functions.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ dragon.difference(python) # {'d', 'r', 'a', 'g'}
343343

344344
### Finding Symmetric Difference Between Two Sets
345345

346-
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)
347347

348348
```py
349349
# syntax
@@ -380,7 +380,7 @@ st2.isdisjoint(st1) # False
380380

381381
```py
382382
even_numbers = {0, 2, 4 ,6, 8}
383-
even_numbers = {1, 3, 5, 7, 9}
383+
odd_numbers = {1, 3, 5, 7, 9}
384384
even_numbers.isdisjoint(odd_numbers) # True, because no common item
385385

386386
python = {'p', 'y', 't', 'h', 'o','n'}

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',

09_Day_Conditionals/09_conditionals.md

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
- [If and Or Logical Operators](#if-and-or-logical-operators)
3030
- [💻 Exercises: Day 9](#-exercises-day-9)
3131
- [Exercises: Level 1](#exercises-level-1)
32+
- [Exercises: Level 2](#exercises-level-2)
33+
- [Exercises: Level 3](#exercises-level-3)
3234

3335
# 📘 Day 9
3436

@@ -72,7 +74,7 @@ else:
7274
this part of code runs for false conditions
7375
```
7476

75-
**Example: **
77+
**Example:**
7678

7779
```py
7880
a = 3
@@ -82,7 +84,7 @@ else:
8284
print('A is a positive number')
8385
```
8486

85-
The condition above proves false, therefore the else block was executed. How about if our condition is more than two? We could use _ elif_.
87+
The condition above proves false, therefore the else block was executed. How about if our condition is more than two? We could use _elif_.
8688

8789
### If Elif Else
8890

@@ -99,7 +101,7 @@ else:
99101

100102
```
101103

102-
**Example: **
104+
**Example:**
103105

104106
```py
105107
a = 0
@@ -118,7 +120,7 @@ else:
118120
code if condition else code
119121
```
120122

121-
**Example: **
123+
**Example:**
122124

123125
```py
124126
a = 3
@@ -137,7 +139,7 @@ if condition:
137139
code
138140
```
139141

140-
**Example: **
142+
**Example:**
141143

142144
```py
143145
a = 0
@@ -163,7 +165,7 @@ if condition and condition:
163165
code
164166
```
165167

166-
**Example: **
168+
**Example:**
167169

168170
```py
169171
a = 0
@@ -185,7 +187,7 @@ if condition or condition:
185187
code
186188
```
187189

188-
**Example: **
190+
**Example:**
189191

190192
```py
191193
user = 'James'
@@ -202,53 +204,60 @@ else:
202204

203205
### Exercises: Level 1
204206

205-
1. Get user input using input(“Enter your age: ”). If user is 18 or older, give feedback: You are old enough to drive. If below 18 give feedback to wait for the missing amount of years. Output:
207+
1. Get user input using input(“Enter your age: ”). If user is 18 or older, give feedback: You are old enough to drive. If below 18 give feedback to wait for the missing amount of years. Output:
208+
206209
```sh
207210
Enter your age: 30
208211
You are old enough to learn to drive.
209212
Output:
210213
Enter your age: 15
211214
You need 3 more years to learn to drive.
212215
```
213-
2. Compare the values of my_age and your_age using ifelse. Who is older (me or you)? Use input(“Enter your age: ”) to get the age as input. You can use a nested condition to print 'year' for 1 year difference in age, 'years' for bigger differences, and a custom text if my_age = your_age. Output:
216+
217+
2. Compare the values of my_age and your_age using ifelse. Who is older (me or you)? Use input(“Enter your age: ”) to get the age as input. You can use a nested condition to print 'year' for 1 year difference in age, 'years' for bigger differences, and a custom text if my_age = your_age. Output:
218+
214219
```sh
215220
Enter your age: 30
216221
You are 5 years older than me.
217222
```
218-
3. Get two numbers from the user using input prompt. If a is greater than b return a is greater than b, if a is less b return a is smaller than b, else a is equal to b. Output:
223+
224+
3. Get two numbers from the user using input prompt. If a is greater than b return a is greater than b, if a is less b return a is smaller than b, else a is equal to b. Output:
219225

220226
```sh
221227
Enter number one: 4
222228
Enter number two: 3
223229
4 is greater than 3
224230
```
225231

226-
### Exercises: Level 2
232+
### Exercises: Level 2
227233

228234
1. Write a code which gives grade to students according to theirs scores:
229-
235+
230236
```sh
231237
80-100, A
232238
70-89, B
233239
60-69, C
234240
50-59, D
235241
0-49, F
236242
```
237-
1. Check if the season is Autumn, Winter, Spring or Summer. If the user input is:
243+
244+
1. Check if the season is Autumn, Winter, Spring or Summer. If the user input is:
238245
September, October or November, the season is Autumn.
239246
December, January or February, the season is Winter.
240247
March, April or May, the season is Spring
241248
June, July or August, the season is Summer
242-
2. The following list contains some fruits:
249+
2. The following list contains some fruits:
250+
243251
```sh
244252
fruits = ['banana', 'orange', 'mango', 'lemon']
245253
```
246-
If a fruit doesn't exist in the list add the fruit to the list and print the modified list. If the fruit exists print('That fruit already exist in the list')
247254

248-
### Exercises: Level 3
255+
If a fruit doesn't exist in the list add the fruit to the list and print the modified list. If the fruit exists print('That fruit already exist in the list')
256+
257+
### Exercises: Level 3
249258

250259
1. Here we have a person dictionary. Feel free to modify it!
251-
260+
252261
```py
253262
person={
254263
'first_name': 'Asabeneh',

11_Day_Functions/11_functions.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- [Arbitrary Number of Arguments](#arbitrary-number-of-arguments)
3232
- [Default and Arbitrary Number of Parameters in Functions](#default-and-arbitrary-number-of-parameters-in-functions)
3333
- [Function as a Parameter of Another Function](#function-as-a-parameter-of-another-function)
34+
- [Testimony](#testimony)
3435
- [💻 Exercises: Day 11](#-exercises-day-11)
3536
- [Exercises: Level 1](#exercises-level-1)
3637
- [Exercises: Level 2](#exercises-level-2)
@@ -48,7 +49,7 @@ A function is a reusable block of code or programming statements designed to per
4849

4950
### Declaring and Calling a Function
5051

51-
When we make a function, we call it declaring a function. When we start using the it, we call it *calling* or *invoking* a function. Function can be declared with or without parameters.
52+
When we make a function, we call it declaring a function. When we start using the it, we call it _calling_ or _invoking_ a function. Function can be declared with or without parameters.
5253

5354
```py
5455
# syntax
@@ -374,7 +375,8 @@ print(do_something(square_number, 3)) # 27
374375
🌕 You achieved quite a lot so far. Keep going! You have just completed day 11 challenges and you are 11 steps a head in to your way to greatness. Now do some exercises for your brain and muscles.
375376

376377
## Testimony
377-
Now it is time to express your thoughts about the Author and 30DaysOfPython. You can leave your testimonial on this [link](https://testimonify.herokuapp.com/)
378+
379+
Now it is time to express your thoughts about the Author and 30DaysOfPython. You can leave your testimonial on this [link](https://testimonial-s3sw.onrender.com/)
378380

379381
## 💻 Exercises: Day 11
380382

@@ -401,35 +403,35 @@ print(reverse_list1(["A", "B", "C"]))
401403
11. Declare a function named add_item. It takes a list and an item parameters. It returns a list with the item added at the end.
402404

403405
```py
404-
food_staff = ['Potato', 'Tomato', 'Mango', 'Milk'];
405-
print(add_item(food_staff, 'Meat')) # ['Potato', 'Tomato', 'Mango', 'Milk','Meat'];
406-
numbers = [2, 3, 7, 9];
406+
food_staff = ['Potato', 'Tomato', 'Mango', 'Milk']
407+
print(add_item(food_staff, 'Meat')) # ['Potato', 'Tomato', 'Mango', 'Milk','Meat']
408+
numbers = [2, 3, 7, 9]
407409
print(add_item(numbers, 5)) [2, 3, 7, 9, 5]
408410
```
409411

410412
12. Declare a function named remove_item. It takes a list and an item parameters. It returns a list with the item removed from it.
411413

412414
```py
413-
food_staff = ['Potato', 'Tomato', 'Mango', 'Milk'];
415+
food_staff = ['Potato', 'Tomato', 'Mango', 'Milk']
414416
print(remove_item(food_staff, 'Mango')) # ['Potato', 'Tomato', 'Milk'];
415-
numbers = [2, 3, 7, 9];
417+
numbers = [2, 3, 7, 9]
416418
print(remove_item(numbers, 3)) # [2, 7, 9]
417419
```
418420

419421
13. Declare a function named sum_of_numbers. It takes a number parameter and it adds all the numbers in that range.
420422

421423
```py
422424
print(sum_of_numbers(5)) # 15
423-
print(sum_all_numbers(10)) # 55
424-
print(sum_all_numbers(100)) # 5050
425+
print(sum_of_numbers(10)) # 55
426+
print(sum_of_numbers(100)) # 5050
425427
```
426428

427429
14. Declare a function named sum_of_odds. It takes a number parameter and it adds all the odd numbers in that range.
428430
15. Declare a function named sum_of_even. It takes a number parameter and it adds all the even numbers in that - range.
429431

430432
### Exercises: Level 2
431433

432-
1. Declare a function named evens_and_odds . It takes a positive integer as parameter and it counts number of evens and odds in the number.
434+
1. Declare a function named evens_and_odds . It takes a positive integer as parameter and it counts number of evens and odds in the number.
433435

434436
```py
435437
print(evens_and_odds(100))

13_Day_List_comprehension/13_list_comprehension.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ odd_numbers = [i for i in range(21) if i % 2 != 0] # to generate odd numbers in
8989
print(odd_numbers) # [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
9090
# Filter numbers: let's filter out positive even numbers from the list below
9191
numbers = [-8, -7, -3, -1, 0, 1, 3, 4, 5, 7, 6, 8, 10]
92-
positive_even_numbers = [i for i in range(21) if i % 2 == 0 and i > 0]
92+
positive_even_numbers = [i for i in numbers if i % 2 == 0 and i > 0]
9393
print(positive_even_numbers) # [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
9494

9595
# Flattening a three dimensional array

16_Day_Python_date_time/16_python_datetime.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
- [Using *date* from *datetime*](#using-date-from-datetime)
2626
- [Time Objects to Represent Time](#time-objects-to-represent-time)
2727
- [Difference Between Two Points in Time Using](#difference-between-two-points-in-time-using)
28-
- [Difference Between Two Points in Time Using *timedelata*](#difference-between-two-points-in-time-using-timedelata)
28+
- [Difference Between Two Points in Time Using *timedelta*](#difference-between-two-points-in-time-using-timedelta)
2929
- [💻 Exercises: Day 16](#-exercises-day-16)
3030
# 📘 Day 16
3131

@@ -173,7 +173,7 @@ diff = t2 - t1
173173
print('Time left for new year:', diff) # Time left for new year: 26 days, 23: 01: 00
174174
```
175175

176-
### Difference Between Two Points in Time Using *timedelata*
176+
### Difference Between Two Points in Time Using *timedelta*
177177

178178
```py
179179
from datetime import timedelta

0 commit comments

Comments
 (0)