Suppose we have a list x = [43,34,22,32,62,12]. Write a Python program to figure out the smallest number in the list without using the min() function.
Hint: similar to page 8 on the slide. You can use an arbitrary large number as the temporary smallest number to start the program. Such as temp_smallest = 100.
x = [43,34,22,32,62,12]
#considering a large number to be the minimum
min_term = 999999
#iterating to each element of the list
for i in x:
#checking if the element is smaller than the min_term
if i < min_term:
#if true, then our new minimum value is the current element
min_term = i
print("Minimum in the list is: ", min_term)
IF THERE IS ANYTHING THAT YOU DO NOT UNDERSTAND, OR NEED MORE HELP THEN PLEASE MENTION IT IN THE COMMENTS SECTION.
Get Answers For Free
Most questions answered within 1 hours.