0% found this document useful (0 votes)
4 views10 pages

Python Practicals

The document contains several Python programs that demonstrate basic programming concepts. It includes programs for summing three numbers, finding the largest of three numbers, performing arithmetic operations based on user input, calculating areas and circumferences based on a menu, and a menu-driven program for generating multiplication tables, Fibonacci series, and factorials. Each program is accompanied by example outputs to illustrate their functionality.

Uploaded by

vaigha837
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)
4 views10 pages

Python Practicals

The document contains several Python programs that demonstrate basic programming concepts. It includes programs for summing three numbers, finding the largest of three numbers, performing arithmetic operations based on user input, calculating areas and circumferences based on a menu, and a menu-driven program for generating multiplication tables, Fibonacci series, and factorials. Each program is accompanied by example outputs to illustrate their functionality.

Uploaded by

vaigha837
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

1.

Write a simple python program to obtain three numbers and print their
sum.

PROGRAM:-
a=int(input('ENTER YOUR FIRST NUMBER:'))
b=int(input('ENTER YOUR SECOND NUMBER'))
c=int(input('ENTER YOUR THIRD NUMBER:'))
print('THE SUM OF',a,'+',b,'+',c,'=',a+b+c)

1|Page
OUTPUT:-
ENTER YOUR FIRST NUMBER:21
ENTER YOUR SECOND NUMBER67
ENTER YOUR THIRD NUMBER:69
THE SUM OF 21 + 67 + 69 = 157

2|Page
2. Write a Python program to find the largest among the three input
numbers using
if-elif-else ladder.

PROGRAM:-

n1=int(input('ENTER YOUR FIRST NUMBER:'))


n2=int(input('ENTER YOUR SECOND NUMBER;'))
n3=int(input('ENTER YOUR THIRD NUMBER:'))
if n1>n2:
print(n1,'is greatest among them')
elif n2>n3:
print(n2,'is the greateest among them')
else:
print(n3 , 'is the greatest among them')

3|Page
OUTPUT:-

ENTER YOUR FIRST NUMBER:2


ENTER YOUR SECOND NUMBER;3
ENTER YOUR THIRD NUMBER:4
4 is the greatest among them

4|Page
3. Write a Python program that reads two numbers and an arithmetic
operator and
display the results.

PROGRAM:-

a=int(input('ENTER YOUR FIRST NUMBER :'))


b=int(input('ENTER YOUR SECOND NUMBER:'))
c=input('ENTER YOUR ARITHMETIC OPERATOR:')
if c=='+':
print('The sum of ',a,'and',b,'is:',a,'+',b,'=',a+b)
elif c=='-':
print('The difference of',a,'and',b,'is:',a,'-',b,'=',a-b)
elif c=='X':
print('The product of',a,'and',b,'is:',a,'X',b,'=',a*b)
elif c=='/':
print('The quotient of',a,'and',b,'is:',a,'/',b,'=',a/b)
elif c=='//':
print('The floor division of ',a,'and',b,'is:',a,'//',b,'=',a//b)
elif c=='%':
print('The modulus of', a,'and',b,'is:',a,'%',b,'=',a%b)
elif c=='**':
print('The exponentiation of',a,'and',b,'is:',a,'**',b,'=',a**b)
else:
print('ARITHMETIC OPERATOR NOT FOUND')

5|Page
OUTPUT:-

ENTER YOUR FIRST NUMBER :2


ENTER YOUR SECOND NUMBER:3
ENTER YOUR ARITHMETIC OPERATOR:X
2X3=6

6|Page
4. Write a Python program to perform the following task according to
user’s choice
using menu:
a) Area of Circle
b) Area of Rectangle
c) Circumference of Circle
d)Area of Square

PROGRAM:-
while True:
print('MENU')
print('a)Area of a circle')
print('b)Area of rectangle')
print('c)Circumferefnce of circle')
print('d)Area of square')
n=input('Enter the operation from the menu given options (a to d):')
if n== 'a':
r1=int(input('enter the radius'))
print('THE AREA OF THE CIRCLE IS:',3.14*r1**2)
elif n== 'b':
l=int(input('enter the length of the rectangle:'))
b=int(input('enter th breadth of the rectangle:'))
print('THE AREA OF RECATANGLE IS:',l*b)
elif n=='c':
r2=int(input('enter the radius of the circle:'))
print('THE CIRCUMFERENCE O THE CIRCLE IS :',2*3.14*r2)
elif n=='d':
s=int(input('enter the side length of the square:'))
print('THE AREA OF THE SQUARE IS :',s**2)
else:
print('invalid')
break
print('Thank you')

7|Page
OUTPUT:-
MENU
a)Area of a circle
b)Area of rectangle
c)Circumferefnce of circle
d)Area of square
Enter the operation from the menu given options (a to d):a
enter the radius1
THE AREA OF THE CIRCLE IS: 3.14
MENU
a)Area of a circle
b)Area of rectangle
c)Circumferefnce of circle
d)Area of square
Enter the operation from the menu given options (a to d):b
enter the length of the rectangle:2
enter th breadth of the rectangle:3
THE AREA OF RECATANGLE IS: 6
MENU
a)Area of a circle
b)Area of rectangle
c)Circumferefnce of circle
d)Area of square
Enter the operation from the menu given options (a to d):c
enter the radius of the circle:4
THE CIRCUMFERENCE O THE CIRCLE IS : 25.12
MENU
a)Area of a circle
b)Area of rectangle
c)Circumferefnce of circle
d)Area of square
Enter the operation from the menu given options (a to d):d
enter the side length of the square:5
THE AREA OF THE SQUARE IS : 25
MENU

8|Page
a)Area of a circle
b)Area of rectangle
c)Circumferefnce of circle
d)Area of square
Enter the operation from the menu given options (a to d):t
invalid
Thank you

9|Page
5. Write a Python program to perform the following task according to
user’s choice
using menu:
1)Print the multiplication table of a number.
2)Print the Fibonacci series up to a certain limit.
3)Find the factorial of a given number.

PROGRAM:-

10 | P a g e

You might also like