Python @ DjangoSpin

PyPro #3 Python Arithmetic

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon
Reading Time: 1 minutes

Python Arithmetic

Python Arithmetic

The following program demonstrates the arithmetic in Python.

##
## Demonstrating arithmetic in Python

a = int(input("Enter first number"))
b = int(input("Enter second number"))

## + Addition
print("Sum of inputs a + b:", a + b)
## - Subtraction
print("Subraction of inputs a - b:", a - b)
## * Multiplication
print("Multiplication of inputs a * b:", a * b)
## / Division
print("Division of inputs a / b:", a / b)
## % Modulo
print("Modulo a % b:", a % b)
## % Exponent
print("a raised to the power b:", a ** b)
## % Floor Division: Result restricted to zero decimal points
print("Floor Division a // b:", a // b)
##
Try it online here.

See also:

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon

Leave a Reply