Professional Documents
Culture Documents
Assignment 5 ML Imdad Ullah
Assignment 5 ML Imdad Ullah
Assignment No 5
BY
IMDAD ULLAH
MS COMPUTER SCIENCE
SUBMITTED TO
SIR MUHAMMAD HARIS SHAMS
Dated: 21/12/2021
My_List1=[8,25,200]
print (My_List1)
maximum=(max(My_List1))
print (maximum)
My_List2=[1,2,3,10,12,0,20]
print (My_List2)
Addition=sum(My_List2)
print(Addition)
3. Write a Python function to multiply all the numbers in a list.
import numpy
My_List3=[8,2,3,-1,7,4,5]
print (My_List3)
Product=numpy.prod(My_List3)
print(Product)
def My_Function(x):
return x[::-1]
print(My_Text)
5. Write a Python function to calculate the factorial(recursive function) of a number (a non-negative
integer). The function accepts the number as an argument.
def factorial(n):
p=1
i=1
while i<=n:
p= p*i
i+=1
return p
factorial(4)