Skip to content

Commit 6c6ce01

Browse files
authored
Merge branch 'master' into pep8-styling
2 parents dc039d2 + 48e543a commit 6c6ce01

File tree

133 files changed

+55313
-1411
lines changed

Some content is hidden

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

133 files changed

+55313
-1411
lines changed

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
github: [Asabeneh]
2+
thanks_dev:
3+
custom: []

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ flask_project/venv/include/
1616
flask_project/ven/lib
1717
numpy.ipynb
1818
.ipynb_checkpoints
19-
.vscode/
19+
.vscode/
20+
*~
21+
test.py

01_Day_Introduction/helloworld.py

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

4+
print("Hello World!") # print hello world
5+
46
print(2 + 3) # addition(+)
57
print(3 - 1) # subtraction(-)
68
print(2 * 3) # multiplication(*)
9+
print(3 + 2) # addition(+)
10+
print(3 - 2) # subtraction(-)
11+
print(3 * 2) # multiplication(*)
712
print(3 / 2) # division(/)
813
print(3 ** 2) # exponential(**)
914
print(3 % 2) # modulus(%)

02_Day_Variables_builtin_functions/02_variables_builtin_functions.md

Lines changed: 67 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99

1010
<sub>Author:
1111
<a href="https://www.linkedin.com/in/asabeneh/" target="_blank">Asabeneh Yetayeh</a><br>
12-
<small> First Edition: Nov 22 - Dec 22, 2019</small>
12+
<small> Second Edition: July, 2021</small>
1313
</sub>
1414

15-
</div>
1615
</div>
1716

