[go: up one dir, main page]

0% found this document useful (0 votes)
18 views7 pages

Fs20co047 Py Exp 2

This document discusses various arithmetic, comparison, and bitwise operators in Python. It provides examples of operators like addition, subtraction, multiplication, division, greater than, less than, equal to, and binary operators. It also includes a Python program demonstrating a minimum of 8 operators and the corresponding output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views7 pages

Fs20co047 Py Exp 2

This document discusses various arithmetic, comparison, and bitwise operators in Python. It provides examples of operators like addition, subtraction, multiplication, division, greater than, less than, equal to, and binary operators. It also includes a Python program demonstrating a minimum of 8 operators and the corresponding output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

1 Python Exp 2

FS20CO047
Experiment 2

Shrikrushna Dilip Patil


22ND November, 2021
2 Python Exp 2

Title: Write a simple Python program using


Operators
Theory:
Arithmetic Operators:-

Arithmetic operators are used to performing mathematical


operations like addition, subtraction, multiplication, and division.

1.Addition (+)
Addition operator in python is being used to add two operands(values)
in python programming.
Syntax:- x + y

2.Subtraction (-)
Subtraction is used to execute a mathematical function which
subtracts the right hand operand from the left hand one.
Syntax:- x - y

3.Multiplication (*)
It is used in python programming to multiply the values and thereby to
get output.
Syntax:- x * y

4.Division (/)
Division Operator is used to divide the left hand operand by right hand
one.
Syntax:- x / y
3 Python Exp 2

5.Percentile Operator (%)


The Percentile (%) is the string formatting operator in python, and it is
also called as a interpretation operator. It divides the left hand operand by
right hand one and also returns reminder
Syntax:- x % y

6.Floor division Operator (//)


The Floor Operator is used to make a whole number adjusted to the
left hand side in the number line.
Syntax:- x // y

7.Exponent Operator (**)


Exponent operator is used in Python to perform exponential (power)
calculations by using operators.
Syntax:- x ** y

Comparison Operators:-

Comparison of Relational operators compares the values. It either


returns True or False according to the condition.

1.Greater Than (>)


This operator is mainly used in Python to return true if the Left
hand value is greater than right one. If left hand operand is greater than
right hand operand, it returns True as the output.
Syntax:- x > y

2.Less Than (<)


This Operator compares the right hand operator with the left hand
one and if the right hand one is greater than the left hand one, it returns
True statement.
Syntax:- x > y
4 Python Exp 2

3.Not Equal to (! =)
This Not equal operator is used to compare two operands and
returns True statement if they are Not equal, and False if they are Equal.
Syntax:- x != y

4.Equal to (= =)
Equal operator is used to compare the two values and to give the
result whether they are equal or not. If both the values are equal, then it
gives the result as True, if not False.
Syntax:- x == y

5.Greater than or Equal to (>=)


Greater than operator is used in python to evaluate to True if the
left hand operand is >= (greater than or equal) to right hand one
Syntax:- x >= y

6.less than or Equal to (>=)


Less than or equal to operator returns true if the right hand
operator is greater than or equal to left hand one.
Syntax:- x <= y

Bitwise Operators:-

Bitwise operators act on bits and perform the bit-by-bit


operations. These are used to operate on binary numbers.

1.Binary AND (&)


This operator performs bit by bit AND operations on the values on
either side of the operator.
Syntax:- x & y
5 Python Exp 2

2.Binary XOR (^)


This operator performs bit by bit exclusive OR operations on the
values on either side of the operator.
Syntax:- x^y

3.Binary NOT (~)


The one’s complement of a number’s binary is returned.
Syntax:- ~y

4.Binary OR (|)
This operator performs bit by bit OR operations on the values on
either side of the operator.
Syntax:- x|y

5.Bitwise Right Shift (>>)


The value to the left of the operator is shifted to the right as many
times as the value on the right of the operator.
Syntax:- x>>

6.Bitwise Left Shift (>>)


The value to the left operator is shifted to the left as many times
as the value on the right side of the operator.
Syntax:- <<x
6 Python Exp 2

Practical:
A. Program and output for demonstration of minimum 8
operators.
Program:-
7 Python Exp 2

Observation:
a.
Output:-

Conclusion:
In the above experiment I learned how to use the and perform various
operations using it.

You might also like