ML-python_basics - Section (1and2).
ML-python_basics - Section (1and2).
3
Installing Anaconda
4
Installing Anaconda
5
Opening Anaconda
6
Opening Jupyter Notebook
7
Opening Jupyter Notebook
8
Having trouble with Anaconda or Jupyter?
9
Variables
10
Printing a variable or a message
print(name)
Result : Ahmed
11
Accessing items in lists or dictionaries
print(favorites[1])
print(info[“name”])
Result :
3
Mostafa
12
Arithmetic Operators
Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
** Exponentiation (power)
// Floor division
13
Arithmetic Operators
print(1 + 1)
print(1 – 1)
print(2 * 3)
print(6 / 2)
print(4 % 2)
print(5 // 2)
Result :
2
0
6
3
0
2 14
Conditionals
Result :
This is true 15
Greater than 0
Logical Operators
Operator Equivalent to
and &&
or ||
not !
16
Loops
? While while loops stays the same, for loops on the other
hand are a bit different.
while(check):
print(“This is an infinite loop”)
for i in range(10):
print(“This will loop 10 times”)
for x in favorites:
print(x)
18
Example
list_of_favorites = [
{“name”: “Ahmed”, “likes”: ”watermelon”},
{“name”: “Michael”, “likes”: “apples”},
{“name”: “Sara”, “likes”: “grapes”}
{“name”: “Mariam”, “likes”: “mango”}
]
19
Try it out yourself
? Code:
https://colab.research.google.com/drive/1ycxWsdM9qiEc
PyP5bucYbkdNPa6PrP8g?usp=sharing
20
Thank you for your attention!
21
Further reading
? https://www.freecodecamp.org/news/learning-python-from-zero-to-hero-120ea540b567/
? https://www.w3schools.com/python/python_operators.asp
22