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!

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

Carole Cox
Carole Cox
429 Points

Should the formula in the challenge be weeks = days /52 ?

The problem may be incorrect...just sayin...:-)

1 Answer

Chris Freeman
Chris Freeman
Treehouse Moderator 68,404 Points

The total weeks would be either the total days / 7: (years * 365) / 7,

or be the number of years * "weeks per year". While these would be close, "years * 52" would be an integer number of weeks, while dividing the total days by 7 would yield a more accurate floating point result.

>>> years = 32
>>> days = 365 * years
>>> weeks_from_days = days / 7
>>> weeks_from_years = years * 52
>>> weeks_from_years
>>> weeks_from_days
Carole Cox
Carole Cox
429 Points

Thank you! A nice expanded explanation but I think that Treehouse set the problem up wrong or worded it wrong. In real time Weeks is not days /7. In other words. My age =61 ; days =61 *365 =22,265. then Weeks would be days/52 not 7. in my case 428. Oh my! Not a big deal..it just "looks wrong". But thank you , your answer is helpful in other ways!!!

Chris Freeman
Chris Freeman
Treehouse Moderator 68,404 Points

Hey Carole, I think your math has an error.

Using "unit management" we can check our units. Starting with an initial value, then multiplying by unity values (=1) to convert to other units. Similar units values will cancel leaving the final value and units.

           365 days
61 y̶e̶a̶r̶s̶ * -------- = 22,265 days
           1 y̶e̶a̶r̶

               1 week
22,265 d̶a̶y̶s̶ * -------- = 3180.7 weeks
               7 d̶a̶y̶s̶

Checking your math, working backwards from 428 weeks:

              1 year
428 w̶e̶e̶k̶s̶ * ---------- = 8.23 years
             52 w̶e̶e̶k̶s̶

I think you may be confusing the conversion factors.. "1/52" would be a "years per weeks" conversion which doesn't help when starting with days.