Python Array Find Maximum Number Program

By | March 18, 2020

Python Array Find Maximum Number Program

# Write a Python program
# to input n numbers in
# python array and find maximum number

# Perfect Python Programming Tutorials
# Author : www.EasyCodebook.com (c)



# Actual Program starts here 


import array

a = array.array('i', [])

n = int(input('Enter  size of Array='))

for i in range(n):
    item= int(input("Enter number in array:"))
    a.append(item)
maxi=a[0]
for item in a:
    if item>maxi:
        maxi=item

print('Array values are:', end=' ')        
for item in a:
    print(item, end='   ')

print('\nMaximum Number in array is:',maxi)

print('\nMaximum Number in array using predefined max function is:',max(a))
         

Output

Enter  size of Array=5
Enter number in array:67
Enter number in array:8
Enter number in array:900
Enter number in array:12
Enter number in array:101
Array values are: 67   8   900   12   101   
Maximum Number in array is: 900

Maximum Number in array using predefined max function is: 900

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *