Operators in Python | EP-32 Arithmetic Operators in Python | Python Tutorials for Beginners | Python
Python Opertaor
Operators are used to perform operations on variables and values.
Python divides the operators in the following groups:
1.Arithmetic operators
2.Comparison Operators
3.Logical Operators
4.Bitwise Operators
5.Assignment Operators
6.Membership & Identity Operators | Python “in”, and “is” operator
1. Python Arithmetic Operators
"""The Python operators are fundamental for performing mathematical calculations in programming languages like Python. Arithmetic operators are symbols used to perform mathematical operations on numerical values. In most programming languages, arithmetic operators include addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).
- Addition Operator
In Python, + is the addition operator. It is used to add 2 values.
val1=10
val2=20
add=val1+val2
print(add)
- Subtraction Operator
In Python, – is the subtraction operator. It is used to subtract the second
value from the first value.
val3=56
val4=20
sub = val3-val4
print(sub)
- Multiplication Operator
Python * operator is the multiplication operator. It is used to find the product of 2 values.
val5=56
val6=63
mul = val5*val6
print(mul)
- Division Operator
Python / operator is the division operator. It is used to find the quotient when the first operand is divided by the second.
val7=80
val8=10
div =val7/val8
print(div)
- Floor Division Operator
The // in Python is used to conduct the floor division. It is used to find the floor of the quotient when the first operand is divided by the second."""
floor_div = val7//val8
print(floor_div)
- Modulus Operator
The % in Python is the modulus operator. It is used to find the remainder when the first operand is divided by the second.
val9=20
val10=3
mod = val9%val10
print(mod)
- Exponentiation Operator
In Python, ** is the exponentiation operator. It is used to raise the first
operand to the power of the second.
val11 =6
val12=2
exp =val11**val12 # 6**2
print(exp)
What is the rule for arithmetic operators in Python?
Arithmetic operators in Python follow the standard mathematical order of operations, also known as BODMAS/BIDMAS rules:
Brackets
Orders (exponentiation, **)
Division and Multiplication (/, *, //, %)
Addition and Subtraction (+, -)
arth = 3+((2*(2**2))/2)-1
print(arth)
#3+((2*4)/2)-1
#3+8/2-1
#3+4-1
#7-1 =6
#PythonTutorials #PythonForBeginners #ArithmeticOperators #LearnPython #CodingForBeginners #Programming #PythonCoding #TechEducation #PythonProgramming #PythonCourse #Python #PythonTutorial #CodingTutorial #PythonTips #Programming #Coding
Connect With Us:
—————————————
➡️ Website: https://www.cybrosys.com/
➡️ Email: info@cybrosys.com
➡️ Twitter: / cybrosys
➡️ LinkedIn: / cybrosys
➡️ Facebook: / cybrosystechnologies
➡️ Instagram: / cybrosystech
➡️ Pinterest: / cybrosys