Python Record-1 Removed
Python Record-1 Removed
Code:
def cumulative_product(list1):
p=1
for i in list1:
p=p*i
print(p)
return p
l=[1,2,3,4,5,6,7,8,9,10]
result=cumulative_product(l)
print(result)
OUTPUT:
VNRVJIET Sheet No: ………..
Name of the Experiment : __________________
Name of the Laboratory :
Python Programming Laboratory Experiment No.___ Date: 22/05/23
2. Aim :- To write a function reverse to print the given list in reverse order.
Code :
def reverse(list1):
new=list1[::-1]
return new
l=[1,2,3,4,5,6,7,8,9]
result=reverse(l)
print(result)
OUTPUT:
Code-1:
import math
gcd=math.gcd(54,24)
print(gcd)
lcm=(54*24)/gcd
print(lcm)
OUTPUT:
VNRVJIET Sheet No: ………..
Name of the Experiment : __________________
Name of the Laboratory :
Python Programming Laboratory Experiment No.___ Date: 22/05/23
Code-2:
def compute_gcd(x,y):
while(y):
x,y=y,x%y
return x
gcd=compute_gcd(54,24)
print(gcd)
OUTPUT:
Code-3:
def gcd(m,n):
if m<n:
(m,n)=(n,m)
if (m%n)==0:
return n
else:
return gcd(n,m%n)
res=gcd(54,24)
print(res)
OUTPUT:
VNRVJIET Sheet No: ………..
Name of the Experiment : __________________
Name of the Laboratory :
Python Programming Laboratory Experiment No.___ Date: 22/05/23
Code-4:
def compute_lcm(x,y):
lcm=(x*y)//compute_gcd(x,y)
return lcm
res=compute_lcm(54,24)
print(res)
OUTPUT:
Code-5:
def compute_lcm1(x,y):
if x>y:
greater=x
else:
greater=y
while(True):
if ((greater%x==0) and (greater%y==0)):
lcm=greater
break
greater=greater+1
return lcm
res=compute_lcm1(54,24)
print(res)
OUTPUT: