0% found this document useful (0 votes)
5 views2 pages

Python Basic Math Operations Guide

Assignment__1_on_Basic_Programs_Solution

Uploaded by

atharvagupta2025
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Python Basic Math Operations Guide

Assignment__1_on_Basic_Programs_Solution

Uploaded by

atharvagupta2025
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

#1)to add 2 no. print('The area of the rectangle is ',area,'sq.

units')
print('to add 2 no.')
a=eval(input('Enter your first no. ')) #9)x**N or pow(x,n)
b=eval(input('Enter your second no. ')) print('x**N or pow(x,n)')
r=a+b a=eval(input('Enter your base no.(X) '))
print('The sum of the numbers is ',r,) b=eval(input('Enter your exponent no.(N) '))
r=a**b
#2)to add 4 no. print('the answer is ',r,'\n')
print('to add 4 no.')
a=eval(input('Enter your first no. ')) #10)perimeter of a rectangle
b=eval(input('Enter your second no. ')) print('perimeter of a rectangle')
c=eval(input('Enter your third no. ')) a=eval(input('Enter the lenght of the rectangle '))
d=eval(input('Enter your fourth no. ')) b=eval(input('Enter the breadth of the rectangle '))
r=a+b+c+d perimeter=2*(a+b)
print('The sum of the numbers is ',r) print('The perimeter of the rectangle is ', perimeter, 'units')

#3)to multiply 3 no. #11) area of a circle


print('to multiply 3 no.') print('area of a circle')
a=eval(input('Enter your first no. ')) radius=eval(input('Enter the radius of the circle '))
b=eval(input('Enter your second no. ')) area=3.14*r*r
c=eval(input('Enter your third no. ')) print('The area of the circle is ',area,'square units')
r=a*b*c
print('The product of the numbers is ',r) #12)circumference
print('circumference')
#4) avg of 5 no. radius=eval(input('Enter the radius of the circle '))
print('avg of 5 no.') circumference=2*3.14*r
a=eval(input('Enter your first no. ')) print('The circumference of the circle is
b=eval(input('Enter your second no. ')) ',circumference,'units')
c=eval(input('Enter your third no. '))
d=eval(input('Enter your fourth no. ')) #13)swaping two variables
e=eval(input('Enter your fifth no. ')) print('swaping two variables')
r=(a+b+c+d+e)/5 a=eval(input('Enter your first no. '))
print('The average of the numbers is ',r) b=eval(input('Enter your second no. '))
print('a=',a,'\n b=',b)
#5) age after 15 yrs a+=b a,b=b,a
print('age after 15 yrs') b=a-b (python way of doing
age=int(input('Enter your age ')) a=a-b swaping, shotcut &easy)
nage=age+15 print('a=',a,'\n b=',b)
print('Your age after 15 years is ',nage,'years')
#14)converting hours and minutes into seconds
#6) a cube no. print('converting hours and minutes into seconds')
print('a cube no.') hours=eval(input('enter hour/s'))
a=eval(input('Enter your no. ')) minutes=eval(input('enter minute/s'))
r=a**3 seconds=eval(input('enter second/s'))
print('The cube of the number is ',r) hours=hours*60*60
minutes=minutes*60
#7)area of a square tseconds=hours+minutes+seconds
print('area of a square') print('the time in seconds is ',tseconds,'sec')
a=eval(input('Enter the lenght of the square '))
area=a**2 #15)increasing 25% of the cost
print('The area of the square is ',r,'[Link]') print('increasing 25% of the cost')
cost=eval(input('Enter cost '))
#8)area of a rectangle ncost=cost+cost*0.25
print('area of a rectangle') print('the new cost after increasing 25% is', ncost, 'Rs')
a=eval(input('Enter the lenght of the rectangle '))
b=eval(input('Enter the breadth of the rectangle '))
area=a*b
#16) a square no. #23)simple interest
print('square no.') print('simple interest')
a=eval(input('Enter your no. ')) p=eval(input('Enter the principal amount '))
r=a**2 r=eval(input('Enter the rate of interest '))
print('The square of the number is ',r) t=eval(input('enter the time in years '))
si=(p*r*t)/100
#17)volume of a sphere print('the simple interest for the given values is',si,'Rs')
print('volume of a sphere')
radius=eval(input('enter the radius of the sphere')) #24)gross salary
vol=(4/3)*3.14*r**3 print('gross salary')
print('the volume opf the sphere is ',vol,'cube units') basic=eval(input('enter your basic salary '))
da=eval(input('enter da '))
#18)area of a triangle using heron's formula pf=eval(input('enter pf '))
print("area of a triangle using heron's formula") hra=eval(input('enter hra '))
a=eval(input('Enter the first side of the triangle ')) gs=basic-pf+da+hra
b=eval(input('Enter the second side of the triangle ')) print('gross salary =',gs)
c=eval(input('Enter the third side of the triangle '))
s=(a+b+c)/2
e=s*(s-a)*(s-b)*(s-c) #25) solving a quadratic equation
area=e**0.5 print('solving a quadratic equation')
print("The area of the triangle using hero's formula is a=eval(input('Enter a '))
",area,'[Link]') b=eval(input('Enter b '))
c=eval(input('Enter c '))
#19)Compound interest print(a,'x^2+',b,'x+',c)
print('Compound interest') d=b**2-4*a*c
p=eval(input('Enter the principal amount ')) x1=(-b+(d**0.5))/(2*a)
r=eval(input('Enter the rate of interest ')) x2=(-b-(d**0.5))/(2*a)
t=eval(input('enter the time in years ')) print('the roots of the quadratic equation formed
ci=p*(1+(r/100))**t are',x1,'and',x2)
print('the compound interest for the given values
is',ci,'bucks') #26)conversion from kilometer to miles
print('conversion from kilometer to miles')
#20)average of marks and percentage km=eval(input('Enter a distance in kilometer/s '))
print('average of marks and percentage') miles=km*0.621
s1=float(input("Enter your English Marks : ")) print(km,'Km =',miles,'mile/s')
s2=float(input("Enter your Physics Marks : "))
s3=float(input("Enter your Chemistry Marks : "))
s4=float(input("Enter your Maths Marks : "))
s5=float(input("Enter your Biology Marks : "))
total=s1+s2+s3+s4+s5
avg=total/5
percentage=(total*100)/500
print('the average is',avg,'\n the percentage
is',percentage,'%')

#21)conversion from fahrenheit to centigrade


print('conversion from fahrenheit to centigrade')
f=eval(input('Enter the temprature in farenheit '))
c=(5/9)*(f-32)
print('the temperature in centigrade is ',c,'°C')

#22)conversion from centigrade to fahrenheit


print('conversion from centigrade to fahrenheit ')
c=eval(input('Enter the temprature in centigrade '))
f=(9/5*c)+32
print('the temperature in farenheit is ',f,'°F')

You might also like