python program language operators

WBOY
Release: 2024-08-12 18:43:05
Original
806 people have browsed it

python program language operators

python divides the operators in the following groups
Types of operators
Arithmetic operators
Assignment operators
comparison operators
logical operators
bitwise operators
Membership operators

program

Arithmetic operators

The Arithmetic operators is numeric value is mathematical operators
1.Addition
2.Subtraction
3.Multlplication
4.Division
5.Modules
6.Floor division

Addition

a=3
b=2
print(a + b)
O/P
5

subtraction

a=6
b=5
print(a-b)
O/P
1

multplication

a=25
b=25
print(a*b)
O/P
500

division

a=12
b=3
print(a/b)
O/P
4

modules

a=5
b=2
print(a % b)
O/P
1

floor division

a=15
b=2
print(a//b)
O/P
7
2.Assignment operators
The assignment operators is a assign value to varables

Assign values=

a=4
print(a)
o/p
4

Assign values+=

x=2
x+=2
print(x)
o/p
4

Assign value-=

x=2
x-=2
print(x)
o/p
0

Assign value*=

x=6
x*=2
print(x)
o/p
12

Assign value/=

x=6
x/=3
print(x)
o/p
2.0

Assign value%=

x=9
x%=4
print(x)
o/p
1

Assign values //=

x=5
x//=2
print(x)
o/p
2

assign value&=

x=8
x&=3
print(x)
o/
0

assign values ^=

x=7
x^=8
print(x)
o/p
15

assign values!=

x=5
x!=3
print(x)
o/p
5

assign values >>=

x=9
x>>=4
print(x)
o/p
0

assign values <<=

x=9
x<<=4
pr9int(x)
o/p
144
3.Comparsion operators
The Comparsion operatror is compare two values

equal ==

x=3
y=6
print(x==y)
false

not equal!=

x=3
y=6
print(x!=y)
o/p
True

greater equal>=

x=3
y=6
print(x>=y)
o/p
true

less equal<=

x=3
y=6
print(x<=y)
o/p
false
4.logical oiperators
AND
OR
NOT

AND

X=5
print(x>3 and x<10)
o/p
true

OR

x-5
print(x>3 or x<4)
o/p
true

NOT

x=5
print(x>3 not x<10))
o/p
false

The above is the detailed content of python program language operators. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!