Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (2015) Python Data Types Age Calculation

Should I round?

I am doing my calculations and I keep getting the answer wrong. Should I round my number?


1 Answer

Charlie Gallentine
Charlie Gallentine
12,092 Points

So the error is not in your calculations, rather it is because you are doing them instead of the program. You are assigning values which you have calculated to "years", "days", and "weeks" instead of using them to create one another. Python will do the calculations for you with a little algebraic logic:

years = 19 # You set the initial variable, in this case your age in years
days = years * 365 # Python will calculate the number of days by multiplying "years" by 365
weeks = days / 7 # Python will calculate the number of weeks by dividing "days" by 7

I do not think you should have to do any external calculations for any of the challenges, after all, that is why we program computers to do them!

Hope that helps!