Python Array Find Minimum Number Program

By | March 18, 2020

Python Array Find Minimum Number Program

 

# Write a Python program
# to input n numbers in
# python array and find minimum 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)
mini=a[0]
for item in a:
    if item<mini:
        mini=item

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

print('\nMinimum Number in array is:',mini)

# using built-in function min(array) 
print('\nMinimum Number in array is using min function:',min(a))

         

Output

Enter  size of Array=5
Enter number in array:678
Enter number in array:123
Enter number in array:90
Enter number in array:55
Enter number in array:460
Array values are: 678   123   90   55   460   
Minimum Number in array is: 55

Minimum Number in array is using min function: 55

Loading

Leave a Reply

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