Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patching all issues #638

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -280,22 +280,22 @@ Number data types in Python:
### Exercises: Level 2

1. Check the data type of all your variables using type() built-in function
1. Using the _len()_ built-in function, find the length of your first name
1. Compare the length of your first name and your last name
1. Declare 5 as num_one and 4 as num_two
1. Add num_one and num_two and assign the value to a variable total
1. Subtract num_two from num_one and assign the value to a variable diff
1. Multiply num_two and num_one and assign the value to a variable product
1. Divide num_one by num_two and assign the value to a variable division
1. Use modulus division to find num_two divided by num_one and assign the value to a variable remainder
1. Calculate num_one to the power of num_two and assign the value to a variable exp
1. Find floor division of num_one by num_two and assign the value to a variable floor_division
1. The radius of a circle is 30 meters.
2. Using the _len()_ built-in function, find the length of your first name
3. Compare the length of your first name and your last name
4. Declare 5 as num_one and 4 as num_two
5. Add num_one and num_two and assign the value to a variable total
6. Subtract num_two from num_one and assign the value to a variable diff
7. Multiply num_two and num_one and assign the value to a variable product
8. Divide num_one by num_two and assign the value to a variable division
9. Use modulus division to find num_two divided by num_one and assign the value to a variable remainder
10. Calculate num_one to the power of num_two and assign the value to a variable exp
11. Find floor division of num_one by num_two and assign the value to a variable floor_division
12. The radius of a circle is 30 meters.
1. Calculate the area of a circle and assign the value to a variable name of _area_of_circle_
2. Calculate the circumference of a circle and assign the value to a variable name of _circum_of_circle_
3. Take radius as user input and calculate the area.
1. Use the built-in input function to get first name, last name, country and age from a user and store the value to their corresponding variable names
1. Run help('keywords') in Python shell or in your file to check for the Python reserved words or keywords
13. Use the built-in input function to get first name, last name, country and age from a user and store the value to their corresponding variable names
14. Run help('keywords') in Python shell or in your file to check for the Python reserved words or keywords

🎉 CONGRATULATIONS ! 🎉

Expand Down
3 changes: 2 additions & 1 deletion 02_Day_Variables_builtin_functions/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@
print('Last name: ', last_name)
print('Country: ', country)
print('Age: ', age)
print('Married: ', is_married)
print('Married: ', is_married)

4 changes: 2 additions & 2 deletions 03_Day_Operators/03_operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ print('a * b = ', product)
print('a / b = ', division)
print('a % b = ', remainder)
print('a // b = ', floor_division)
print('a ** b = ', exponentiation)
print('a ** b = ', exponential)
```

**Example:**
Expand Down Expand Up @@ -174,7 +174,7 @@ print(weight, 'N') # Adding unit to the weight
mass = 75 # in Kg
volume = 0.075 # in cubic meter
density = mass / volume # 1000 Kg/m^3

print(density)
```

### Comparison Operators
Expand Down
14 changes: 7 additions & 7 deletions 04_Day_Strings/04_strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ print(len(full_name)) # 16
In Python and other programming languages \ followed by a character is an escape sequence. Let us see the most common escape characters:

- \n: new line
- \t: Tab means(8 spaces)
- \t: Tab means(8 spaces)
- \\\\: Back slash
- \\': Single quote (')
- \\": Double quote (")
Expand All @@ -101,7 +101,7 @@ 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('Days\tTopics\tExercises') # adding tab space or 4 spaces
print('Day 1\t5\t5')
print('Day 2\t6\t20')
print('Day 3\t5\t23')
Expand All @@ -112,7 +112,7 @@ print('In every programming language it starts with \"Hello, World!\"') # to wri
# output
I hope every one is enjoying the Python Challenge.
Are you ?
Days Topics Exercises
Days Topics Exercises
Day 1 5 5
Day 2 6 20
Day 3 5 23
Expand Down Expand Up @@ -349,7 +349,7 @@ last_name = 'Yetayeh'
age = 250
job = 'teacher'
country = 'Finland'
sentence = 'I am {} {}. I am a {}. I am {} years old. I live in {}.'.format(first_name, last_name, age, job, country)
sentence = 'I am {} {}. I am {} years old. I am a {}. I live in {}.'.format(first_name, last_name, age, job, country)
print(sentence) # I am Asabeneh Yetayeh. I am 250 years old. I am a teacher. I live in Finland.

