Copyright (c) Hyperion Entertainment and contributors.
Difference between revisions of "AmigaOS Manual: Python Elements of Python"
Jump to navigation
Jump to search
(Added table of Bitwise Operations and table of Logical Operations.) |
(Added 3 new titles, removed Boolean operators (was duplicate of Logical Operators)) |
||
Line 16: | Line 16: | ||
== Arithmetic operators == |
== Arithmetic operators == |
||
− | |||
{| class="wikitable" |
{| class="wikitable" |
||
! Operator !! Name !! Explanation |
! Operator !! Name !! Explanation |
||
Line 35: | Line 34: | ||
|} |
|} |
||
+ | == Comparison operators == |
||
− | == Bitwise Operations on Integer Types == |
||
{| class="wikitable" |
{| class="wikitable" |
||
! Operator !! Name !! Explanation |
! Operator !! Name !! Explanation |
||
|- |
|- |
||
+ | | < || Less Than || Returns whether x is less than y. All comparison operators return 1 for true and 0 for false. This is equivalent to the special variables '''True''' and '''False''' respectively. Note the capitalization of these variables' names. |
||
− | | << || Left Shift || Shifts the bits of the number to the left by the number of bits specified. |
||
|- |
|- |
||
+ | | > || Greater Than || Returns whether x is greater than y. |
||
− | | >> || Right Shift || Shifts the bits of the number to the right by the number of bits specified. |
||
|- |
|- |
||
+ | | <= || Less Than or Equal To || Returns whether x is less than or equal to y. |
||
− | | & || Bitwise AND || Bitwise AND of the numbers. |
||
|- |
|- |
||
+ | | >= || Greater Than or Equal To || Returns whether x is greater than or equal to y. |
||
− | | | || Bitwise OR || Bitwise OR of the numbers. |
||
|- |
|- |
||
− | | |
+ | | == || Equal To || Compares if the objects are equal. |
|- |
|- |
||
− | | |
+ | | != || Not Equal To || Compares if the objects are not equal. |
|} |
|} |
||
+ | |||
+ | == Assignment Operators == |
||
== Logical Operators == |
== Logical Operators == |
||
Line 63: | Line 64: | ||
|} |
|} |
||
+ | == Bitwise Operations on Integer Types == |
||
− | == Comparison operators == |
||
− | |||
{| class="wikitable" |
{| class="wikitable" |
||
! Operator !! Name !! Explanation |
! Operator !! Name !! Explanation |
||
|- |
|- |
||
+ | | << || Left Shift || Shifts the bits of the number to the left by the number of bits specified. |
||
− | | < || Less Than || Returns whether x is less than y. All comparison operators return 1 for true and 0 for false. This is equivalent to the special variables '''True''' and '''False''' respectively. Note the capitalization of these variables' names. |
||
|- |
|- |
||
+ | | >> || Right Shift || Shifts the bits of the number to the right by the number of bits specified. |
||
− | | > || Greater Than || Returns whether x is greater than y. |
||
|- |
|- |
||
+ | | & || Bitwise AND || Bitwise AND of the numbers. |
||
− | | <= || Less Than or Equal To || Returns whether x is less than or equal to y. |
||
|- |
|- |
||
+ | | | || Bitwise OR || Bitwise OR of the numbers. |
||
− | | >= || Greater Than or Equal To || Returns whether x is greater than or equal to y. |
||
|- |
|- |
||
− | | |
+ | | ^ || Bitwise XOR || Bitwise XOR of the numbers. |
|- |
|- |
||
− | | |
+ | | ~ || Bitwise Invert || The bitwise inversion of x. |
− | |} |
||
− | |||
− | == Boolean operators == |
||
− | |||
− | {| class="wikitable" |
||
− | ! Operator !! Name !! Explanation |
||
− | |- |
||
− | | not || Boolean NOT || If x is '''True''', it returns '''False'''. If x is '''False''', it returns '''True'''. |
||
− | |- |
||
− | | and || Boolean AND || x and y returns '''False''' if x is '''False''', else it returns evaluation of y. |
||
− | |- |
||
− | | or || Boolean OR || If x is '''True''', it returns '''True''', else it returns evaluation of y. |
||
|} |
|} |
||
− | == |
+ | == Membership Operators == |
+ | == Identity Operators == |
||
= Comments = |
= Comments = |
Revision as of 02:46, 9 January 2019
Contents
Data types
Numeric types
Tuplets and lists
Strings
Dictionaries
Files
Other data types
Operators
Arithmetic operators
Operator | Name | Explanation |
---|---|---|
+ | Plus | Adds the two objects. |
- | Minus | Either gives a negative number or gives the subtraction of one number from the other. |
* | Multiply | Gives the multiplication of the two numbers or returns the string repeated that many times. |
** | Power | Returns x to the power of y. |
/ | Divide | Divide x by y. |
// | Floor Division | Returns the floor of the quotient. |
% | Modulo | Returns the remainder of the division. |
Comparison operators
Operator | Name | Explanation |
---|---|---|
< | Less Than | Returns whether x is less than y. All comparison operators return 1 for true and 0 for false. This is equivalent to the special variables True and False respectively. Note the capitalization of these variables' names. |
> | Greater Than | Returns whether x is greater than y. |
<= | Less Than or Equal To | Returns whether x is less than or equal to y. |
>= | Greater Than or Equal To | Returns whether x is greater than or equal to y. |
== | Equal To | Compares if the objects are equal. |
!= | Not Equal To | Compares if the objects are not equal. |
Assignment Operators
Logical Operators
Operator | Name | Explanation |
---|---|---|
not | Boolean NOT | If x is True, it returns False. If x is False, it returns True. |
and | Boolean AND | x and y returns False if x is False, else it returns evaluation of y. |
or | Boolean OR | If x is True, it returns True, else it returns evaluation of y. |
Bitwise Operations on Integer Types
Operator | Name | Explanation |
---|---|---|
<< | Left Shift | Shifts the bits of the number to the left by the number of bits specified. |
>> | Right Shift | Shifts the bits of the number to the right by the number of bits specified. |
& | Bitwise AND | Bitwise AND of the numbers. |
Bitwise OR | Bitwise OR of the numbers. | |
^ | Bitwise XOR | Bitwise XOR of the numbers. |
~ | Bitwise Invert | The bitwise inversion of x. |