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

Python Codes

The document is a programming assignment by Shivamraje Mohan Deokar for a 9th-grade A.I. class, containing various mathematical operations implemented in code. It includes a table of contents with 19 different tasks, such as adding numbers, calculating averages, and finding areas and volumes. Each task is accompanied by code snippets and example outputs demonstrating the functionality.

Uploaded by

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

Python Codes

The document is a programming assignment by Shivamraje Mohan Deokar for a 9th-grade A.I. class, containing various mathematical operations implemented in code. It includes a table of contents with 19 different tasks, such as adding numbers, calculating averages, and finding areas and volumes. Each task is accompanied by code snippets and example outputs demonstrating the functionality.

Uploaded by

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

Welcom

e
Name :- Shivamraje Mohan
Deokar
Class :- 9th Modesty
Roll no :- M918
Subject :- A.I. (417)

1
INDEX
____________________________________________
[Link]. Title Page
_____________________________________________
01) To add 2 no 3
_____________________________________________
02) To add 4 no 4
_____________________________________________
03) To multiply 3 no 5
_____________________________________________
04) Average of 5 no 6
_____________________________________________
05) Age after 15 years 7
_____________________________________________
06) A cube no 8
_____________________________________________
07) Area of a square 9

2
_____________________________________________
08) Area of a rectangle 10
_____________________________________________
_____________________________________________
[Link]. Title Page

09) x**N or pow(x,n) 11


_____________________________________________
10) Perimeter of a rectangle 12
_____________________________________________

11) Area of a circle 13


_____________________________________________

12) Circumference 14
_____________________________________________

13) Converting hours and minutes


into seconds 15
_____________________________________________

14) Increasing 25% of the cost 16


_____________________________________________

15) A square no 17
_____________________________________________

16) Volume of a sphere 18


_____________________________________________

3
17) Area of a triangle using
heron's formula 19
_____________________________________________

18) Compound interest 20


_____________________________________________

19) Average of marks and percentage 21

4
1)To add 2 no
Code :-
print ('to add 2 no.')
a = eval(input('Enter your first no. '))
b = eval(input('Enter your second no. '))
r = a+b
print ('The sum of the numbers is ',r,)

Output :-
to add 2 no.
Enter your first no. 1234
Enter your second no. 5678
The sum of the numbers is 6912

5
2)To add 4 no

Code :-

print ('to add 4 no.')


a = eval (input('Enter your first no. '))
b = eval (input('Enter your second no. '))
c = eval (input('Enter your third no. '))
d = eval (input('Enter your fourth no. '))
r = a+b+c+d
print ('The sum of the numbers is ',r)

Output :-

to add 4 no.
Enter your first no. 12
Enter your second no. 34
Enter your third no. 56
Enter your fourth no. 78
The sum of the numbers is 180

6
3)To multiply 3 no

Code :-

print ('to multiply 3 no.')


a = eval(input('Enter your first no. '))
b = eval(input('Enter your second no. '))
c = eval(input('Enter your third no. '))
r = a*b*c
print ('The product of the numbers is ',r)

Output :-

to multiply 3 no.
Enter your first no. 12
Enter your second no. 34
Enter your third no. 56
The product of the numbers is 22848

7
4)Average of 5 no

Code :-

print ('avg of 5 no.')


a = eval(input('Enter your first no. '))
b = eval(input('Enter your second no. '))
c = eval(input('Enter your third no. '))
d = eval(input('Enter your fourth no. '))
e = eval(input('Enter your fifth no. '))
r = (a+b+c+d+e)/5
print ('The average of the numbers is ',r)

Output :-

avg of 5 no.
Enter your first no. 1
Enter your second no. 2
Enter your third no. 3
Enter your fourth no. 4
Enter your fifth no. 5
The average of the numbers is 3.0

8
5)Age after 15 years

Code :-

print ('age after 15 years')


age = int(input('Enter your age '))
new_age = age+15
print ('Your age after 15 years is ',new_age,'years')

Output :-

age after 15 years


Enter your age 12
Your age after 15 years is 27 years

9
6) A cube no

Code :-

print ('a cube no.')


a = eval(input('Enter your no. '))
r = a**3
print ('The cube of the number is ',r)

Output :-

a cube no.
Enter your no. 123
The cube of the number is 1860867

10
7)Area of a square

Code :-

print('area of a square')
a=eval(input('Enter the lenght of the square '))
area=a**2
print('The area of the square is ',r,'[Link]')

Output :-

area of a square
Enter the lenght of the square 12
The area of the square is 144 [Link]

11
8)Area of a rectangle

Code :-

print ('area of a rectangle')


a = eval(input('Enter the lenght of the rectangle '))
b = eval(input('Enter the breadth of the rectangle '))
area = a*b
print ('The area of the rectangle is ',area,'[Link]')