radius = 10
Expand Down Expand Up @@ -413,7 +413,7 @@ print(challenge.isdecimal()) # False
challenge = '123'
print(challenge.isdecimal()) # True
challenge = '\u00B2'
print(challenge.isdigit()) # False
print(challenge.isdigit()) # True
challenge = '12 3'
print(challenge.isdecimal()) # False, space not allowed
```
Expand Down Expand Up @@ -545,7 +545,7 @@ print(challenge.startswith('thirty')) # False
9. Cut(slice) out the first word of _Coding For All_ string.
10. Check if _Coding For All_ string contains a word Coding using the method index, find or other methods.
11. Replace the word coding in the string 'Coding For All' to Python.
12. Change Python for Everyone to Python for All using the replace method or other methods.
12. Change "Python for Everyone" to "Python for All" using the replace method or other methods.
13. Split the string 'Coding For All' using space as the separator (split()) .
14. "Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon" split the string at the comma.
15. What is the character at index 0 in the string _Coding For All_.
Expand All @@ -561,7 +561,7 @@ print(challenge.startswith('thirty')) # False
25. Slice out the phrase 'because because because' in the following sentence: 'You cannot end a sentence with because because because is a conjunction'
26. Find the position of the first occurrence of the word 'because' in the following sentence: 'You cannot end a sentence with because because because is a conjunction'
27. Slice out the phrase 'because because because' in the following sentence: 'You cannot end a sentence with because because because is a conjunction'
28. Does '\'Coding For All' start with a substring _Coding_?
28. Does 'Coding For All' start with a substring _Coding_?
29. Does 'Coding For All' end with a substring _coding_?
30. '   Coding For All      '  , remove the left and right trailing spaces in the given string.
31. Which one of the following variables return True when we use the method isidentifier():
Expand Down
14 changes: 7 additions & 7 deletions 04_Day_Strings/day_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
print(len(first_name)) # 8
print(len(last_name)) # 7
print(len(first_name) > len(last_name)) # True
print(len(full_name)) # 15
print(len(full_name)) # 16

#### Unpacking characters
language = 'Python'
Expand Down Expand Up @@ -152,8 +152,8 @@

# isalpha(): Checks if all characters are alphabets

challenge = 'thirty days of python'
print(challenge.isalpha()) # True
challenge = 'thirty days of python' # space is not in alphabet
print(challenge.isalpha()) # False
num = '123'
print(num.isalpha()) # False

Expand All @@ -168,7 +168,7 @@
challenge = 'Thirty'
print(challenge.isdigit()) # False
challenge = '30'
print(challenge.digit()) # True
print(challenge.isdigit()) # True

# isdecimal():Checks decimal characters

Expand Down Expand Up @@ -210,13 +210,13 @@
# join(): Returns a concatenated string

web_tech = ['HTML', 'CSS', 'JavaScript', 'React']
result = '#, '.join(web_tech)
print(result) # 'HTML# CSS# JavaScript# React'
result = '# '.join(web_tech)
print(result) # 'HTML# CSS# JavaScript# React'

# strip(): Removes both leading and trailing characters

challenge = ' thirty days of python '
print(challenge.strip('y')) # 5
print(challenge.strip()) # 'thirty days of python'

# replace(): Replaces substring inside

Expand Down
4 changes: 2 additions & 2 deletions 05_Day_Lists/05_lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fruits = ['banana', 'orange', 'mango', 'lemon'] # list of fr
vegetables = ['Tomato', 'Potato', 'Cabbage','Onion', 'Carrot'] # list of vegetables
animal_products = ['milk', 'meat', 'butter', 'yoghurt'] # list of animal products
web_techs = ['HTML', 'CSS', 'JS', 'React','Redux', 'Node', 'MongDB'] # list of web technologies
countries = ['Finland', 'Estonia', 'Denmark', 'Sweden', 'Norway']
countries = ['Finland', 'Estonia', 'Denmark', 'Sweden', 'Norway']

# Print the lists and its length
print('Fruits:', fruits)
Expand Down Expand Up @@ -190,7 +190,7 @@ print(tenth) # 10
# Third Example about unpacking list
countries = ['Germany', 'France','Belgium','Sweden','Denmark','Finland','Norway','Iceland','Estonia']
gr, fr, bg, sw, *scandic, es = countries
print(gr)
print(gr)
print(fr)
print(bg)
print(sw)
Expand Down
4 changes: 2 additions & 2 deletions 06_Day_Tuples/06_tuples.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ len(tpl)

- Positive Indexing
Similar to the list data type we use positive or negative indexing to access tuple items.
![Accessing tuple items](../images/tuples_index.png)
![Accessing tuple items](../images/tuples_incdex.png)

```py
# Syntax
Expand All @@ -93,7 +93,7 @@ len(tpl)
first_fruit = fruits[0]
second_fruit = fruits[1]
last_index =len(fruits) - 1
last_fruit = fruits[las_index]
last_fruit = fruits[last_index]
```

- Negative indexing
Expand Down
16 changes: 8 additions & 8 deletions 07_Day_Sets/07_sets.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,18 +411,18 @@ age = [22, 19, 24, 25, 26, 24, 25, 24]
### Exercises: Level 2

1. Join A and B
1. Find A intersection B
1. Is A subset of B
1. Are A and B disjoint sets
1. Join A with B and B with A
1. What is the symmetric difference between A and B
1. Delete the sets completely
2. Find A intersection B
3. Is A subset of B
4. Are A and B disjoint sets
5. Join A with B and B with A
6. What is the symmetric difference between A and B
7. Delete the sets completely

### Exercises: Level 3

1. Convert the ages to a set and compare the length of the list and the set, which one is bigger?
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.
2. Explain the difference between the following data types: string, list, tuple and set
3. _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 ! 🎉

Expand Down
2 changes: 1 addition & 1 deletion 08_Day_Dictionaries/08_dictionaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ person = {
}
print(person.get('first_name')) # Asabeneh
print(person.get('country')) # Finland
print(person.get('skills')) #['HTML','CSS','JavaScript', 'React', 'Node', 'MongoDB', 'Python']
print(person.get('skills')) #['JavaScript', 'React', 'Node', 'MongoDB', 'Python']
print(person.get('city')) # None
```

