Find the smallest value in a list using a loop in Python: example + exercise 9

preview_player
Показать описание
#findthesmalest #python #programming #loopsinpython #loopidioms #程式設計語言 #python程式設計語言

Python tutorial in English 36
Python programming language tutorial in English

In order to find the smallest value in a list we use a loop and an "if" statement in Python.
At the very beginning we create a variable that we call "smallest", but we assign to it a very big value.
Рекомендации по теме
Комментарии
Автор

Thank you very much! nicely done ! find lowest and max is just comparing number on the opposite side of the spectrum of numbers.

nickmensah
Автор

I had to code a program that accepts many numbers as input and outputs the smallest one, this example of yours really helped me so thank you. Please make more videos:)

tsholofelosechele
Автор

I saw this video like 3 times and i couldnt understand it:
Why "smallest" is always the number "8" and not "one million? ok, I can see you have "smallest= number", and I was thinking that the first time this has to take the value of one million. because this is in third line, and not in the fourth line in the code. and when starting the bucle again, in this case the second time, now yes, this has to change a 8 by the order of the code is written.. Well, but i am thinking now that the order of the code not has to do with this.

Well if it were like this. Why always makes a comparison only with the number 8 ?
If 8<8:
if 23<8:
if 19<8:
if 57<8:

- why only takes the first number of the list, the number 8?
- and why when you have the print at the beginning, this only print the number "3", and why when you have it in the level of "if" this print 8, 8, 8, 8, 8, 3?
This is so confuse for me, please help! My mind is blowing up!

superlequack