Arithmetic Operators


In Python, arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication, division, modulus, and exponentiation. These operators are represented by symbols such as +, -, *, /, %, and **.

This program is a simple Python script that performs basic arithmetic operations on two numbers inputted by the user. Here's a step-by-step explanation of what the code does:

  • The first two lines prompt the user to input two numbers (a and b), which are then converted to integers using the int() function.
  • The next section prints the message "Arithmetic Operations" to inform the user that the following outputs are the results of arithmetic operations.
  • The following seven lines perform the following arithmetic operations and print the results:
    • Addition
    • Subtraction
    • Multiplication
    • Division
    • Modulo
    • Exponentiation
    • Floor Division
  • Finally, the program ends and the results of the operations are displayed on the screen for the user to see.

Source Code

a=int(input("Enter Number 1 : "))
b=int(input("Enter Number 2 : "))

print("Arithmetic Operations")

print("Addition :",a + b)

print("Subtraction :",a - b)

print("Multiplication :",a * b)

print("Division :",a / b)

print("Modulo :",a % b)

print("Exponentiation :",a ** b)

print("Floor Division :",a // b)

To download raw file Click Here

Output

Enter Number 1 : 20
Enter Number 2 : 13

Arithmetic Operations

Addition : 33
Subtraction : 7
Multiplication : 260
Division : 1.5384615
Modulo : 7
Exponentiation : 81920000
Floor Division : 1