You are on page 1of 23

PYTHON

ASSIGNMENT
4/30/2020

NAME:-ANURANJITA KUND
ROLL NO:-374007
REGD NO:-1805105007
SEMESTER:-4TH
BRANCH:-MCA
FUNCTION

1. Wap to create a list of prime Fibonacci series between user defined range and default
range is 10 to 50 using defaunt arguments,required argument,kegyword araguments and
function?
Program:-
def isPrime(x):
count=0
if x>1:
for i in range(1,x+1):
if x%i==0:
count=count+1
if count==2:
return True
def FiboAndPrime(a=10,b=50):
l=[]
lp=[]
n1=0
n2=1
l.append(n1)
l.append(n2)
for i in range(2,b):
n3=n1+n2
l.append(n3)
n1=n2
n2=n3
for i in range(len(l)):
x=l[i]
if x>=a and x<b:
if isPrime(x)==True:
lp.append(x)
return lp

a=int(input('Enter the upper Limit:'))


b=int(input('Enter the Lower Limit:'))
l1=l2=l3=[]
l1=FiboAndPrime(a,b)
print("The list of Prime Fibonascci series using postional argument is:",l1)
l2=FiboAndPrime(b=40,a=20)
print("The list of Prime Fibonascci series using keyword argument is:",l2)
l3=FiboAndPrime()
print("The list of Prime Fibonascci is using default argument is:",l3)
Output:-
Enter the upper Limit:0
Enter the Lower Limit:10
The list of Prime Fibonascci series using postional argument is: [2, 3, 5, 8]
The list of Prime Fibonascci series using keyword argument is: [21, 34]
The list of Prime Fibonascci is using default argument is: [13, 21, 34]
2. Wap to chech wheather a number is Armstrong number or not using defaunt
arguments,required argument,kegyword araguments and function?
Program:-
def Armstrong(num=153):
res=num
sum=0
while(num!=0):
d=num%10
sum=sum+d*d*d
num=num//10
if res==sum:
print('Armstrong....')
else:
print('Not Armstrong....')
num=int(input('Enter a number:'))
print('Checking using positional argument.....')
Armstrong(num)
print('Checking using keyword argument.....')
Armstrong(num=121)
print('Checking using default argument.....')
Armstrong()
Output:-
Enter a number:370
Checking using positional argument.....
Armstrong....
Checking using keyword argument.....
Not Armstrong....
Checking using default argument.....
Armstrong....
3. Wap to chech wheather a number is palindrome number and divisible by 3 and 5 or not
using defaunt arguments,required argument,kegyword araguments and function?
Program:-
def Palindrome(num=111):
res=num
sum=0
while(num!=0):
d=num%10
sum=d+sum*10
num=num//10
if res==sum :
print('Palindrome ')
if sum%3==0 and sum%5==0:
print('Divisible by 3 and 5')
else:
print('Not divisible by 3 and 5')
else:
print('Not Palindrome and not divisible by 3 and 5....')
num=int(input('Enter a number:'))
print('Checking using positional argument.....')
Palindrome(num)
print('Checking using keyword argument.....')
Palindrome(num=121)
print('Checking using default argument.....')
Palindrome()
Output:-
Enter a number:121
Checking using positional argument.....
Palindrome
Not divisible by 3 and 5
Checking using keyword argument.....
Palindrome
Not divisible by 3 and 5
Checking using default argument.....
Palindrome
Not divisible by 3 and 5
4. Wap to find repeated elements and no of repeated elements in the list of 20 user defined
values and also remove redundant values and update list with unique values only using
required arguments and pass by reference?
Program:-
def Rep(l):
rep={}
res=[]
for i in range(20):
for j in range(i+1,20):
if l[i]==l[j]:
rep[l[i]]=l.count(l[i])
print('The repeated elements in the list is:\n')
for k,v in rep.items():
print(k,' is repeated ',v,'times')
for i in l:
if i not in res:
res.append(i)
print('The unique elements after removing duplicate elements in the list is:',res)
l=[]
for i in range(20):
x=int(input('Enter number in list:'))
l.append(x)
Rep(l)
Output:-
Enter number in list:5
Enter number in list:5
Enter number in list:5
Enter number in list:5
Enter number in list:1
Enter number in list:1
Enter number in list:1
Enter number in list:7
Enter number in list:7
Enter number in list:7
Enter number in list:9
Enter number in list:9
Enter number in list:9
Enter number in list:5
Enter number in list:5
Enter number in list:2
Enter number in list:2
Enter number in list:2
Enter number in list:2
Enter number in list:6
The repeated elements in the list is:

