You can learn about Operators in Python Programs with Outputs helped you to understand the language better.

Python Programming – Operators

Operators

An operator is a particular symbol that is used on some values and produces an output as a result. In other words, the operator in Python specifies an operation to be performed on the variables that yield a resultant value. The operator works on operands. An operand is an entity on which the operator acts. For example, in the expression:
a + b

the sign + is an operator which specifies the operation of addition on the two operands a and b. Operators can be unary, binary or ternary. The operator which requires a single operand is known as a unary operator; the operator which requires two operands is known as a binary operator, and which requires three operands is called the ternary operator. For example,

-X # here – is a unary operator

7+2=9# here + is a binary operator

# Assign minimum value using ternary operator
x, y = 5, 7
minimum = x if x < y else y
print(minimum)

Two operators, + and -, can be used as unary operators. The unary operator has only one operand. It expects a single numeric expression (literal number, variable, or more complicated numeric expression within parentheses) immediately to its right; it computes the additive inverse of its operand.

A binary operator is an operator that takes two arguments (for example, + or /). A unary operator operates on a single value. (For example, -)
Python language operators are classified into the following types. These are:

  1. Arithmetic Operators
  2. Relational (Conditional) Operators
  3. Logical / Boolean Operators
  4. Assignment Operators
  5. Bitwise Operators
  6. Membership Operators
  7. Identity Operators

 

Leave a Reply

Your email address will not be published. Required fields are marked *