Understanding Arithmetic Operators in Python

Arithmetic Operators:

In Python, arithmetic operators are used to perform basic mathematical operations on numeric data types, such as integers and floating-point numbers. Here are the common arithmetic operators in Python:

Examples:

Let's see some examples of using arithmetic operators in Python:

        
            # Addition
            num1 = 10
            num2 = 5
            result = num1 + num2
            print("Addition:", result)

            # Subtraction
            x = 15
            y = 7
            difference = x - y
            print("Subtraction:", difference)

            # Multiplication
            a = 5
            b = 3
            product = a * b
            print("Multiplication:", product)

            # Division
            dividend = 20
            divisor = 4
            quotient = dividend / divisor
            print("Division:", quotient)

            # Modulus
            dividend = 17
            divisor = 5
            remainder = dividend % divisor
            print("Modulus:", remainder)

            # Exponentiation
            base = 2
            exponent = 3
            result = base ** exponent
            print("Exponentiation:", result)

            # Floor Division
            dividend = 17
            divisor = 5
            quotient = dividend // divisor
            print("Floor Division:", quotient)
        
    

Understanding arithmetic operators is essential for performing mathematical calculations and writing expressions in Python.

Arithmetic Operators in Python YouTube Video