0% found this document useful (0 votes)
6 views6 pages

Thursday, September 14, 2023 7:05 PM: Python 22 Batch 7 PM Page 1

The document provides an overview of various operators in Python, including the exponential operator, modulo operator, relational operators, logical operators, and equality operators. It explains how each operator functions with examples and outputs, highlighting their behavior with both boolean and non-boolean values. The content is structured in a tutorial format, aimed at teaching Python programming concepts to learners.
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)
6 views6 pages

Thursday, September 14, 2023 7:05 PM: Python 22 Batch 7 PM Page 1

The document provides an overview of various operators in Python, including the exponential operator, modulo operator, relational operators, logical operators, and equality operators. It explains how each operator functions with examples and outputs, highlighting their behavior with both boolean and non-boolean values. The content is structured in a tutorial format, aimed at teaching Python programming concepts to learners.
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/ 6

14-9-2023

Thursday, September 14, 2023 7:05 PM

Exponential Operator(**):

It performs power of the given value in a format

2**3
3**2

4**3

output:
>>> 2**3
8
>>> 3**2
9
>>> 4**3
64
>>> 4**4
256
>>>

7.Modulo Operator(%)

Modulo operator display remainder as a result

9%3
0
>>> 6%2
0
>>> 8%2
0
>>> 6%5
1
>>>

Relational Operators/comparision Operators

>,>=,<,<=,==

Relational Operators returns a boolean value as output

Python 22 batch 7 pm Page 1


5>3
True
>>> 5>=3
True
>>> 5<3
False
>>> 6<9
True
>>> 4==4
True
>>> 4<=7
True
>>>
Logical Operators:

Logical operators are of 3 types

a.AND
b.OR
c.NOT

a.AND

In case of AND the result is true when both values are true , otherwise the result is
false.

T T T
T F F
F T F
F F F

True and True


True
>>> False and True
False
>>> False and False
False
>>> True and False
False
>>> 1 and 0
0
Python 22 batch 7 pm Page 2
0

2.OR

In case of OR if itleast one value is True the result is True otherwise the result is
False

T T T
F T T
T F T
F F F
n=21

True or False if(n>9 and n<20)


True
>>> 1 or 0
1
>>> False or True
True
>>> True or True
True
>>> False or False
False
>>> 1 or 1
1
>>>

NOT

If the value is True the result is False, if the value is False the result is True

not True-->False
not False-->True

not True
False
>>> not False
True
>>>

HCL python developer

Python 22 batch 7 pm Page 3


'apple' and 'grapes'

Logical Operator for Non Boolean Values

AND operator for Non Boolean Values

0-->False

other than zero , any number or any alphabet is treated as True

43-->True
a-->True

Rule:

In case of AND operator for non boolean values, if x evaluates to False then the result
is x, if x evaluates to True then the result is y

0 and 20

output:
0

10 and 20

20

30 and 0

'apple' and 'grapes'

grapes

'' and 'apple'

Python 22 batch 7 pm Page 4


'' and 'apple'

'' and ' '

' ' and 'apple'

apple

Note:

''--> empty string


' '-->space (has ascii value(32) means True)

OR operator for non boolean Values

Rule:

If x evaluates to True then the result is x


If x evaluates to False then the result is y

Example:

10 or 20

output:
10

-14 or -18

output:
-14

'' or 'grapes'

Python 22 batch 7 pm Page 5


'' or 'grapes'

output:
'grapes'

' ' or 'apple'

output:
' ' 0-->False
1 True
10 and 20 any number->
True
Equality Operators

==,!=

10==20-->False

10==20
False
>>> 10!=20
True
>>> 1==True
True
>>> 'orange'=='orange'
True
>>>

Python 22 batch 7 pm Page 6

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy