Python Operators: Unterschied zwischen den Versionen

Aus MattWiki
Die Seite wurde neu angelegt: „===Sources=== https://www.codecademy.com/resources/docs/python/operators https://docs.python.org/3/reference/lexical_analysis.html#operators Kategorie:Python
 
Änderung 3361 von Matt (Diskussion) rückgängig gemacht.
Markierung: Rückgängigmachung
 
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
===Sources===
For more Python Basics see [[Python Basics]]
 
== Arithmetic Operators ==
{| class="wikitable"
!Operator
!Operation
!Example
!Description
|-
| +      || Addition          || x + y  || x plus y
|-
| -      || Subtraction      || x - y  || x minus y
|-
| *      || Multiplication    || x * y  || x multiplied by y
|-
| **    || Exponentiation    || x ** y || x raised to the power of y
|-
| /      || Division          || x / y  || x divided by y
|-
| //    || Floor Division    || x // y || x divided by y, returning integer
|-
| %      || Modulo            || x % y  || The remainder of x divided by y
|}
 
'''Examples'''<syntaxhighlight lang="python3">
x = 4 
y = 3 
 
x + y    # returns 7 
x - y    # returns 1 
x * y    # returns 12 
x ** y  # returns 64 
x / y    # returns 1.333 
x // y  # returns 1 
x % y    # returns 1
</syntaxhighlight>
 
 
===Further Reading===
https://www.codecademy.com/resources/docs/python/operators
https://www.codecademy.com/resources/docs/python/operators
https://www.w3schools.com/python/python_operators.asp


https://docs.python.org/3/reference/lexical_analysis.html#operators
https://docs.python.org/3/reference/lexical_analysis.html#operators
[[Kategorie:Python]]
[[Kategorie:Python]]

Aktuelle Version vom 17. Februar 2025, 08:06 Uhr

For more Python Basics see Python Basics

Arithmetic Operators

Operator Operation Example Description
+ Addition x + y x plus y
- Subtraction x - y x minus y
* Multiplication x * y x multiplied by y
** Exponentiation x ** y x raised to the power of y
/ Division x / y x divided by y
// Floor Division x // y x divided by y, returning integer
% Modulo x % y The remainder of x divided by y

Examples

x = 4  
y = 3  
  
x + y    # returns 7  
x - y    # returns 1  
x * y    # returns 12  
x ** y   # returns 64  
x / y    # returns 1.333  
x // y   # returns 1  
x % y    # returns 1


Further Reading

https://www.codecademy.com/resources/docs/python/operators

https://www.w3schools.com/python/python_operators.asp

https://docs.python.org/3/reference/lexical_analysis.html#operators