At this point, you've learned quite a bit in this course.
Hopefully you feel like you've gained
an understanding of the essentials of programming in Python.
Now, we're going to put these skills into practice,
we're going to actually write some programs here,
so that you can see how to use the things that you've learned,
and put them all together to create something.
We are going to work with dates in this project,
and because this is a very common thing that you need to do when you write scripts,
you usually have a bunch of data and when you have data,
very often, is associated with a time or a date.
So you have to think about when things happened in relationship with each other,
and you use dates to figure that out.
So, we're going to learn a bunch of different functions using dates
in Python to get you started in this whole scripting process.
So I want to walk you through the logistics of working on the project.
If we look at the project description page,
you'll see all of the instructions that you need to get started.
Now, I strongly encourage you to read the entire description first,
and then go back and start working from beginning.
First, let's talk about a few preliminaries here, okay?
You will be graded on your coding style, okay?
Programming is not just about creating something as quickly as
possible or as sloppily as possible and getting it working,
rather you need to think about how
you're writing your programs and the style with which you do so.
So, the first thing that should do is read the coding style guidelines for the class,
which explains things like you need to have,
doc strings to explain what your functions do,
you need to indent by a consistent four spaces,
you need to use good variable names, things like that, all right.
And nothing is overly complicated,
there are just a set of rules that you need to follow in order to make sure
that you generate reasonable looking code,
that other people can read and understand.
Now, some people push back a little bit on being forced to follow rigid rules,
and that the stifles of their creativity.
But I promise you that in each situation you
get in where you're working with other people,
you're going to need to agree on a set of coding style guidelines,
and work with them so that each of you can read
the other people's code that's written and understand and feel comfortable with it.
And this is very common and you're usually not
given much of a choice on what these style guidelines are.
So, this is good practice for working out with other people in the real world. All right.
Now, you also need to test your code, okay?
You should always test your code as you write it,
you shouldn't just sit down,
try to write everything and never run your code.
And at the very end, run it,
find out you have all kinds of errors that the thing that you did in the very beginning.
This causes all kinds of trouble. All right.
As you write your code,
test it as you go, okay?
If you build up a little piece of functionality, test it,
make sure it actually works then build on top of that,
so you know that you started with something working,
get something bigger working test that and so on.
All right. Now, we also are going to help you in a little bit here,
in that we're going to give you this program called OwlTest.
And throughout this course here, and throughout the project,
you're going to be using OwlTest which is a machine grading infrastructure.
What it does is it runs your program against a suite of tests that we've developed,
and it tells you how well you've done.
So this allows you to not only test your code yourself,
but also have us help you test your code so that you can see what you're doing right,
and what you're doing wrong.
Okay. And I'm going to walk you through that a little bit later.
All right. We'll actually try to use OwlTest and see what's going on there.
Okay. And I want to emphasize that OwlTest is for your use,
it's for your feedback to help you to
understand what's actually happening with your code.
It is not free to get a grade with Coursera.
We have another tool that looks almost identical to OwlTest,
that will submit your grade to Coursera.
And again I'll walk you through that in a minute. All right.
Now, the actual project itself.
Okay. We have several problems that we want you to work on.
In fact, there are four for this project.
Each one consists of a single Python function that you need to write.
Okay. They build upon each other though.
As I was saying before, don't just rush ahead and try to do everything all at once.
Work on the first problem.
Okay. Get that working.
Again once it's working,
test it on your own.
Then test an LTest,
and then make sure that your confidence's working,
and then move on to the second problem.
Okay. And if you follow that process,
you should be able to build up your code,
piece by piece, and have
a pleasant experience where you end up with something that works in the end.
Okay. And so, I'm just going to scroll through here quickly,
so you can see that there's a lot of stuff here that you should come read.
So, this is the OwlTest page.
If you click the OwlTest link in the project description,
this is what you'll see.
It's a page that says OwlTest in the upper left hand corner,
and has a pale yellow background and some information about how to submit your code,
and what's going to be tested.
Okay, so what you should do is you working along in codeskulptor,
save your work when you're ready to test it with OwlTest.
Basically, copy the URL directly out of the web browser,
and paste it right in here.
Okay. So, I have taken my code,
the URL from my code.
I've pasted the URL directly in here and I'm going
to click this button to submit to OwlTest,
and it tells me,
hey waiting for results could take a while.
And here we go, we now have results and it tells me that my score is a 20 out of 100,
I didn't do very well.
And then gives me a bunch of error messages.
Now, I encourage you to read the web page
in the Coursera site that explains these Owl testers in detail.
But generally, for each function that's going to be tested,
and it tells us up here what it's going to test,
it either will tell us nothing because we did
perfectly on that function or it'll give us one of these lines,
which tells us how many points we've lost,
and it will give me an example of one of the tests that we failed.
All right so, if we look here at the top line it
says calling age in days with the arguments (2017,
1, 1), expected 198 but received zero.
Okay. So, we run that test when that was run on my code,
I returned 0, but if I had done it correctly,
I should have returned the number 198.
All right.
Now, you need to go read
the project description to have an understanding of
what age and days were supposed to do.
And then you should hopefully be able to think about what's going on
here and understand what happened.
All right.
And also, interestingly in this particular example,
it tells you that today's date on the server.
So, it gives a way when I actually recorded this video.
Okay. So maybe you're surprised,
maybe you're not about when that date is.
Okay, that's important for this function because
this function actually uses today's date.
And given that you might be somewhere else in the world,
then where are the OwlTest server is,
it's useful to know what day OwlTest thinks it is.
And that could be off by one depending on where you are.
It's important to understand that even though OwlTest gives you a score,
that score doesn't really mean anything.
Remember I got that 20, but that's okay.
It was just in OwlTest.
Okay. This is not submitted to Coursera,
it's for your feedback and your use while you're developing your project.
And when you're ready to actually receive a grade for Coursera,
you have to come back to the Coursera page and
submit to this date' s project rate here and you will see this big green checkmark,
that means that I have already submitted.
Okay so, I improved my project a little bit better than 20.
It was kind of embarrassing for me to have such a low grade,
so I fixed it up and then I submitted it.
Now, you go here, you click on there.
It now requires you to read and understand and agree to the honor code,
confirm who you are and so on.
And then you go to a page that looks almost identical to OwlTest,
except it says Coursera LTITest and has a white background.
You submit your code exactly in the same way,
you get exactly the same feedback, except now,
because you went through here,
it knows who you are and it is able to submit your grade back to Coursera.
You can submit as many times as you like here.
If you aren't happy with your score,
you can still keep working and submit something else and improve it.
But, make sure that you don't just say, oh,
I submitted to OwlTests, I'm done,
then you come back here and you submit it to Coursera.
Now, that we have all the logistics out of the way,
I want to return briefly to what you're actually going to have to do for the project.
Okay? So, the first problem is computing the number of days in a month.
All right, and so you are going to have to write a function that's called days in month,
and you can see its signature here.
It takes two inputs a year and then month.
Okay. So could be something like 2012,
three meaning March of 2012,
and then you have to return a number that is the number of days in that particular month.
Okay. And there are some hints here,
will help you think about how to do this and I suggest that you read them.
But effectively, you want to use the python daytime module to figure out
exactly how many days were in that particular month and then return that number. Okay.
All right. Second problem,
checking if a date is valid.
For the first problem we're just going to assume
that you give me a valid year and a valid month.
Okay. You didn't enter some random number,
negative number as the year and 42 as the month.
They are years between the minimum and maximum year supported by
the Python datetime module and the month was a number between 1 and 12.
Here now, we want to say okay,
maybe we don't know that that's going to be valid. All right.
So, we are going to write a function called is valid date and that takes a year,
a month, and a day, three numbers.
Okay. That's supposed to be the year,
the month, and the day and then you're going to check.
Okay. Are these valid?
Is this a valid year?
Is this a valid month?
And is this a valid day within that particular month of that particular year?
And again, there are a few hints here that you should read. All right.
And you're going to return true if it is a valid date,
and false if it's not a valid date.
Okay. All right.
For the third problem,
you're going to compute the number of days between two dates.
So we are you going to get two dates.
Each as a year,
a month, and a day,
for three numbers and then you are going to figure out how many days there
are between your earlier date and the later date.
Okay. So date one should be earlier and date two should be later.
Okay. And if they're not,
you're just going to return zero,
or if either of those dates are invalid, you're going to return zero.
If there are two valid dates,
and the second date is after the first date,
then you are going to figure out how many days there are between them.
Okay. And you'll return that number.
And again there are a few hints. All right.
And I encourage you to read the hints and think about the hints and work on things. Okay.
And then finally, for the fourth problem,
we're going to calculate a person's age in days.
So you are going to write a function called age in days that takes one date,
and that's the person's birthday.
Okay? Year, month and the day that corresponds to their birthday, three numbers.
Make sure it's valid,
if it's not then just return zero.
But, assuming that it's valid,
then you are going to tell me how old is that person right now in days.
If the date is in the future,
that doesn't make any sense,
so you're also going to return zero.
But, as long as the day is in the past,
you should be able to figure out how many days since their birthday and today?
And you need to think about what have you already written that will help you out.
Okay. So as you work on each of these problems,
realize that you can utilize
the functions that you wrote before to actually implement it.
And again, this is why we're saying, work on them in order.
If you start with age in days, you are going to make things a lot harder for yourself,
but if you wrote all the other three functions,
age in days is actually not that difficult.
Now, I want you to recognize we're not asking you to just
start from scratch here with absolutely nothing.
If you'll notice here there's a link to
a template file right here in the project description,
and if we click this,
we're going to go to the following page.
Okay. You're going to go to a codeskulptor file that has code in it already.
Okay. It has the appropriate import of
datetime and it has all the function signatures already there.
But, you'll notice the code
doesn't do anything or at least it doesn't do anything useful.
You need to fill in the body of these functions and
make them actually compute the things they're supposed to compute,
but I don't want you starting from a blank file when working out here.
Make sure that you use the template.
At this point I hope you're very excited to get started with the project. I know I am.
And you can put into practice the things that you've learned in this course.
Just remember a few things, work on it in order.
Make sure you read everything first,
and then go through and work on things in the order that we presented them to you.
That will make it significantly easier for you to get through
the project and take less time in doing so.
It still may be difficult, all right,
but it will be far less difficult if you work on it in order.
All right? Now, also read the hints, okay?
The hints are there to help you.
Think about those hints. If you get stuck,
well that's what the discussion forums are for.
Make sure that you utilize them.
Okay. So do not worry, do not panic,
just be methodical, think through clearly,
work through things, read through things,
ask many questions in the discussion forums as you need to,
and I'm sure you are going to be able to get it, all right?
I look forward to your project submissions.