Section 3
Section 3
Operators
Numbers
• There are three numeric types in Python:
1. int
Int, or integer, is a whole number, positive or negative,
without decimals, of unlimited length.
2. float
- Float, or "floating point number" is a number, positive
or negative, containing one or more decimals.
Numbers cont.
- Float can also be scientific numbers with an "e" to
indicate the power of 10.
3. complex
Complex numbers are written with a "j" as the imaginary
part.
Random Number
• Python does not have a random() function to make a random
number, but Python has a built-in module called random that
can be used to make random numbers.
Operators
• Arithmetic operators
• Assignment operators
• Comparison operators
• Logical operators
• Identity operators
• Membership operators
• Bitwise operators
Arithmetic operators
Arithmetic operators are used with numeric values
Operator Description
is Returns True if both variables are the
same object.
is not Returns True if both variables are not the
same object.
Identity example..
Membership operators
• Membership operators are used to test if a sequence is
presented in an object.
Operator Description
in Returns True if a sequence with the
specified value is present in the object.
not in Returns True if a sequence with the
specified value is not present in the object.
Membership example..
Bitwise operators
• used to compare (binary) numbers.