5 is repeated 6 times
1 is repeated 3 times
7 is repeated 3 times
9 is repeated 3 times
2 is repeated 4 times
The unique elements after removing duplicate elements in the list is: [5, 1, 7, 9, 2, 6]
5. Wap to create biodata of a student using variable length argument function in cv format
available in ms doc?
Program:-
def f1(**kwargs):
print('*'*30)
print('CV')
print('*'*30)
for key,value in kwargs.items():
print(key,':',value)

student={}
roll=input('Enter the roll no:')
regd=input('Enter the regd no:')
phone=input('Enter the phone no:')
name=input("Enter the name:")
branch=input('Enter the Branch:')
stream=input('Enter the Stream:')
sem=input('Enter the Semester:')
add=input('Enter the Address:')
f1(Name=name,Roll_no=roll,Regd_no=regd,Phone_no=phone,Branch=branch,Stream=stream,Semem
ster=sem,Address=add)
Output:-
Enter the roll no:374007
Enter the regd no:1805105007
Enter the phone no:987654321
Enter the name:Anuranjita Kund
Enter the Branch:MCA
Enter the Stream:MCA
Enter the Semester:4TH
Enter the Address:PURI
******************************
CV
******************************
Name : Anuranjita Kund
Roll_no : 374007
Regd_no : 1805105007
Phone_no : 987654321
Branch : MCA
Stream : MCA
Sememster : 4TH
Address : PURI
6. Wap to find factorial of a number using while loop,do while loop and for loop and
keyword arguments function?
Program:-
def Factorial(a,b,c):
print('Factorial of a number using While Loop....')
fact=1
n=a
while a>0:
fact=fact*a
a=a-1
print('Factorial of {} is::{}'.format(n,fact))

print('Factorial of a number using do While Loop....')


fact=1
n=b
while True:
fact=fact*b
b=b-1
if b==0:
break
print('Factorial of {} is:: {}'.format(n,fact))

print('Factorial of a number using For Loop....')


