1. Python 101 NoteBook-Arithmetic Operators

Python 101 NoteBook

  • Arithmetic operators are used to perform mathematical operations on numerical values. Python supports the following arithmetic operators:
    1. Addition (+)
    2. Subtraction (-)
    3.Multiplication (*)
    4.Division (/)
    5.Floor division (//)
    6.Modulus (%)
    7.Exponentiation (**)

Example

# Addition (+): adds two values together
a = 2
b = 3
c = a + b
print(c) # Output: 5
# Subtraction (-): subtracts the second value from the first value
a = 5
b = 3
c = a - b
print(c) # Output: 2
# Multiplication (*): multiplies two values together
a = 2
b = 3
c = a * b
print(c) # Output: 6
# Division (/): divides the first value by the second value (returns 
a float)
a = 10
b = 3
c = a / b
print(c) # Output: 3.3333333333333335
# Floor Division (//): divides the first value by the second value 
and returns the floor (integer) value
a = 10
b = 3
c = a // b
print(c) # Output: 3
# Modulus (%): returns the remainder after division of the first 
value by the second value
a = 10
b = 3

Leave a Comment

Your email address will not be published. Required fields are marked *