00:01
We are going to retype the following code and fix the indentation as necessary to make the program work.
00:09
And here we have inside these quotes in green we have a piece of code which we recognize the python code.
00:20
So we have if the string new york is in if string in temperatures column, if temperatures at the string new york greater than 90.
00:33
Column printed city is melting the string else print another string the temperature in new york is and temperatures at the string new york else column print that string is temperature in new york is unknown so several things here we have a first if statement and it has associated a column which is expected and then here we should have a line break with an indentation indicating that the next instruction, which is again an if statement, is inside this if statement here.
01:22
So we have a line break here, we have indentation, and then if temperatures at new york greater 90, and because we have another if, we have a column associated to it.
01:35
So we have a land break here and an indentation, we're respect to this if, that is with the column where the eye of the if is located, and we have a print associated to that if statement, that is this instruction inside the if statement.
01:55
And when python finds this else statement, it will associate it to this if, the inner if.
02:04
So the inner if is going to be close with this else statement, and because it's an else statement, it has also its column and then line break.
02:17
And a indentation to indicate that this print statement is inside the else statement.
02:27
Okay, so we recognize in this print statement here that it has two parameters, the string, the temperature in new york is, and then accessing this element.
02:39
Element in this tree new york.
02:42
We're going to talk that in a minute.
02:45
As you can see, there is another else which is going to be associated with this if here.
02:52
So let's say this if goes with this else because the if the inner if here has been closed already with this else because it is closed with the first else we are going to find.
03:08
And then the other else here is going to close here is going to close the outer if here we found at first place so this else statement has is column as expected and here is a line break and an indentation indicating that brain statement is inside the second else so we get something like this let me see this way we can see both to indicate what i said before so we have let me the screen now we have one thing we recognize when we use a variable like this, temperatures, and we access that not in an index, but in a string, we're talking about a dictionary.
04:04
So here we have a dictionary because we can have strings as the key values of a dictionary, and that's what happened here.
04:19
So temperatures is the noise.
04:21
Name of the variable that contains a dictionary and we expect new york to be or not to be in that dictionary.
04:33
So the shape of the dictionary the key values are the name of the cities which are strings and the values the numbers are temperature so we have something like this.
04:47
Variable temperature here i have assigned the dictionary not to simplify a little bit the the answer but because if we put an input it's going to be more involved so i have assigned the dictionary directly on the variable temperatures so we have here the three cities with three temperatures london 55 madrid 78 and new york 86 in this dictionary which is a save on the variable temperatures.
05:26
That's exactly what we expect here.
05:30
The variable is temperatures and we access that using score bracket in the key values, which are the names of the cities which are in fact strings.
05:42
Perfect.
05:43
So the first if here, this one here is this one over here, if new york in temperatures is very fine is the name of the city, the string in new york, written this way.
06:00
It's very important that it's case sensitive in python...