fact=1
for i in range(1,c+1):
fact=fact*i
print('Factorial of {} is:: {}'.format(c,fact))
n1=int(input('Enter a number to find factorial using while loop:'))
n2=int(input('Enter a number to find factorial using Do while loop:'))
n3=int(input('Enter a number to find factorial using For loop:'))
Factorial(a=n1,b=n2,c=n3)
Output:-
Enter a number to find factorial using while loop:5
Enter a number to find factorial using Do while loop:4
Enter a number to find factorial using For loop:3
Factorial of a number using While Loop....
Factorial of 5 is::120
Factorial of a number using do While Loop....
Factorial of 4 is:: 24
Factorial of a number using For Loop....
Factorial of 3 is:: 6
7. Wap to search position of element in the list of 20 user defined values using binary serach
and function?
Program:-
def binarySearch(l,a,b,num):
if b>=1:
mid=(a+b)//2
if l[mid]==num:
return mid
elif l[mid]>num:
return binarySearch(l,a,mid-1,num)
elif l[mid]<num:
return binarySearch(l,mid+1,b,num)
else:
return -1
l=[]
for i in range(20):
x=int(input('Enter number in list:'))
l.append(x)
l.sort()
num=int(input('Enter the element to be searched::'))
res=binarySearch(l,0,len(l)-1,num)
if res!=-1:
print("The position of searched number is {}".format(res))
else:
print("The number is not found in the given list...")
Output:-
Enter number in list:10
Enter number in list:20
Enter number in list:30
Enter number in list:40
Enter number in list:50
Enter number in list:60
Enter number in list:70
Enter number in list:80
Enter number in list:90
Enter number in list:100
Enter number in list:11
Enter number in list:22
Enter number in list:33
Enter number in list:44
Enter number in list:55
Enter number in list:66
Enter number in list:77
Enter number in list:88
Enter number in list:99
Enter number in list:110
Enter the element to be searched::90
The position of searched number is 16
8. Wap to find area,perimeter of rectangle,square,triangle having 3 sides using keyword
arguments with function?
Program:-
from math import *
def areaPerimeterRectangle(l,b):
print('Area of rectangle is:',l*b)
print('Perimeter of rectangle is:',2*(l+b))
def areaPerimeterCircle(r):
print('Area of the circle is::',pi*r**2)
print('Perimeter of the circle is::',2*pi*r)
def areaPerimeterTriangle(a,b,c):
s=(a+b+c)/2
area=sqrt(s*(s-a)*(s-b)*(s-c))
print('Area of the triangle is::',area)
print('Primeter of the triangle is::',(a+b+c))
x=int(input('Enter the length of the reactangle:::'))
y=int(input('Enter the breadth of the reactangle:::'))
areaPerimeterRectangle(l=x,b=y)
x=int(input('Enter the radius of the circle:::'))
areaPerimeterCircle(r=x)
x=int(input('Enter the side1 of the triangle:::'))
y=int(input('Enter the side2 of the triangle:::'))
z=int(input('Enter the side3 of the triangle:::'))
areaPerimeterTriangle(a=x,b=y,c=z)
Output:-
Enter the length of the reactangle:::2
Enter the breadth of the reactangle:::3
Area of rectangle is: 6
Perimeter of rectangle is: 10
Enter the radius of the circle:::2
Area of the circle is:: 12.566370614359172
Perimeter of the circle is:: 12.566370614359172
Enter the side1 of the triangle:::2
Enter the side2 of the triangle:::3
Enter the side3 of the triangle:::4
Area of the triangle is:: 2.9047375096555625
Primeter of the triangle is:: 9
9. WAP to swap two numbers using anonymous or lambda function?
Program:-
a=int(input('Enter the value of a::'))
b=int(input('Enter the value of b::'))
x=lambda a,b:a+b
y=lambda a,b:a-b
z=lambda a,b:a-b
print('Before Swapping\na={} b={}'.format(a,b))
a=x(a,b)
b=y(a,b)
a=z(a,b)
print('After Swapping\na={} b={}'.format(a,b))
Output:-
Enetr the value of a::5
Enter the value of b::6
Before Swapping
a=5 b=6
After Swapping
a=6 b=5
10. Wap to perform all arithmetic operations using anonymous or lambda function?
Program:-
a=int(input('Enter the value of a:::'))
b=int(input('Enter the value of b:::'))
p=lambda a,b:a+b
q=lambda a,b:a-b
r=lambda a,b:a*b
s=lambda a,b:a/b
t=lambda a,b:a//b
u=lambda a,b:a**b
v=lambda a,b:a%b
print('Addition::',p(a,b))
print('Subtraction::',q(a,b))
print('Multiplication::',r(a,b))
print('Floating Division::',s(a,b))
print('Floor Division::',t(a,b))
print('Exponent::',u(a,b))
print('Modulous Division::',v(a,b))
Output:-
Enter the value of a:::5
Enter the value of b:::6
Addition:: 11
Subtraction:: -1
Multiplication:: 30
Floating Division:: 0.8333333333333334
Floor Division:: 0
Exponent:: 15625
Modulous Division:: 5

MODULE

