Program to print the smallest element in an Array in Python. The program contains array initialisation, for iterative statement and if comparative statement. This program is for Beginners, class 11,12 and B Tech computer science students.
Program to print the smallest element in an Array
What is an Array ?
A Python Array is a collection of common type of data structures having elements with same data type. It is used to store collections of data.
Source code :
a=[1,25,56,25,32,10,0,1,25] p=100 for i in range (0,len(a)): if (a[i]<p): p=a[i] print(p)
Source Code Explanation :
Step 1: An array is initialised
Step 2: A variable is assigned with a value of 100
Step 3: For loop start with zero and ends in length of array
for i in range (0,len(a)):
Step 4: Comparison operator if conditional statement
Step 5:to check which is the smallest one and to be given the value of smallest to p
Step 6:p is printed
RESTART: C:\csstudy\source code file 2\Python program to print the smallest element in an array.py 0 >>>
Output Explanation :
Here 0 is the smallest number. The loop transverse through the array and comparing each of the number whether they are lower than the comparator if it is low the number is given to the variable and the array transverse to the end of array.
The program works fine.
Thank you for learning, reading and downloading source code of Program to print the smallest element in an Array in Python. The program contains array initialisation, for iterative statements and if comparative statements. This program is for Beginners, class 11,12 and B Tech computer science students. For more program like this, class 11,12 practical program and B Tech projects are provided here. Click the below links:
Computer Science with Python Practical Book Solutions Class 11 Term -2 – CS Study
Computer Science Practical file for class 12 Term-2 – CS Study
Python Projects for Class 12 with Source Code (Mysql Connectivity) – CS Study