1817
[<< Day 1](../readme.md) | [Day 3 >>](../03_Day_Operators/03_operators.md)
@@ -22,6 +21,7 @@
2221
- [📘 Day 2](#-day-2)
2322
- [Built in functions](#built-in-functions)
2423
- [Variables](#variables)
24+
- [Declaring Multiple Variable in a Line](#declaring-multiple-variable-in-a-line)
2525
- [Data Types](#data-types)
2626
- [Checking Data types and Casting](#checking-data-types-and-casting)
2727
- [Numbers](#numbers)
@@ -33,36 +33,37 @@
3333

3434
## Built in functions
3535

36-
In python we have lots of built-in functions. Built-in functions are globally available for your use. Some of the most commonly used python built-in functions are the following: _print()_, _len()_, _type()_, _int()_, _float()_, _str()_, _input()_, _list()_, _dict()_, _min()_, _max()_, _sum()_, _sorted()_, _open()_, _file()_, _help()_, and _dir()_. In the following table you will see an exhaustive list of python built-in functions taken from [python documentation](https://docs.python.org/2/library/functions.html).
36+
In Python we have lots of built-in functions. Built-in functions are globally available for your use that mean you can make use of the built-in functions without importing or configuring. Some of the most commonly used Python built-in functions are the following: _print()_, _len()_, _type()_, _int()_, _float()_, _str()_, _input()_, _list()_, _dict()_, _min()_, _max()_, _sum()_, _sorted()_, _open()_, _file()_, _help()_, and _dir()_. In the following table you will see an exhaustive list of Python built-in functions taken from [python documentation](https://docs.python.org/3/library/functions.html).
3737

3838
![Built-in Functions](../images/builtin-functions.png)
3939

40-
Let's open the python shell and start using some of the most common built-in functions.
40+
Let us open the Python shell and start using some of the most common built-in functions.
4141

4242
![Built-in functions](../images/builtin-functions_practice.png)
4343

44-
Let's practice more by using different built-in functions
44+
Let us practice more by using different built-in functions
4545

4646
![Help and Dir Built in Functions](../images/help_and_dir_builtin.png)
4747

48-
As you can see from the terminal above, python has got reserved words. We do not use reserved words to declare variables or functions. We will cover variables in the next section.
48+
As you can see from the terminal above, Python has got reserved words. We do not use reserved words to declare variables or functions. We will cover variables in the next section.
4949

50-
I believe, by now you are familiar with built-in functions. Let's do one more practice of built-in functions and we will move on to the next section
50+
I believe, by now you are familiar with built-in functions. Let us do one more practice of built-in functions and we will move on to the next section.
5151

5252
![Min Max Sum](../images/builtin-functional-final.png)
5353

5454
## Variables
5555

56-
Variables store data in a computer memory. Mnemonic variables are recommended to use in many programming languages. A variable refers to a memory address in which data is stored.
57-
Number at the beginning, special character, hyphen are not allowed when naming them. A variable can have a short name (like x,y,z), but a more descriptive name (firstname, lastname, age, country) is highly recommended.
56+
Variables store data in a computer memory. Mnemonic variables are recommended to use in many programming languages. A mnemonic variable is a variable name that can be easily remembered and associated. A variable refers to a memory address in which data is stored.
57+
Number at the beginning, special character, hyphen are not allowed when naming a variable. A variable can have a short name (like x, y, z), but a more descriptive name (firstname, lastname, age, country) is highly recommended.
58+
5859
Python Variable Name Rules
5960

6061
- A variable name must start with a letter or the underscore character
6162
- A variable name cannot start with a number
6263
- A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and \_ )
63-
- Variable names are case-sensitive (firstname, Firstname, FirstName and FIRSTNAME are different variables)
64+
- Variable names are case-sensitive (firstname, Firstname, FirstName and FIRSTNAME) are different variables)
6465

65-
Valid variable names
66+
Here are some example of valid variable names:
6667

6768
```shell
6869
firstname
@@ -74,9 +75,10 @@ first_name
7475
last_name
7576
capital_city
7677
_if # if we want to use reserved word as a variable
77-
year_2019
78-
year2019
79-
current_year_2019
78+
year_2021
79+
year2021
80+
current_year_2021
81+
birth_year
8082
num1
8183
num2
8284
```
@@ -85,19 +87,20 @@ Invalid variables names
8587

8688
```shell
8789
first-name
90+
first@name
91+
first$name
8892
num-1
8993
1num
9094
```
9195

92-
We will use standard python variable naming style which has been adopted by many python developers. The example below is an example of standard naming of variables, underscore when the variable name is long.
96+
We will use standard Python variable naming style which has been adopted by many Python developers. Python developers use snake case(snake_case) variable naming convention. We use underscore character after each word for a variable containing more than one word(eg. first_name, last_name, engine_rotation_speed). The example below is an example of standard naming of variables, underscore is required when the variable name is more than one word.
9397

94-
When we assign a certain data type to a variable, it is called variable declaration. For instance in the example below my first name is assigned to a variable first_name. The equal sign is an assignment operator. Assigning means storing data in the variable.
98+
When we assign a certain data type to a variable, it is called variable declaration. For instance in the example below my first name is assigned to a variable first_name. The equal sign is an assignment operator. Assigning means storing data in the variable. The equal sign in Python is not equality as in Mathematics.
9599

96100
_Example:_
97101

98102
```py
99103
# Variables in Python
100-
101104
first_name = 'Asabeneh'
102105
last_name = 'Yetayeh'
103106
country = 'Finland'
@@ -113,17 +116,17 @@ person_info = {
113116
}
114117
```
115118

116-
Let's use _print()_ and _len()_ built in functions. Print function will take multiple arguments. An argument is a value which we pass or put inside the function parenthesis, see the example below.
119+
Let us use the _print()_ and _len()_ built-in functions. Print function takes unlimited number of arguments. An argument is a value which we can be passed or put inside the function parenthesis, see the example below.
117120

118121
**Example:**
119122

120123
```py
121-
print('Hello, World!')
122-
print('Hello',',', 'World','!') # it can take multiple arguments
124+
print('Hello, World!') # The text Hello, World! is an argument
125+
print('Hello',',', 'World','!') # it can take multiple arguments, four arguments have been passed
123126
print(len('Hello, World!')) # it takes only one argument
124127
```
125128

126-
Let's print and also find the length of the variables declared at the top:
129+
Let us print and also find the length of the variables declared at the top:
127130

128131
**Example:**
129132

@@ -142,7 +145,9 @@ print('Skills: ', skills)
142145
print('Person information: ', person_info)
143146
```
144147

145-
Variables can also be declared in one line:
148+
### Declaring Multiple Variable in a Line
149+
150+
Multiple variables can also be declared in one line:
146151

147152
**Example:**
148153

@@ -157,7 +162,7 @@ print('Age: ', age)
157162
print('Married: ', is_married)
158163
```
159164

160-
Getting user input using the _input()_ built-in function. Let's assign the data we get from a user into first_name and age variables.
165+
Getting user input using the _input()_ built-in function. Let us assign the data we get from a user into first_name and age variables.
161166
**Example:**
162167

163168
```py
@@ -170,12 +175,12 @@ print(age)
170175

171176
## Data Types
172177

173-
There are several data types in python. To identify the data type we use the _type_ builtin function. I would like you to focus on understanding different data types very well. When it comes to programming, it is all about data types. I introduced data types at the very beginning and it comes again, because every topic is related to data types. We will cover data types in more detail in their respective sections.
178+
There are several data types in Python. To identify the data type we use the _type_ built-in function. I would like to ask you to focus on understanding different data types very well. When it comes to programming, it is all about data types. I introduced data types at the very beginning and it comes again, because every topic is related to data types. We will cover data types in more detail in their respective sections.
174179

175180
## Checking Data types and Casting
176181

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

180185
```py
181186
# Different python data types
@@ -188,32 +193,31 @@ city= 'Helsinki' # str
188193
age = 250 # int, it is not my real age, don't worry about it
189194

190195
# Printing out types
191-
print(type('Asabeneh')) # str
192-
print(type(first_name)) # str
193-
print(type(10)) # int
194-
print(type(3.14)) # float
195-
print(type(1 + 1j)) # complex
196-
print(type(True)) # bool
197-
print(type([1, 2,3,4])) # list
198-
print(type({'name':'Asabeneh','age':250, 'is_married':250})) # dict
199-
print(type((1,2))) # tuple
200-
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
201206
```
202207

203-
- Casting: Converting one data type to another data type. We use _int()_, _float()_, _str()_, _list_
204-
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 string, the number should be first converted to a string. We will talk about concatenation in String section.
205-
**Example:**
208+
- Casting: Converting one data type to another data type. We use _int()_, _float()_, _str()_, _list_, _set_
209+
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.
210+
211+
**Examples:**
206212

207213
```py
208214
# int to float
209-
210215
num_int = 10
211216
print('num_int',num_int) # 10
212217
num_float = float(num_int)
213218
print('num_float:', num_float) # 10.0
214219

215220
# float to int
216-
217221
gravity = 9.81
218222
print(int(gravity)) # 9
219223

@@ -223,22 +227,25 @@ print(num_int) # 10
223227
num_str = str(num_int)
224228
print(num_str) # '10'
225229

226-
# str to int
230+
# str to int or float
227231
num_str = '10.6'
232+
num_float = float(num_str) # Convert the string to a float first
233+
num_int = int(num_float) # Then convert the float to an integer
228234
print('num_int', int(num_str)) # 10
229235
print('num_float', float(num_str)) # 10.6
236+
num_int = int(num_float)
237+
print('num_int', int(num_int)) # 10
230238

231239
# str to list
232240
first_name = 'Asabeneh'
233-
print(first_name)
234-
print(first_name) # 'Asabeneh'
241+
print(first_name) # 'Asabeneh'
235242
first_name_to_list = list(first_name)
236243
print(first_name_to_list) # ['A', 's', 'a', 'b', 'e', 'n', 'e', 'h']
237244
```
238245

239246
## Numbers
240247

241-
Number data types in python:
248+
Number data types in Python:
242249

243250
1. Integers: Integer(negative, zero and positive) numbers
244251
Example:
@@ -252,7 +259,7 @@ Number data types in python:
252259
Example:
253260
1 + j, 2 + 4j, 1 - 1j
254261

255-
🌕 You are awesome. You have just completed day 2 challenges and you are two steps ahead on your way to greatness. Now do some exercises for your brain and for your muscle.
262+
🌕 You are awesome. You have just completed day 2 challenges and you are two steps ahead on your way to greatness. Now do some exercises for your brain and muscles.
256263

257264
## 💻 Exercises - Day 2
258265

@@ -275,22 +282,22 @@ Number data types in python:
275282
### Exercises: Level 2
276283

277284
1. Check the data type of all your variables using type() built-in function
278-
1. Using the _len()_ built-in function find the length of your first name
279-
1. Compare the length of your first name and your last name
280-
1. Declare 5 as num_one and 4 as num_two
281-
1. Add num_one and num_two and assign the value to a variable \_total
282-
2. Subtract num_two from num_one and assign the value to a variable \_diff
283-
3. Multiply num_two and num_one and assign the value to a variable \_product
284-
4. Divide num_one by num_two and assign the value to a variable \_division
285-
5. Use modulus division to find num_two divided by num_one and assign the value to a variable \_remainder
286-
6. Calculate num_one to the power of num_two and assign the value to a variable \_exp
287-
7. Find floor division of num_one by num_two and assign the value to a variable \_floor_division
288-
1. The radius of a circle is 30 meters.
289-
1. Calculate the area of a circle and assign the value to a variable _area_of_circle_
290-
2. Calculate the circumference of a circle and assign the value to a variable _circum_of_circle_
285+
2. Using the _len()_ built-in function, find the length of your first name
286+
3. Compare the length of your first name and your last name
287+
4. Declare 5 as num_one and 4 as num_two
288+
5. Add num_one and num_two and assign the value to a variable total
289+
6. Subtract num_two from num_one and assign the value to a variable diff
290+
7. Multiply num_two and num_one and assign the value to a variable product
291+
8. Divide num_one by num_two and assign the value to a variable division
292+
9. Use modulus division to find num_two divided by num_one and assign the value to a variable remainder
293+
10. Calculate num_one to the power of num_two and assign the value to a variable exp
294+
11. Find floor division of num_one by num_two and assign the value to a variable floor_division
295+
12. The radius of a circle is 30 meters.
296+
1. Calculate the area of a circle and assign the value to a variable name of _area_of_circle_
297+
2. Calculate the circumference of a circle and assign the value to a variable name of _circum_of_circle_
291298
3. Take radius as user input and calculate the area.
292-
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
293-
1. Run help('keywords') in python shell or in your file to check for the reserved words
299+
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
300+
14. Run help('keywords') in Python shell or in your file to check for the Python reserved words or keywords
294301

295302
🎉 CONGRATULATIONS ! 🎉
296303

0 commit comments

Comments
 (0)