Arithmetic Operation in Python
Arithmetic Operation in Python
Symbol | Description | Example 1 | Example 2 |
+ | Addition | >>>55+45 100 | >>> „Good‟ + „Morning‟ GoodMorning |
- | Subtraction | >>>55-45 10 | >>>30-80 -50 |
* | Multiplication | >>>55*45 2475 | >>> „Good‟* 3 GoodGoodGood |
/ | Division | >>>17/5 3 >>>17/5.0 3.4 >>> 17.0/5 3.4 | >>>28/3 9 |
% | Remainder/Modulo | >>>17%5 2 | >>> 23%2 1 |
** | Exponentiation | >>>2**3 8 >>>16**.5 4.0 | >>>2**8 256 |
// | Integer Division | >>>7.0//2 3.0 | >>>3/ / 2 1 |
#Demo Program to test Arithmetic Operators
a=100
b=10
print ("The Sum = ",a+b)
print ("The Difference = ",a-b)
print ("The Product = ",a*b)
print ("The Quotient = ",a/b)
print ("The Remainder = ",a%30)
print ("The Exponent = ",a**2)
print ("The Floor Division =",a//30)
#Program End
Output:
The Sum = 110
The Difference = 90
The Product = 1000
The Quotient = 10.0
The Remainder = 10
The Exponent = 10000
The Floor Division = 3
Python : Arithmetic Operation in Python Program List
Program [1]
Write a Program to obtain temperature in Celsius and convert it into Fahrenheit using formula –
C X 9/5 + 32 = F
Program [2]
WAP to print the area of circle when radius of the circle is given by user.
Program [3]
WAP to print the volume of a cylinder when radius and height of the cylinder is given by user.
Program [4]
WAP that asks your height in centimeters and converts it into foot and inches.
Program [5]
WAP to accept 3 side of triangle and find area of a triangle.
Program [6]
WAP to input principle amount,rate time and calculate simple interest.
Program [7]
WAP to read a number in n and prints n^2, n^3, n^4
Program [8]
WAP to take value of x,y,z from the user and calculate the equation
Program [9]
WAP to take the temperatures of all 7 days of the week and displays the average temperature of that week.
Program [10]
Python program to obtain three numbers and print their sum.
Program [11]
Python program to obtain length and breath of a rectangle and calculate its area
Program [12]
Python program to calculate (BMI) body mass index of a person
Body Mass Index is a simple calculation using a person's height and weight. The formula is BMI=kg/m^2 where kg is a person's weight in kilogram and m^2 is the height in meter squared.
Program [13]
Write a program to input a number and print its cube.
Program [14]
Write a program to input a single digit(n) and print a 3 digit number created as <n(n+1)(n+2)> e.g., if you input 7, then it should print 789. Assume that the input digit is in range 1-7.
Program [15]
Write a program to Calculate the Compound Interest
Program [16]
write a program to find sale price of an item with given price and discount (%)
Program [17]
Write a Python program to accept 3 sides of triangle and find the area of triangle.
s = (a+b+c)/2
area = √(s(s-a)*(s-b)*(s-c))
Program [18]
Write a python program which accept two times as input and displays the total time after adding both the entered times.
Sample Input :
Enter Time 1 :
Hour : 3
Minute : 40
Enter Time 2 :
Hour : 2
Minute : 35
Output:
Time 1 : 3 Hour & 40 Minute
Time 2 : 2 Hour & 35 Minute
Total Time : 6 Hour & 15 Minute
Program [19]
Write a python program which accept two times (HH:MM:SS) as input and displays the total time after adding both the entered times.
Sample :
Input:
Enter Time 1 :
Hour : 2
Minute : 40
Second : 45
Enter Time 2 :
Hour : 1
Minute : 35
Second : 40
Output:
Time 1 : 2 Hour, 40 Minute and 45 Second
Time 2 : 1 Hour, 35 Minute and 40 Second
Total Time : 4 Hour & 16 Minute and 25 Second