00:01
We want to write a programming python that takes a date as input and outputs to date season.
00:09
The input is a string to represent the month and an int to represent the day.
00:17
Check if the string and int are valid.
00:22
So we have an input which is a date, which have two parts the month on the day, number of the day.
00:29
And we check that information correct to be correct and then verify the date.
00:35
For that we need the seasons landmarks which are following.
00:41
Spring, spring corresponds to or goes through march 20 to june 20th also.
01:03
Then we have a summer from june 21.
01:12
Let's see if we have the next day just after this 20 here, june 21 through september 21 then autumn or fall is from september 22 the very next day from this one through december 2020 and finally we have winter from december 21 the next day after this through march 19 which is the day before this one here so these are our seasons, file, and date.
02:13
And here we have a solution.
02:15
We're going to look now.
02:19
So we start by asking the user to enter data, consistent of, there would be a date, consistent of a month's name, or day number.
02:31
So we read that data with this input here.
02:38
But at the same time that the thing we read from input, we split that.
02:46
And split, remember, is using the separator space, as blank space, to find the paths that conform this string.
02:57
We get to remember when we use input in python, everything is read as a string.
03:05
And split uses by the full the blank space to separate the parts that it can be inside a string.
03:17
So we do that split directly here after the input by in this dot syntax.
03:24
And that is going into the variable my date.
03:29
And now we see if we have two parts in the separation with it here with split, that is if the length of the array in my page is not two we say message error data is incredibly structured and stop the program execution so we always expect two paths to compose the input data now we are going to see we can work with these two parts the first part corresponds is we is hope that corresponds to a month name.
04:12
So we lower that because we want to work with the lower name of the month without taking in care of the case of the letters.
04:25
That is we can input that in all capital letters or the first letter in capitals or all in lower letters so we can put the name of the month anyway.
04:42
So to do that, we lower what we read from the input and then it doesn't matter how it was entered.
04:52
That's why we do that lower function applied to the string mitate zero, which is the first part of the data that the user entered.
05:01
If the user enter any other thing, it doesn't matter because lower is going to work only on letters.
05:08
If there are other type of characters lower two and nothing on your scale, characters.
05:14
So that is put in the variable month.
05:17
So for the moment we are not verifying that that's correct, is the name of the month's correctly spelled.
05:27
For the moment we are not doing that.
05:30
We only know we lowered the letters.
05:34
We put them in lower case.
05:36
And now we try to see if we can convert the second part that is might date 1 into an integer number.
05:44
And for that we try doing the conversion with the int function, put that in the variable day.
05:52
And if that doesn't work, then we know there was an error, any type, and we'll say invalid because the data is not correct in any case.
06:05
So here we are going to set the correspondence of the month, and put that in a list.
06:10
The list is called month and we put the card to spell names of each of the month in order because we're going to use that information but this is very important here to put the month in order january february march etc up to december and this is a list because we put that into a square bracket and it's important that because we know the list is accessed by indices starting from index zero for the first element, one to the second, and so on.
06:46
Now we said the maximum number of days for each month.
06:50
In fact, for any months except for february, these are the exact number of any of the months.
06:58
February can have 28 or 29.
07:01
That's why we say the maximum is 29 the maximum, but it doesn't matter that i say the maximum for the other month, because for the other months is exactly the number of days.
07:13
For those months.
07:15
And we call that nom names month.
07:19
And it is kind of correspondence with months with the previous list because if we access months and nom days months at the zero position, we know that 31 is the number of dates of january, if we access the second, 29, the maximum number of days of february and so on.
07:41
So there is a correspondence between any months and things.
07:45
Could then be corresponding non -day months at the same index position.
07:52
Okay, having that, that's going to help us to solve a problem, these two lists here...