You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description: 'Operators are used to perform operations on variables and values. In the example below, we use the + operator to add together two values: py print(10 + 5) Python divides the operators in the following groups: - Arithmetic operators'
3
+
Description: 'Operators are used to perform various operations on variables and values.'
4
4
Subjects:
5
5
- 'Computer Science'
6
6
- 'Data Science'
@@ -15,64 +15,77 @@ CatalogContent:
15
15
- 'paths/data-science'
16
16
---
17
17
18
-
Operators are used to perform operations on variables and values.
18
+
Operators are used to perform various operations on variables and values. The standard arithmetic and assignment operators are the most familiar.
19
19
20
-
In the example below, we use the `+` operator to add together two values:
20
+
## Syntax
21
21
22
-
```py
23
-
print(10+5)
22
+
The following code snippet uses the assignment operator, `=`, to set `my_variable` to the value of `num1` and `num2` with an arithmetic operator acting on them. For example, if `operator` represented `*`, `my_variable` would be assigned a value of `num1 * num2`.
23
+
24
+
```pseudo
25
+
my_variable = num1 operator num2
24
26
```
25
27
26
-
Python divides the operators in the following groups:
28
+
Python operators can be organized into the following groups:
27
29
28
-
- Arithmetic operators
29
-
- Assignment operators
30
-
- Comparison operators
31
-
- Logical operators
30
+
- Arithmetic operators for performing traditional math evaluations.
31
+
- Assignment operators for assigning values to variables.
32
+
- Comparison operators for comparing two values.
33
+
- Logical operators for combining boolean values.
32
34
33
35
## Arithmetic Operators
34
36
35
-
Arithmetic operators are used with numeric values to perform common mathematical operations:
37
+
Python has the following arithmetic operators:
36
38
37
-
| Operator | Name | Example |
38
-
| -------- | -------------- | -------- |
39
-
|`+`| Addition |`a + b`|
40
-
|`-`| Subtraction |`a - b`|
41
-
|`*`| Multiplication |`x * y`|
42
-
|`/`| Division |`x / y`|
43
-
|`%`| Modulus |`x % y`|
44
-
|`**`| Exponentiation |`x ** y`|
45
-
|`//`| Floor division |`x // y`|
39
+
- Addition, `+`, which returns the sum of two numbers.
40
+
- Subtraction, `-`, which returns the difference of two numbers.
41
+
- Multiplication, `*`, which returns the product of two numbers.
42
+
- Division, `/`, which returns the quotient of two numbers.
43
+
- Exponentiation, `**`, which returns the value of one number raised to the power of another.
44
+
- Modulus, `%`, which returns the remainder of one number divided by another.
45
+
- Floor division, `//`, which returns the integer quotient of two numbers.
46
46
47
47
## Assignment Operators
48
48
49
-
Assignment operators are used to assign values to variables:
49
+
Python includes the following assignment operators:
50
50
51
-
-`+=`
52
-
-`-=`
53
-
-`*=`
54
-
-`/=`
55
-
-`%=`
51
+
- The `=` operator assigns the value on the left to the variable on the right.
52
+
- The `+=` operator updates a variable by incrementing its value and reassigning it.
53
+
- The `-=` operator updates a variable by decrementing its value and reassigning it.
54
+
- The `*=` operator updates a variable by multiplying its value and reassigning it.
55
+
- The `/=` operator updates a variable by dividing its value and reassigning it.
56
+
- The `%=` operator updates a variable by calculating its modulus against another value and reassigning it.
56
57
57
58
## Comparison Operators
58
59
59
-
Comparison operators are used to compare two values:
0 commit comments