Expand Down
4 changes: 2 additions & 2 deletions 09_Day_Conditionals/09_conditionals.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ Enter number two: 3
0-49, F
```

1. Check if the season is Autumn, Winter, Spring or Summer. If the user input is:
2. Get the month from user input then check if the season is Autumn, Winter, Spring or Summer. If the user input is:
September, October or November, the season is Autumn.
December, January or February, the season is Winter.
March, April or May, the season is Spring
June, July or August, the season is Summer
2. The following list contains some fruits:
3. The following list contains some fruits:

```sh
fruits = ['banana', 'orange', 'mango', 'lemon']
Expand Down
6 changes: 3 additions & 3 deletions 10_Day_Loops/10_loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ for number in range(6):
The sum of all numbers is 5050.
```

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

```sh
The sum of all evens is 2550. And the sum of all odds is 2500.
Expand All @@ -450,8 +450,8 @@ for number in range(6):
### Exercises: Level 3

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_.
1. This is a fruit list, ['banana', 'orange', 'mango', 'lemon'] reverse the order using loop.
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.
2. This is a fruit list, ['banana', 'orange', 'mango', 'lemon'] reverse the order using loop.
3. 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.
1. What are the total number of languages in the data
2. Find the ten most spoken languages from the data
3. Find the 10 most populated countries in the world
Expand Down
25 changes: 12 additions & 13 deletions 11_Day_Functions/11_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def sum_of_numbers(n):
total = 0
for i in range(n+1):
total+=i
print(total)
return total
print(sum_of_numbers(10)) # 55
print(sum_of_numbers(100)) # 5050
```
Expand Down Expand Up @@ -182,7 +182,7 @@ print('Sum of two numbers: ', sum_two_numbers(1, 9))

def calculate_age (current_year, birth_year):
age = current_year - birth_year
return age;
return age

print('Age: ', calculate_age(2021, 1819))

Expand Down Expand Up @@ -213,12 +213,12 @@ def print_fullname(firstname, lastname):
space = ' '
full_name = firstname + space + lastname
print(full_name)
print(print_fullname(firstname = 'Asabeneh', lastname = 'Yetayeh'))
print_fullname(firstname = 'Asabeneh', lastname = 'Yetayeh')

def add_two_numbers (num1, num2):
total = num1 + num2
print(total)
print(add_two_numbers(num2 = 3, num1 = 2)) # Order does not matter
return total
print(add_two_numbers(num2 = 3, num1 = 2)) # Order does not matter
```

### Function Returning a Value - Part 2
Expand Down Expand Up @@ -252,7 +252,7 @@ print(add_two_numbers(2, 3))

def calculate_age (current_year, birth_year):
age = current_year - birth_year
return age;
return age
print('Age: ', calculate_age(2019, 1819))
```

Expand All @@ -262,7 +262,6 @@ print('Age: ', calculate_age(2019, 1819))
```py
def is_even (n):
if n % 2 == 0:
print('even')
return True # return stops further execution of the function, similar to break
return False
print(is_even(10)) # True
Expand Down Expand Up @@ -316,7 +315,7 @@ print(generate_full_name('David','Smith'))

def calculate_age (birth_year,current_year = 2021):
age = current_year - birth_year
return age;
return age
print('Age: ', calculate_age(1821))

def weight_of_object (mass, gravity = 9.81):
Expand Down Expand Up @@ -357,8 +356,8 @@ print(sum_all_nums(2, 3, 5)) # 10
def generate_groups (team,*args):
print(team)
for i in args:
print(i)
print(generate_groups('Team-1','Asabeneh','Brook','David','Eyob'))
print(i)
generate_groups('Team-1','Asabeneh','Brook','David','Eyob')
```

### Function as a Parameter of Another Function
Expand All @@ -369,7 +368,7 @@ def square_number (n):
return n * n
def do_something(f, x):
return f(x)
print(do_something(square_number, 3)) # 27
print(do_something(square_number, 3)) # 9
```

🌕 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.
Expand All @@ -395,7 +394,7 @@ Now it is time to express your thoughts about the Author and 30DaysOfPython. You
```py
print(reverse_list([1, 2, 3, 4, 5]))
# [5, 4, 3, 2, 1]
print(reverse_list1(["A", "B", "C"]))
print(reverse_list(["A", "B", "C"]))
# ["C", "B", "A"]
```

Expand All @@ -406,7 +405,7 @@ print(reverse_list1(["A", "B", "C"]))
food_staff = ['Potato', 'Tomato', 'Mango', 'Milk']
print(add_item(food_staff, 'Meat')) # ['Potato', 'Tomato', 'Mango', 'Milk','Meat']
numbers = [2, 3, 7, 9]
print(add_item(numbers, 5)) [2, 3, 7, 9, 5]
print(add_item(numbers, 5)) # [2, 3, 7, 9, 5]
```

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.
Expand Down
Loading