File tree Expand file tree Collapse file tree 2 files changed +53
-43
lines changed Expand file tree Collapse file tree 2 files changed +53
-43
lines changed Original file line number Diff line number Diff line change 1
- ## Basic Data Types
2
- ### Variable ` x `
3
- ### String ` "My string" `
4
- ### Integer ` 10 `
5
- ### Float ` 15.95 `
6
- ### Bool ` True/False `
7
- ### List ` [] `
8
- ### Tuple ` (,) `
9
- ### Set ` {} `
10
- ### Dictionary ` {:} `
1
+ # 01. Basic Data Types
11
2
12
- ## Arithmetic Operators
13
- ### Addition ` + `
14
- ### Subtraction ` - `
15
- ### Multiplication ` * `
16
- ### True Division ` / `
17
- ### Floor Division ` // `
18
- ### Modulo ` % `
19
- ### Exponentiation ` ** `
3
+ # 02. Arithmetic Operators
20
4
21
- ## Comparison Operators
22
- ### Equal ` == `
23
- ### Not equal ` != `
24
- ### Greater than ` > `
25
- ### Less than ` < `
26
- ### Greater than or equal to ` >= `
27
- ### Less than or equal to ` <= `
5
+ # 03. Comparison Operators
28
6
29
- ## Logical Operators
30
- ### AND
31
- ### OR
32
- ### NOT
33
-
34
- ## Operator precedence
35
- Showing from most binding to the least binding
36
- - Parentheses (grouping)
37
- - Exponentiation
38
- - Multiplication, division, modulo
39
- - Addition, subtraction
7
+ # 04. Logical Operators
Original file line number Diff line number Diff line change 1
- ### Addition ` + `
2
- ### Subtraction ` - `
3
- ### Multiplication ` * `
4
- ### True Division ` / `
5
- ### Floor Division ` // `
6
- ### Modulo ` % `
7
- ### Exponentiation ` ** `
1
+ ## Addition ` + `
2
+ Correct uses:
3
+ - The use with integers and floats:
4
+ ` 44 + 19.5 # 63.5 `
5
+ - The use with strings (concatenation):
6
+ ` "My name is" + "James" `
7
+
8
+ Wrong uses:
9
+ - Between strings and integers/floats:
10
+ ` "The correct number is" + 5 `
11
+ ` TypeError: can only concatenate str (not "int") to str `
12
+
13
+ ## Subtraction ` - `
14
+ - The use between integers/floats:
15
+ ` 93.1 - 50 `
16
+
17
+ ## Multiplication ` * `
18
+ - The arithmetic use:
19
+ ` 8 * 5 `
20
+
21
+ - Multiplying data types:
22
+ ` "Hello " * 2 `
23
+ ` [100] * 2 `
24
+ ` (100, 1) * 2 `
25
+
26
+ ## True Division ` / `
27
+ - The two operands will always result in a float using the ` / ` operator
28
+
29
+ Example:
30
+ ` 40 / 2 ` will result ` 20.0 `
31
+
32
+ ## Floor Division ` // `
33
+ - Will always round the amount and result in a string
34
+
35
+ Example:
36
+ ` 55 // 3 `
37
+
38
+ ## Modulo ` % `
39
+ - Based on the Euclidean division
40
+ - Start with a ** dividend** and a ** divisor**
41
+ - It's used to get the remainder between the two operands
42
+
43
+ Example:
44
+
45
+ The result for ` 10 % 3 ` is ` 1 ` .
46
+
47
+
48
+ ## Exponentiation ` ** `
49
+ ` 2 ** 3 ` Can be read as: 2 raised to the power of 3, and it works just like in math
You can’t perform that action at this time.
0 commit comments