00:01
We want to write a python program that reads a list of integers into a list of python as long as the integers are greater than zero.
00:11
That is, as long as the integers are positive, and then outputs the smallest and largest integers in the list.
00:20
So here we have a python code that solve the problem, and we start by initializing an empty list, where we are going to store all the positive the user is going to enter by the screen or by the keyboard and we do that with an infinite loop here while true is going to be an infinite loop and we are going to stop that when the user enters an integer number that is zero or negative while the integer number is positive we put that number into the list which is storing the variable my list okay so we ask the user to enter a positive into the number and press enter.
01:13
And we say to the user that if he or she enters a negative into the number or zero, the process of entering numbers is going to stop.
01:32
So we read the value from the keyboard with the input function.
01:37
And then we use a try -except block in order to verify that we have an interest.
01:42
Integer number there and at this time we don't know if the interior is positive, negative or zero.
01:50
What we are interesting at this moment here is to check if the parsing function in it can convert the expression read from the keyboard, which in general is read as a string with the input function here, is in fact an integer number.
02:11
So if the tri -block succeeds, that is if the value variable can be obtained from the string, we can see that the variable we are using is the same.
02:27
So when we call the transformation function int or conversion function, then here we have a stream, but then at the end if the function succeeds, or if we can transform the string to an into the number, then here the variable value, the same variable, will hold the integer number, not the string.
02:54
And in that case, that it should sit, then it goes to the line 18.
03:06
Okay, so, oh sorry, not to the light 18 because we have an else clause in the tri -except block.
03:16
When we have an else clause in the trixat block, that's the instruction where we go when the tri -block is positive.
03:29
That is when the string can be converted into an integer number, then we go to the else part of the tri -exet block and we check for that number to be positive.
03:44
If the number is positive, then we append that number to the list.
03:48
That is, we put it at the end of the list.
03:53
And if the number is negative or zero, that is the else case here, we break the y loop.
04:04
That is, we go to line, in this case, we go to line 18, meaning we have ended the process of taking number from the user.
04:15
Okay, if the track set block is not succeed, that is, we can.
04:20
Cannot convert the string value into a number, then we go to the except bar and we print the message you have to enter a positive into your number and try again.
04:32
And because the else part is not executed in that case, that is in the case we enter the except part, then we are going to repeat the loop.
04:43
That is, we're going to ask the user to enter into a number and press enter.
04:48
So this first part here from line three to line, 17, we are in a loop and an infinite loop to read positive into the numbers from the screen or from the keyboard.
05:05
If the string cannot be converted into a number, we say that to the user, we warn the user, and then we ask again a value, another value.
05:18
If the values can be converted into an integer, then we check the value to be positive.
05:24
If we should be positive, if it is, then we put it into the list at the end.
05:28
And if not, we go to line 18, meaning we have entered the user has, have entered negative value or zero in order to stop the process of entering numbers...