Now it's finally time to put all of our skills to use by creating our automated
birthday wisher
which is going to send our family or friends
a "Happy Birthday" email on their birthday automatically.
Now the idea for this project actually came from my mum. Well,
inadvertently.
Now I love my mom to death and she is my biggest source of motivation and
inspiration. But on her birthday,
she always expects me to send her some form of "Happy Birthday" by like 8:00 AM
And
if I send her a message at, like, 8:05,
or 9 o'clock, God forbid,
then I am deemed as a *bad child*.
I don't know if this is true for you. Um,
maybe other Asian kids out there can relate,
but my mom has this thing about being wished a "happy birthday" promptly on her
birthday. And you know, I always remember her birthday,
but I just might remember it at 10 o'clock or, you know, at lunchtime.
And I always panic, um, thinking that I've forgotten or missed
the crucial eight o'clock in the morning time slot.
So what did I decide to do?
Um,
I decided to use Python to create a automated way of wishing her a happy
birthday at 8:00 AM on the spot or even seven o'clock or five o'clock. That way
she'll think that I wake up really early and
I am working really hard in life. But
let me demonstrate to you what this app is going to do. This is the birthday
wisher demo,
and I'm not going to show you the code in my main.py cause that is what
you're going to create.
But what I've got here is a CSV file called birthdays.csv.
Now, here, I'm going to change one of these rows of data to test it.
And I'm going to change the month to the current month
which is July and the day to the current day, which has 14.
So I'll change this
which corresponds to this column of data to 7 and then the day to 14.
And then I'm going to hit save to save that data.
And now I'm going to run this code
and what it will do is it'll check against all of these dates inside my
birthdays.csv,
it'll find that one of these rows of data actually has a month and day that
matches today.
And it will pick a random letter from one of these text files and replace this
name
placeholder with the name of the row of data that actually matched today's
date. And then it's going to send that as an email to this email.
So now if I go ahead and hit run,
and once that process is finished, we can go and check our email.
And you can see that email show up here with a subject line of Happy Birthday!,
and it's replaced the name of the person whose birthday it is right here inside
that name placeholder, it sent the rest of the message
and this was all done automatically. As you can imagine,
if I change this back to a random date,
if our code was running in the background every single day
checking to see if today's date matched one of these dates,
then the day when it actually matches or on their birthday,
it's going to pick out their name, insert it into one of these letters randomly,
and then send it to them as an email.
And the reason why we have three letters is just because so that they don't
actually clock onto the fact that it's the same letter being sent every single
year.
The ethics of this whole project is really up to you to decide. Um,
I don't actually do this in reality. Um,
I just live with being told I'm a bad child by wishing my mom happy birthday at
10:00 AM instead of 8:00 AM. But in terms of Python Programming,
this is going to be a really interesting project because it's going to use a lot
of the things that you've learned before
like pandas to read CSVs or replacing texts,
doing mail merge, using built in Python
ways of opening and reading files, and also of course what we learned recently
which is the datetime module and the smtplib.
Now the starting project I've split into three difficulty levels.
So depending on how comfortable you feel with the things that you've learned in
all of these 32 days,
you can pick which level of starting project you want to use.
Obviously, if you go for the extra hard starting project,
it's not going to have a lot of hints in there.
It's going to tell you generally what the program needs to do
and it's your job to figure out how to actually implement it using maybe a
Google search or Stack Overflow or looking through some of the path lessons.
This is going to be the extra hard version.
And then there's the hard version with some hints, but not a lot.
And there's the normal version where I've put in a lot more hints that will make
it a little bit easier for you to write out all the code.
So depending on how confident you feel, head over to the course resources,
pic the difficulty level for your starting project
and then go ahead and try to complete this project.