-: Hi guys and welcome back.
In this video we're going to building our first app.
Think of it as a bit of a recap
of everything we've learned so far.
The app we're going to build will ask the users
for their age, and then it will tell them
how many months that age equals to.
So for example, if they enter 10, the app will say 120
because that's 12 months in each year of course.
And so let's get start by asking the user for their age,
and we will say for example, user underscore age,
and then we're gonna use the input function
to get the user's age, we'll say input Enter your age.
Then remember that this is going to give you back a string,
so we need to turn it into an integer or whole number
so that we can do maths on it.
So we will say something like years equal int of user age.
Now we're gonna calculate the months that that equals to
so that we can tell the user that information.
So we'll say months equal years times 12.
Finally, we're gonna print it out for the user to see.
So you could do just print months,
but that's not gonna tell the user a lot
about what it actually means, this variable,
unless they know what the programme does,
it's not gonna be all that helpful.
So instead, I recommend using an f string
to print the information in a bit of a readable format.
So we can say something like Your age, years,
is equal to this many months.
So if we run this file, then you get asked to enter your age
let's say 30, and then you get,
Your age, 30, is equal to 360 months.
So this is our very first application
that actually does something, and you can extend this
further and I would encourage you to do so,
just to play around with the code,
and so that instead of printing out the number of months,
you can print out the number of seconds
that this is equal to.
Of course the maths is gonna be slightly different,
you're gonna have to multiply a few more things here
to calculate the number of seconds,
but that should let you play around
with this code a little bit.
Something else that you may wanna think about,
is simplifying this code a little bit,
'cause at the moment we've got our input
and then we have this variable called user age,
the user age variable is only used
to be converted into an integer in the very next line.
So actually, we could just put the int function
around that input, so now what we're turning into an integer
is the result of calling the input function
which is gonna give us the string.
So the value the user enters will be this,
and then that will be turned into an integer.
So we actually don't need this line at all,
although we do need to use the user age
instead of the years variable.
And that is a little bit simpler,
and the reason for doing that is,
so that you don't have a variable
that is only used as a temporary measure
before it gets converted into another type,
so you can put functions inside of functions
when it makes sense, it can make your code
a little bit less readable, but in this case,
I think it's OK, it is simple enough
that it should make a lot of sense.
That's it for this video, do tackle the extension
which is to print out the number of seconds
instead of months, and I'll see you in the next one.