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


View Solution


Program [2]

WAP to print the area of circle when radius of the circle is given by user.


View Solution


Program [3]

WAP to print the volume of a cylinder when radius and height of the cylinder is given by user.

area =πr2h


View Solution


Program [4]

WAP that asks your height in centimeters and converts it into foot and inches.


View Solution


Program [5]

WAP to accept 3 side of triangle and find area of a triangle.


View Solution


Program [6]

WAP to input principle amount,rate time and calculate simple interest.


View Solution


Program [7]

WAP to read a number in n and prints n^2, n^3, n^4


View Solution


Program [8]

WAP to take value of x,y,z from the user and calculate the equation 


View Solution


Program [9]

WAP to take the temperatures of all 7 days of the week and displays the average temperature of that week.


View Solution


Program [10]

Python program to obtain three numbers and print their sum.


View Solution


Program [11]

Python program to obtain length and breath of a rectangle and calculate its area


View Solution


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.


View Solution


Program [13]

Write a program to input a number and print its cube.


View Solution


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.


View Solution


Program [15]

Write a program to Calculate the Compound Interest


View Solution


Program [16]

write a program to find sale price of an item with given price and discount (%)


View Solution


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))


View Solution


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




View Solution


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



View Solution


Program [20]

Program to print quotient.



View Solution


Program [21]

Write a program to obtain principal amount, rate of interest and time from user and compute simple interest.


View Solution


Program [22]

Program to calculate area and perimeter of a parallelogram


View Solution


Program [23]

 Program demonstrating working with power operator


View Solution


Program [24]

Program of division operator(/)


View Solution


Program [25]

Program of modulus


View Solution


Program [26]

Program convert dollars in Rupee 

View Solution


Program [27]

Program to convert kilometers to miles 


View Solution


Program [28]

Program to display menu to calculate are of square or rectangle 


View Solution


Program [29]

Write a program to obtain x, y, z from user and calculate expression : 4x4 + 3y3 + 9z + 6π


View Solution


Program [30]

Write a program that reads a number of seconds and prints it in form : mins and seconds, e.g., 200 seconds are printed as 3 mins and 20 seconds.

[Hint. use // and % to get minutes and seconds]


View Solution


Program [31]

Write a program to take a 2-digit number and then print the reversed number. That is, if the input given is 25, the program should print 52.


Solution


View Solution


Program [32]

Write a program to take a 3-digit number and then print the reversed number. That is, if you input 123, the program should print 321.


View Solution


Program [33]

Write a program to take two inputs for day, month and then calculate which day of the year, the given date is. For simplicity, take 30 days for all months. For example, if you give input as: Day3, Month2 then it should print "Day of the year : 33".


View Solution


Program [34]

Write a program that asks a user for a number of years, and then prints out the number of days, hours, minutes, and seconds in that number of years.


How many years? 10

10.0 years is:

3650.0 days

87600.0 hours

5256000.0 minutes

315360000.0 seconds


View Solution


Program [35]

Write a program that inputs an age and print age after 10 years as shown below:


What is your age? 17

In ten years, you will be 27 years old!


View Solution


Program [36]

Write a program to calculate the radius of a sphere whose area (4πr2) is given.


View Solution


Program [37]

Write a program to calculate the area of an equilateral triangle. (area = (√3 / 4) * side * side).


View Solution


Program [38]

Write a program to input the radius of a sphere and calculate its volume (V = 4/3πr3)


View Solution


Program [39]

Write a program to calculate amount payable after simple interest.


View Solution


CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad