#user defined function
def max_min(n):
ls=[]
for i in range(n):
nu=int(input("enter the number"))
ls.append(nu)
print(ls)
l=ls[0]
for j in range(n):
if(ls[j]>l):
l=ls[j]
print("larger=",l)
s=ls[0]
for j in range(n):
if(ls[j]<s):
s=ls[j]
print("smaller=",s)
#main program
n=int(input("Enter the size of the list="))
max_min(n)
output
Enter the size of the list=4
enter the number6
enter the number8
enter the number2
enter the number3
[6, 8, 2, 3]
larger= 8
smaller= 2
def max_min(n):
ls=[]
for i in range(n):
nu=int(input("enter the number"))
ls.append(nu)
print(ls)
l=ls[0]
for j in range(n):
if(ls[j]>l):
l=ls[j]
print("larger=",l)
s=ls[0]
for j in range(n):
if(ls[j]<s):
s=ls[j]
print("smaller=",s)
#main program
n=int(input("Enter the size of the list="))
max_min(n)
output
Enter the size of the list=4
enter the number6
enter the number8
enter the number2
enter the number3
[6, 8, 2, 3]
larger= 8
smaller= 2
No comments:
Post a Comment