My homework is asking me to: Define a function make_birthday_intro()
that takes in two arguments: a name (string), and a birth date (date).
You should utilize your make_introduction()
function from Part 1! You may need to calculate a variable to pass into that function call.
Hint: use the relativedelta()
function to calculate the person's current age, as well as when they will turn 1 year older. You can get the number of days or years from a relativedelta
value (e.g., time_difference) by accessing the .days or .years properties (e.g., time_difference.years).
And the second part
Create a variable my_bday_intro
by calling your make_birthday_intro()
function and passing in your name (already a variable!) and your birthdate. Print the variable after you create it.
My tutor and I really struggled to work this out together but I believe part of the problem was that we didn't work through part one of the assignment together so he didn't fully understand this part of the assignment which I realized later may be part of why we were getting so stuck, we were missing a variable. I can't figure out where to even start with the second part of the assignment because we got so stuck on the make_birthday_intro portion.
my make_introduction code from part 1 including all code leading up to it
my_name = "Kaitlyn Griffith"
print(my_name)
my_age = 24
print(my_age)
def make_introduction(my_name, my_age):
return "Hello, my name is, " + my_name + " and I'm " + str(my_age) + " years old."
My attempt at the homework problem
import datetime
def make_birth_intro(name, date_of_birth):
age = datetime.date.today() - date_of_birth
print(age)
dateThing = datetime.date(1995, 2, 10)
make_birth_intro(make_introduction, dateThing)
I'm not sure where to start with the second part of the assignment
This function should return a string of the format "Hello, my name is {NAME} and I'm {AGE} years old. In {N} days I'll be {NEW_AGE}" (replacing {NAME}, {AGE}, {N}, and {NEW_AGE} with appropriate values).
Where it should ready "Hello, my name is Kaitlyn and I'm 24 years old. In 274 days I'll be 25"
however, my current output is:
8857 days, 0:00:00
And I am honestly not sure what I should be looking for in the second part