Professional Documents
Culture Documents
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
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))
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
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 *
stack=[]
while(True):
if operation.lower()=='push':
if is_full(stack)==True:
print('Stack is Full....')
else:
for i in range(20):
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)
elif operation.lower()=='peek':
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:
elif operation.lower()=='display':
print(stack)
else:
break
Output:-
Enter the size of the stack::20
[32, 21, 65, 54, 98, 87, 10, 20, 30, 14]
3. WAP to perform following comutation on queue using function like insert, delete, isempty,
isfull, peak and use function and module
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 *
queue=[]
while(True):
if operation.lower()=='insert':
if is_full(queue)==True:
print('Queue is Full....')
else:
for i in range(20):
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)
elif operation.lower()=='peek':
flag=False
for i in range(len(queue)):
if x==peek(queue,i):
flag=True
break
else:
continue
if flag!=True:
elif operation.lower()=='display':
print(queue)
else:
break
Output:-
Enter the size of the queue::20
[93, 14, 25, 36, 41, 52, 63, 15, 35, 75]
4. WAP to perform following using module and function for deposit,withdraw,check balance for
banking application
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 *
while True:
if operation.lower()=='deposite':
balance=deposite(amount,balance)
elif operation.lower()=='withdraw':
bal=withdraw(amount,balance)
if bal!=balance:
balance=bal
else:
elif operation.lower()=='checkbalance':
else:
break
Output:-
Enter the fixed value for account::3000
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:
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):
if opt.lower()=='factorial':
print('Fact=',factorial(num))
elif opt.lower()=='gcd':
elif opt.lower()=='lcm':
elif opt.lower()=='squareroot':
print('Square Root=',squareroot(num))
elif opt.lower()=='swap':
num1,num2=swap(num1,num2)
else:
break
Output:-
Enter the option to compute[factorial/GCD/LCM/squareroot/swap/exit]factorial
Fact= 120