Help with some python homework...

sjud9227 scottwd80 at gmail.com
Fri Jan 31 01:24:01 EST 2014


On Thursday, January 30, 2014 10:30:11 PM UTC-7, Chris Angelico wrote:
> On Fri, Jan 31, 2014 at 4:12 PM,  <scottwd80 at gmail.com> wrote:
> 
> > **If I leave my house at 6:52 am and run 1 mile at an easy pace (8:15 per mile), then 3 miles at tempo (7:12 per mile) and 1 mile at easy pace again, what time do I get home for breakfast?**
> 
> >
> 
> >
> 
> >
> 
> >      seconds = 1
> 
> >      hours = seconds / (60*60)
> 
> >      seconds = seconds - hours*60*60
> 
> >      minutes = seconds / 60
> 
> >      seconds = seconds - minutes *60
> 
> >
> 
> >      time_left_house = 6 * hours + 52 * minutes
> 
> >
> 
> >      miles_run_easy_pace = 2 * (8 * minutes + 15 * seconds)
> 
> >
> 
> >      miles_run_fast_pace = 3 * (7 * minutes + 12 * seconds)
> 
> >
> 
> >
> 
> >      total_time_run = miles_run_easy_pace + miles_run_fast_pace + time_left_house
> 
> 
> 
> Thanks for being up-front about it being homework. I'll give you one
> 
> broad hint, and see if you can figure it out from there.
> 
> 
> 
> Your beginning work is not actually achieving anything useful. To make
> 
> your next steps work, what you actually want is two very simple
> 
> assignments that will mean that "6 * hours" comes out as the number of
> 
> seconds in six hours. Then, when you've added all the different pieces
> 
> together, you'll have a final time that's measured in seconds - and
> 
> since that final time includes the time_left_house, it's actually
> 
> going to be the number of seconds since midnight. This is actually an
> 
> excellent way to represent time (number of seconds since some
> 
> "beginning point" aka epoch). There's then just one last step: Convert
> 
> it into hours, minutes, and seconds, for display. You have most of the
> 
> code for doing that.
> 
> 
> 
> So, work on this in two parts. In the first part, make your program
> 
> calculate how many seconds after midnight you'll get home. (The
> 
> correct answer there is 27006, according to my calculations. Of
> 
> course, you need to have a program that produces the correct answer,
> 
> not just the answer.) Then work out how to make that display as
> 
> hh:mm:ss.
> 
> 
> 
> I think you can probably get it from there - you're already a lot of
> 
> the way toward it. But if not, you know where to find us :)
> 
> 
> 
> ChrisA

Thank you so much Chris.  However, i'm still a little confused.  Doesn't assigning seconds/(60*60) mean that calculating 6*hours will give me 6 hours in seconds?  Also, why calculate how many seconds from midnight?  wouldn't it just be from the time that you left the house at 6:52?  Also, for the life of me I cannot figure out how to make everything display in hh:mm:ss.  I realize I'm asking a lot especially do to the fact it's homework but, we are allowed help in class I just don't have class again until next Tuesday.  Plus I really do want to learn not just get the answers.



More information about the Python-list mailing list