GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||
GeezerVison is showing www.geeksforgeeks.org — Python Arithmetic Operators - GeeksforGeeks Python Arithmetic OperatorsLast Updated : 27 May, 2026 Arithmetic operators are used to perform mathematical calculations on numbers. These operators help in tasks like addition, subtraction, multiplication, division and other basic mathematical operations.
Addition OperatorThe + operator is used to combine two values by adding them together. It returns the sum of both operands and is commonly used in mathematical calculations.
Output 5 Explanation: a + b adds both numbers and returns 5. Subtraction OperatorThe - operator is used to subtract one value from another. It returns the difference between the two operands.
Output -1 Explanation: a - b subtracts 3 from 2, resulting in -1. Multiplication OperatorThe * operator is used to multiply two values together. It returns the product of the operands.
Output 6 Explanation: a * b multiplies both numbers and returns 6. Division OperatorDivision operators are used to divide one number by another. Python provides two types of division operators: Float Division (/) and Floor Division (//). 1. Float Division (/): / operator divides two numbers and always returns the result as a floating-point number.
Output 1.0 5.0 -5.0 10.0 Explanation:
2. Floor Division (//): // operator divides two numbers and returns the floor value of the quotient.
Output 3 -3 2.0 -3.0 Explanation:
Modulus OperatorThe % operator is used to find the remainder left after dividing one number by another. It is commonly used in programs that check divisibility, even or odd numbers and cyclic operations.
Output 1 Explanation: 3 % 2 divides 3 by 2 and the remainder left after division is 1. Exponentiation OperatorThe ** operator is used to raise a number to the power of another number. It performs repeated multiplication of the first number based on the second number.
Output 8 Explanation: 2 ** 3 means 2 × 2 × 2 and the result of the exponentiation is 8. Precedence of Arithmetic OperatorsThe table below shows the precedence and associativity of arithmetic operators in Python.
Comment Explore | ||||||||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |