0% found this document useful (0 votes)
2 views

Data Handling Part 3.1

The document outlines various operators used in data handling, including arithmetic, relational, identity, logical, bitwise, and membership operators. It explains unary and binary operators with examples, detailing their functions such as addition, subtraction, multiplication, division, and modulus. Additionally, it provides examples of how to use these operators in Python programming, including a practical example of calculating the area of a circle.

Uploaded by

ashugamerz1988
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Data Handling Part 3.1

The document outlines various operators used in data handling, including arithmetic, relational, identity, logical, bitwise, and membership operators. It explains unary and binary operators with examples, detailing their functions such as addition, subtraction, multiplication, division, and modulus. Additionally, it provides examples of how to use these operators in Python programming, including a practical example of calculating the area of a circle.

Uploaded by

ashugamerz1988
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Data Handling

Std XI – Computer Science / Informatics


Practices
Part III
Operators
The operations being carried out on data , are represented
by operators.

Operators are tokens that trigger some computation when


applied to variables and other objects in an expression.

Variables and objects to which the computation is applied,


are called operands.

An operator requires some operands to work upon.


1. Arithmetic operators
2. Relational operators
3. Identity operators
4. Logical operators
5. Bitwise operators
6. Membership operators
Unary Operators
Unary +  The operators unary ‘+’ precedes an operand.
The operand must have arithmetic type and the result is
the value of the argument.

Example 
If a=5 then +a means 5

if a=0 then +a means 0

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.

This operator reverses the sign of the operand’s 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

Python also offers + as a concatenation operator when used with


strings, lists and tuples. Example  str(print())+”One” o/p 
'NoneOne'

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.

Example  3 * “go!” will give output  “go!go!go!”


4. Division operator / The / operator divides first operand
by the second operand and always returns the result as
float value.

Example  4.2 will give o/p 2.0

100/10 will give o/p 10.0

13.5/1.5 will give o/p 9.0


5. Floor division //– In this type of division only the whole
part of the result is given and the fractional part is
truncated.

Example  a=15.9 , b=3 then a/b =5.3


but a//b = 5.0
100//32 is 3
7//3 is 2
6.5// 2 is 3.0
6. Modulus operator %
The % operator finds the modulus ie. The remainder of its
first operand relative to the second.

Example  19%6 will give o/p 1


7.2 % 3 will give o/p 1.2
6 % 2.5 will give o/p 1.0
7. Exponential operator **

This operator performs raise to power calculation.

Example  4**3 will give the o/p 64

49.0 ** 0.5 will give o/p 7.0


Example 
A,B,C,D =9.2, 2.0, 4, 21
print((A/4),(A//4))
print(B**C)
print(D//B)
print(A%C)

O/P  2.3 2.0


16.0
10.0
1.2
Example  Print the area of a circle of radius 3.75
metres.
Solution 

Radius=3.75
Area =3.14159 * Radius **2
print(Area,’sq.meter’)

You might also like