Data Handling Part 3.1
Data Handling Part 3.1
Example
If a=5 then +a means 5
if a= -4 then +a means - 4
Unary -
Unary - The operators unary ‘-’ precedes an operand.
The operand must have arithmetic type and the result is
the negation of its operand value.
Example
If a=5 then - a means - 5
if a=0 then - a means 0
if a= - 4 then – a means 4
Binary operators
Binary operators are those operators that require two operands to
operate upon.
Together , the operator and its operands constitute an expression.
1. Addition operator + This operator adds the values of its
operands.
Example 4+20 a+5 a+b
For Boolean values True and False, Python internally takes values 1
and 0 respectively so True+1 will give you 2
2. Subtraction operator –
The – operator subtracts the second operand from the first.
The operand may be integer or floating point.
Example 14-3 a-b x-3(if x is -1 then result will be -
4)
3. Multiplication operator *
The * operator multiplies the values of its operands.
Example 3*4 b*4 p*2(if p is -2 then result is -4)
The * operator also works as a replication operator.
Radius=3.75
Area =3.14159 * Radius **2
print(Area,’sq.meter’)