34 lines
No EOL
1.4 KiB
Markdown
34 lines
No EOL
1.4 KiB
Markdown
---
|
|
title: arithmeticOperators
|
|
tags:
|
|
- python
|
|
- math
|
|
- operators
|
|
- syntax
|
|
aliases:
|
|
- math operators
|
|
- arithmetic operations
|
|
- python math
|
|
---
|
|
|
|
> [!note] Math Operators in Python
|
|
> Python supports standard arithmetic operations:
|
|
>
|
|
> > [!example] Operator Table
|
|
> > | **Operator** | **Description** | **Example** | **Result** |
|
|
> > |--------------|-----------------------|--------------|------------|
|
|
> > | `+` | Addition | `2 + 3` | `5` |
|
|
> > | `-` | Subtraction | `5 - 2` | `3` |
|
|
> > | `*` | Multiplication | `2 * 3` | `6` |
|
|
> > | `/` | Division (float) | `5 / 2` | `2.5` |
|
|
> > | `//` | Floor Division | `5 // 2` | `2` |
|
|
> > | `%` | Modulo (remainder) | `5 % 2` | `1` |
|
|
> > | `**` | Exponentiation | `2 ** 3` | `8` |
|
|
> >
|
|
> > [!info]- 🔗 Related Notes
|
|
> > - [[numericTypes]] — explains how `int`, `float`, and `complex` values behave
|
|
> > - [[mixedTypeArithmetic]] — details what happens when combining types like `int + float`
|
|
> > - [[operatorPrecedence]] — explains the order in which operators are evaluated
|
|
> > - [[typeConversions]] — shows how conversions affect arithmetic results
|
|
> > - [[pythonSyntaxOverview]] — broad context for where arithmetic fits in Python basics
|
|
> |