1. WAP to create scientific calculator and perform all aritmetic operations like
sum,substraction,division,multiplication,modulus,power,sqrt,cubic root,sinx,cos x,tanx,log
x,exp x,absolute value of x using function and module?
Program:-
Calculation.py
from math import *
def Addition(a,b):
return (a+b)
def Subtraction(a,b):
return (a-b)
def Multiplication(a,b):
return (a*b)
def Division(a,b):
return (a//b)
def Modulous(a,b):
return (a%b)
def Power(a,b):
return (pow(a,b))
def SquareRoot(a):
return (sqrt(a))
def CubeRoot(a):
return (abs(a)**(1./3.))
def SinVal(a):
return (sin(a))
def CosVal(a):
return (cos(a))
def TanVal(a):
return (tan(a))
def LogVal(a,b):
return (log(a,b))
def ExpVal(a):
return (exp(a))
def AbsoluteVal(a):
return (abs(a))
Module1.py
from Calculation import *
while True:
opt=input('Enter the Arthematic operation you want to
perform\n[Addition/Subtraction/Product/ModulousDivision/Division/AbsoluteValue/Power/SquareR
oot/CubicRoot/Sin/Cosine/Tan/LogarithmValue/Exponentvalue]::')
if opt.lower()=='addition':
a=int(input('Enter the value of a::'))
b=int(input('Enter the value of b::'))
print('Sum=',Addition(a,b))
elif opt.lower()=='subtraction':
a=int(input('Enter the value of a::'))
b=int(input('Enter the value of b::'))
print('Difference=',Subtraction(a,b))
elif opt.lower()=='product':
a=int(input('Enter the value of a::'))
b=int(input('Enter the value of b::'))
print('Product=',Multiplication(a,b))
elif opt.lower()=='modulousdivision':
a=int(input('Enter the value of a::'))
b=int(input('Enter the value of b::'))
print('Modulous Division=',Modulous(a,b))
elif opt.lower()=='division':
a=int(input('Enter the value of a::'))
b=int(input('Enter the value of b::'))
print('Division=',Division(a,b))
elif opt.lower()=='absolutevalue':
a=int(input('Enter the value of a::'))
print('Absolute Value=',AbsoluteVal(a))
elif opt.lower()=='power':
a=int(input('Enter the value of a::'))
b=int(input('Enter the value of b::'))
print('Power Value=',Power(a,b))
elif opt.lower()=='squareroot':
a=int(input('Enter the value of a::'))
print('Square Root=',SquareRoot(a))
elif opt.lower()=='cubicroot':
a=int(input('Enter the value of a::'))
print('Cube Root=',CubeRoot(a))
elif opt.lower()=='sinvalue':
a=int(input('Enter the value of a::'))
print('Sin Value=',SinVal(a))
elif opt.lower()=='cosinevalue':
a=int(input('Enter the value of a::'))
print('Cosine Value=',CosVal(a))
elif opt.lower()=='tanvalue':
a=int(input('Enter the value of a::'))
print('Tan Value=',TanVal(a))
elif opt.lower()=='logarithmvalue':
a=int(input('Enter the value of a::'))
b=int(input('Enter the value of b::'))
print('Logarithm Value=',LogVal(a,b))
elif opt.lower()=='exponentvalue':
a=int(input('Enter the value of a::'))
print('Exponent Value=',ExpVal(a))
else:
break
Output:-
Enter the Arthematic operation you want to perform
[Addition/Subtraction/Product/ModulousDivision/Division/AbsoluteValue/Power/SquareRoot/CubicR
oot/Sin/Cosine/Tan/LogarithmValue/Exponentvalue]::addition
Enter the value of a::5
Enter the value of b::6
Sum= 11
Enter the Arthematic operation you want to perform
[Addition/Subtraction/Product/ModulousDivision/Division/AbsoluteValue/Power/SquareRoot/CubicR
oot/Sin/Cosine/Tan/LogarithmValue/Exponentvalue]::subtraction
Enter the value of a::6
Enter the value of b::4
Difference= 2
Enter the Arthematic operation you want to perform
[Addition/Subtraction/Product/ModulousDivision/Division/AbsoluteValue/Power/SquareRoot/CubicR
oot/Sin/Cosine/Tan/LogarithmValue/Exponentvalue]::product
Enter the value of a::6
Enter the value of b::5
Product= 30
Enter the Arthematic operation you want to perform
[Addition/Subtraction/Product/ModulousDivision/Division/AbsoluteValue/Power/SquareRoot/CubicR
oot/Sin/Cosine/Tan/LogarithmValue/Exponentvalue]::modulousdivision
Enter the value of a::10
Enter the value of b::4
Modulous Division= 2
Enter the Arthematic operation you want to perform
[Addition/Subtraction/Product/ModulousDivision/Division/AbsoluteValue/Power/SquareRoot/CubicR
oot/Sin/Cosine/Tan/LogarithmValue/Exponentvalue]::power
Enter the value of a::2
Enter the value of b::3
Power Value= 8.0
Enter the Arthematic operation you want to perform
[Addition/Subtraction/Product/ModulousDivision/Division/AbsoluteValue/Power/SquareRoot/CubicR
oot/Sin/Cosine/Tan/LogarithmValue/Exponentvalue]::cubicroot
Enter the value of a::8
Cube Root= 2.0

2. WAP to perform following comutation on stack using function like push, pop, isempty,
isfull, peak and use function and module

I. Create an stack of user defined size using list


II. Insert 20 user defined values in the stack using is full and push operation in
stack
III. Search for an user defined element in the stack using peak operation of stack
IV. Delete 5 elements from stack using pop opeartion
V. Display all remaig elements of stack

Program:-

Stack.py
def is_empty(stack):

if len(stack)==0:

return True

else :

return False

def is_full(stack):

if len(stack)==20:

return True

else:
return False

def push(stack,element):

stack.append(element)

def pop(stack):

return stack.pop()

def peek(stack,pos):

return stack[pos]

Module2.py
from stack import *

size=int(input('Enter the size of the stack::'))

stack=[]

while(True):

operation=input('Enter your option[Push/Pop/Peek/Display/Exit...]')

if operation.lower()=='push':

if is_full(stack)==True:

print('Stack is Full....')

else:

for i in range(20):

x=int(input('Enter your element:::'))

push(stack,x)

elif operation.lower()=='pop':

if is_empty(stack)==True:

print('Stack is empty...')

continue

else:

for i in range(5):

ele=pop(stack)

print('The poped element is::',ele)

elif operation.lower()=='peek':

x=int(input('Enter the element to be searched:::'))

flag=False

for i in range(len(stack)):

if x==peek(stack,i):
print('Element is present in the stack....')

flag=True

break

else:

continue

if flag!=True:

print('Element not found in the stack....')

elif operation.lower()=='display':

print(stack)

else:

break

Output:-
Enter the size of the stack::20

Enter your option[Push/Pop/Peek/Display/Exit...]push

Enter your element:::32

Enter your element:::21

Enter your element:::65

Enter your element:::54

Enter your element:::98

Enter your element:::87

Enter your element:::10

Enter your element:::20

Enter your element:::30

Enter your element:::14

Enter your element:::25

Enter your element:::36

Enter your element:::17

Enter your element:::28

Enter your element:::39

Enter your element:::47

Enter your element:::58

Enter your element:::69


Enter your element:::75

Enter your element:::95

Enter your option[Push/Pop/Peek/Display/Exit...]pop

The poped element is:: 95

The poped element is:: 75

The poped element is:: 69

The poped element is:: 58

The poped element is:: 47

Enter your option[Push/Pop/Peek/Display/Exit...]pop

The poped element is:: 39

The poped element is:: 28

The poped element is:: 17

The poped element is:: 36

The poped element is:: 25

Enter your option[Push/Pop/Peek/Display/Exit...]display

[32, 21, 65, 54, 98, 87, 10, 20, 30, 14]

Enter your option[Push/Pop/Peek/Display/Exit...]peek

Enter the element to be searched:::98

Element is present in the stack....

Enter your option[Push/Pop/Peek/Display/Exit...]peek

Enter the element to be searched:::29

Element not found in the stack....

3. WAP to perform following comutation on queue using function like insert, delete, isempty,
isfull, peak and use function and module

VI. Create an queue of user defined size using list


VII. Insert 20 user defined values in the queue using is full and insert operation in
stack
VIII. Search for an user defined element in the queue using peak operation of stack
IX. Delete 5 elements from queue using delete opeartion
X. Display all remaig elements of queue

Program:-

Queue.py
def is_empty(queue):

if len(queue)==0:
return True

else :

return False

def is_full(queue):

if len(queue)==20:

return True

else:

return False

def insert(queue,element):

queue.append(element)

def delete(queue):

return queue.pop(0)

def peek(queue,pos):

return queue[pos]

Module3.py
from queue import *

size=int(input('Enter the size of the queue::'))

queue=[]

while(True):

operation=input('Enter your option[Insert/Delete/Peek/Display/Exit...]')

if operation.lower()=='insert':

if is_full(queue)==True:

print('Queue is Full....')

else:

for i in range(20):

x=int(input('Enter your element:::'))

insert(queue,x)

elif operation.lower()=='delete':

if is_empty(queue)==True:

print('Queue is empty...')

continue

else:

for i in range(5):
ele=delete(queue)

print('The deleted element is::',ele)

elif operation.lower()=='peek':

x=int(input('Enter the element to be searched:::'))

flag=False

for i in range(len(queue)):

if x==peek(queue,i):

print('Element is present in the queue....')

flag=True

break

else:

continue

if flag!=True:

print('Element not found in the queue....')

elif operation.lower()=='display':

print(queue)

else:

break

Output:-
Enter the size of the queue::20

Enter your option[Insert/Delete/Peek/Display/Exit...]insert

Enter your element:::21

Enter your element:::32

Enter your element:::36

Enter your element:::25

Enter your element:::14

Enter your element:::17

Enter your element:::28

Enter your element:::39

Enter your element:::71

Enter your element:::82

Enter your element:::93


Enter your element:::14

Enter your element:::25

Enter your element:::36

Enter your element:::41

Enter your element:::52

Enter your element:::63

Enter your element:::15

Enter your element:::35

Enter your element:::75

Enter your option[Insert/Delete/Peek/Display/Exit...]delete

The deleted element is:: 21

The deleted element is:: 32

The deleted element is:: 36

The deleted element is:: 25

The deleted element is:: 14

Enter your option[Insert/Delete/Peek/Display/Exit...]delete

The deleted element is:: 17

The deleted element is:: 28

The deleted element is:: 39

The deleted element is:: 71

The deleted element is:: 82

Enter your option[Insert/Delete/Peek/Display/Exit...]display

[93, 14, 25, 36, 41, 52, 63, 15, 35, 75]

Enter your option[Insert/Delete/Peek/Display/Exit...]peek

Enter the element to be searched:::15

Element is present in the queue....

Enter your option[Insert/Delete/Peek/Display/Exit...]peek

Enter the element to be searched:::10

Element not found in the queue....

4. WAP to perform following using module and function for deposit,withdraw,check balance for
banking application

I. Assign a fixed value as balance for account


II. Deposit user defined amount and display updated balance
III. Withdraw user defined money if user has sufficient fund otherwise shoe
insufficient fund
IV. Check for balance
V. Maintain a fixed amount 3000 in the accpunt

Program:-

BankApplication.py
def deposite(amount,balance):

return (balance+amount)

def withdraw(amount,balance):

if (balance-amount)>=3000:

return balance-amount

else:

return balance

Module4.py
from BankApplication import *

balance=float(input('Enter the fixed value for account::'))

while True:

operation=input('Enter the operation to perform[Deposite/Withdraw/CheckBalance/Eixt]')

if operation.lower()=='deposite':

amount=float(input('Enter the amount to deposite::'))

balance=deposite(amount,balance)

print('{} amount is deposited in your account.The updated balance is


{}'.format(amount,balance))

elif operation.lower()=='withdraw':

amount=float(input('Enter the amount to withdraw::'))

bal=withdraw(amount,balance)

if bal!=balance:

print('{} amount is deducted from your account...'.format(amount))

balance=bal

else:

print('Sufficient balance is not available in your account....')

elif operation.lower()=='checkbalance':

print('The avaliable balance is::',balance)

else:
break

Output:-
Enter the fixed value for account::3000

Enter the operation to perform[Deposite/Withdraw/CheckBalance/Eixt]deposite

Enter the amount to deposite::5000

5000.0 amount is deposited in your account.The updated balance is 8000.0

Enter the operation to perform[Deposite/Withdraw/CheckBalance/Eixt]withdraw

Enter the amount to withdraw::2000

2000.0 amount is deducted from your account...

Enter the operation to perform[Deposite/Withdraw/CheckBalance/Eixt]checkbalance

The avaliable balance is:: 6000.0

Enter the operation to perform[Deposite/Withdraw/CheckBalance/Eixt]withdraw

Enter the amount to withdraw::4000

Sufficient balance is not available in your account....

5. Wap to compute factorial,GCD,LCM,sqrt without using any library function,swap two number
without using 3rd variable using function and module?

Program:-

Compute.py
def factorial(num):

fact=1

if num==0:

return 1

else:

for i in range(1,num+1):

fact=fact*i

return fact

def GCD(num1,num2):

while(num2):

num1,num2=num2,num1%num2

return num1

def LCM(num1,num2):

if num1>num2:

max=num1
else:

max=num2

while True:

if (max%num1 ==0 and max%num2 ==0):

return max

break

max=max+1

def swap(num1,num2):

num1,num2=num2,num1

return num1,num2

def squareroot(num):

return num**(1/2)

Module5.py
from compute import *

while(True):

opt=input('Enter the option to compute[factorial/GCD/LCM/squareroot/swap/exit]')

if opt.lower()=='factorial':

num=int(input('Enter the number to find the factorial::'))

print('Fact=',factorial(num))

elif opt.lower()=='gcd':

num1=int(input('Enter the value of num1::'))

num2=int(input('Enter the value of num2::'))

print('The GCD of two numbers is::',GCD(num1,num2))

elif opt.lower()=='lcm':

num1=int(input('Enter the value of num1::'))

num2=int(input('Enter the value of num2::'))

print('The LCM of two numbers is::',LCM(num1,num2))

elif opt.lower()=='squareroot':

num=int(input('Enter the number to find the squarerrot::'))

print('Square Root=',squareroot(num))

elif opt.lower()=='swap':

num1=int(input('Enter the value of num1::'))

num2=int(input('Enter the value of num2::'))


print('Before swapping :::num1={} and num2={}'.format(num1,num2))

print('After Swapping ::::')

num1,num2=swap(num1,num2)

print('num1={} and num2={}'.format(num1,num2))

else:

break

Output:-
Enter the option to compute[factorial/GCD/LCM/squareroot/swap/exit]factorial

Enter the number to find the factorial::5

Fact= 120

Enter the option to compute[factorial/GCD/LCM/squareroot/swap/exit]gcd

Enter the value of num1::3

Enter the value of num2::6

The GCD of two numbers is:: 3

Enter the option to compute[factorial/GCD/LCM/squareroot/swap/exit]lcm

Enter the value of num1::2

Enter the value of num2::4

The LCM of two numbers is:: 4

Enter the option to compute[factorial/GCD/LCM/squareroot/swap/exit]squareroot

Enter the number to find the squarerrot::9

Square Root= 3.0

Enter the option to compute[factorial/GCD/LCM/squareroot/swap/exit]swap

Enter the value of num1::5

Enter the value of num2::6

Before swapping :::num1=5 and num2=6

After Swapping ::::

num1=6 and num2=5

You might also like