0% found this document useful (0 votes)
5 views43 pages

Python Operators

The document provides an overview of Python operators, including arithmetic, assignment, comparison, logical, identity, and membership operators. It also details escape characters used in strings and includes examples of various Python programs. The content serves as a reference for understanding and utilizing different operators and escape sequences in Python programming.
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)
5 views43 pages

Python Operators

The document provides an overview of Python operators, including arithmetic, assignment, comparison, logical, identity, and membership operators. It also details escape characters used in strings and includes examples of various Python programs. The content serves as a reference for understanding and utilizing different operators and escape sequences in Python programming.
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

Python

Operators
Escape Characters
Escape Characters
Escape Characters
Escape Characters
Escape Character Description

\n Newline – Moves the cursor to the next line.

\t Tab – Adds a horizontal tab.

\\ Backslash – Inserts a literal backslash.

\' Single Quote – Inserts a single quote inside a single-quoted string.

\" Double Quote – Inserts a double quote inside a double-quoted string.

\b Backspace – Moves the cursor one position back, effectively deleting the last character.

\v Vertical Tab – Moves the cursor vertically.


Python Operators
1. Arithmetic operators
2. Assignment operators
3. Comparison operators
4. Logical operators
5. Identity operators
6. Membership operators
7. Bitwise operators
Arithmetic Operators
Arithmetic Operators
Program to Repeat a Given String 5 Times
Program to get the Average of given
numbers.
Print the square and cube of a given
number
Program to Interchange Values between
Variables.
Python program to calculate simple
interests.
Python program to get the current date
using datetime.
Python program to calculate days between
2 dates
Assignment Operators
Assignment Operators
Comparison Operators
Example
Comparison with Integer Numbers
Comparison of Float Number
Comparison of Booleans
Example
Example
Python Logical Operators
Logical and Operator

a b a and b

F F F

F T F

T F F

T T T
Logical or Operator

a b a or b

F F F

F T T

T F T

T T T
Logical not Operator

a not (a)
F T

T F
Identity Operators
Identity Operators
is Operators
is Operators
is not Operators
is not Operators
Membership Operators
Membership Operators
in Operators
not in Operators
Thank you

You might also like