Output :-

area of a rectangle
Enter the lenght of the rectangle 12
Enter the breadth of the rectangle 34
The area of the rectangle is 408 [Link]

12
9)x**N or pow(x,n)

Code :-

print ('x**N or pow(x,n)')


a = eval(input('Enter your base no.(X) '))
b = eval(input('Enter your exponent no.(N)'))
r = a**b
print ('the answer is ',r,'\n')

Output :-

x**N or pow(x,n)
Enter your base no.(X) 12
Enter your exponent no.(N)34
the answer is
4922235242952026704037113243122008064

13
10) Perimeter of a rectangle

Code :-

print ('perimeter of a rectangle')


a = eval(input('Enter the lenght of the rectangle '))
b = eval(input('Enter the breadth of the rectangle '))
perimeter = 2*(a+b)
print ('The perimeter of the rectangle is
',perimeter,'units')

Output :-

perimeter of a rectangle
Enter the lenght of the rectangle 12
Enter the breadth of the rectangle 34
The perimeter of the rectangle is 92 units

14
11) Area of a circle

Code :-

print ('area of a circle')


r = eval(input('Enter the radius of the circle '))
area = 3.14*r*r
print ('The area of the circle is ',area,'square units')

Output :-

area of a circle
Enter the radius of the circle 12
The area of the circle is 452.15999999999997
square units

15
12) Circumference

Code :-

print ('circumference')
r = eval(input('Enter the radius of the circle '))
circumference = 2*3.14*r
print ('The circumference of the circle is
',circumference, 'units')

Output :-

circumference
Enter the radius of the circle 12
The circumference of the circle is 75.36 units

16
13) Converting hours and minutes into seconds

Code :-

print ('converting hours and minutes into seconds')


hours = eval(input('enter hour/s'))
minutes = eval(input('enter minute/s'))
seconds = eval(input('enter second/s'))
hours = hours*60*60
minutes = minutes*60
total_seconds = hours+minutes+seconds
print ('the time in seconds is ',total_seconds,'sec')

Output :-

converting hours and minutes into seconds


enter hour/s12
enter minute/s34
enter second/s56
the time in seconds is 45296 sec

17
14) Increasing 25% of the cost

Code :-

print ('increasing 25% of the cost')


cost = eval(input('Enter cost '))
new_cost = cost+cost*0.25
print ('the new cost after increasing 25%
is',new_cost,'bucks')

Output :-

increasing 25% of the cost


Enter cost 123456
the new cost after increasing 25% is 154320.0 bucks

18
15) A square no

Code :-

print ('square no.')


a = eval(input('Enter your no. '))
r = a**2
print ('The square of the number is ',r)

Output :-

square no.
Enter your no. 123
The square of the number is 15129

19
16) Volume of a sphere

Code :-

print ('volume of a sphere')


r = eval(input('enter the radius of the sphere'))
vol = (4/3)*3.14*r**3
print ('the volume opf the sphere is ',vol,'cube
units')

Output :-

volume of a sphere
enter the radius of the sphere123
the volume opf the sphere is 7790829.84 cube units

20
17) Area of a triangle using heron's formula

Code :-

print ("area of a triangle using heron's formula")


a = eval(input('Enter the first side of the triangle '))
b = eval(input('Enter the second side of the triangle
'))
c = eval(input('Enter the third side of the triangle '))
s = (a+b+c)/2 e=s*(s-a)*(s-b)*(s-c) area=e**0.5
print ("The area of the triangle using hero's formula
is ",area,'[Link]')

Output :-

area of a triangle using heron's formula


Enter the first side of the triangle 12
Enter the second side of the triangle 34
Enter the third side of the triangle 56
The area of the triangle using hero's formula is
(2.5177216270654654e-14+411.17514516322603j)
[Link]

21
18) Compound interest

Code :-

print ('Compound interest')


p = eval(input('Enter the principal amount '))
r = eval(input('Enter the rate of interest '))
t = eval(input('enter the time in years '))
ci = p*(1+(r/100))**t
print ('the compound interest for the given values
is', ci)

Output :-

Compound interest
Enter the principal amount 1234567
Enter the rate of interest 12
enter the time in years 1
the compound interest for the given values is
1382715.04

22
19) Average of marks and percentage

Code :-
print ('average of marks and percentage')
s1 = float(input("Enter your English Marks : "))
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)/5
print (' the average of marks ', avg , 'and percentage is',
percentage )

Output :-

average of marks and percentage


Enter your English Marks : 40
Enter your Physics Marks : 40
Enter your Chemistry Marks : 40

23
Enter your Maths Marks : 40
Enter your Biology Marks : 40
the average of marks 40.0 and percentage is 4000.0

24

You might also like