Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65187

Re: Help with some python homework...

Subject Re: Help with some python homework...
From Scott W Dunning <swdunning@cox.net>
Date 2014-01-31 17:35 -0700
References <02c4c69d-71f1-4a01-86df-d4d5a7ffb3f5@googlegroups.com> <Ldu81n00V3bjUJS01duAN7>
Newsgroups comp.lang.python
Message-ID <mailman.6258.1391232938.18130.python-list@python.org> (permalink)

Show all headers | View raw


So, this is what I came up with.  It works, which is good but it’s a little different from a few things you guys had mentioned.  For one, I got the correct time by calculating the number of time run and converting that into seconds then back out to hr:mn:sc.  I didn’t calculate from midnight.  That seemed more complicated to me because I’d have to figure the number of seconds from midnight to 6:52am then do the calculations for number of seconds run until I got home, then I got kind of lost.  Also, before I forget what is the difference between / and //?  I remember somthing about floor division?  Not sure what that means though.  Is it like a % where it gives the remainder after dividing?  Thanks again.  Code below.  Also, I think I found out through a little trial and error that I had two different hours, mins, and sec so I had to use one uppercase and one lower case.  Is that frowned upon?  And should I have come up with a different name instead?

SECONDS = 1
MINUTES = 60 * SECONDS
HOURS = 60 * MINUTES

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)

time_returned_home = miles_run_easy_pace + miles_run_fast_pace + time_left_house

hours = time_returned_home // HOURS
part_hour = time_returned_home % HOURS
minutes = part_hour // MINUTES
seconds = part_hour % MINUTES

print "Time returned home:", hours,":", minutes,":", seconds,"am"




On Jan 31, 2014, at 6:51 AM, Neil Cerutti <neilc@norwich.edu> wrote:

> On 2014-01-31, scottwd80@gmail.com <scottwd80@gmail.com> wrote:
>> Here is the question that was asked and below that I'll paste
>> the code I have so far.
>> 
>> **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?**
> 
> That depends on the directions in which you run. Also, you are
> fast!
> 
> But seriously, my advice is to find the answer the old fashioned
> way first, with pencil and paper. Then you'll have two things you
> don't now:
> 
> 1. A correct answer to test your program's answer with.
> 2. A general idea of how to solve the problem.
> 
> It's often a mistake to start writing code. Eventually you'll be
> able to go directly from problem to code more often, but it will
> take practice.
> 
> -- 
> Neil Cerutti
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Help with some python homework... scottwd80@gmail.com - 2014-01-30 21:12 -0800
  Re: Help with some python homework... Chris Angelico <rosuav@gmail.com> - 2014-01-31 16:30 +1100
    Re: Help with some python homework... sjud9227 <scottwd80@gmail.com> - 2014-01-30 22:24 -0800
      Re: Help with some python homework... Chris Angelico <rosuav@gmail.com> - 2014-01-31 17:38 +1100
        Re: Help with some python homework... sjud9227 <scottwd80@gmail.com> - 2014-01-30 22:48 -0800
      Re: Help with some python homework... Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-01-31 21:17 +1300
        Re: Help with some python homework... Chris Angelico <rosuav@gmail.com> - 2014-01-31 19:30 +1100
          Re: Help with some python homework... Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-01-31 23:46 +1300
        Re: Help with some python homework... Chris Angelico <rosuav@gmail.com> - 2014-02-01 11:57 +1100
        Re: Help with some python homework... Chris Angelico <rosuav@gmail.com> - 2014-02-01 12:34 +1100
        Re: Help with some python homework... David <bouncingcats@gmail.com> - 2014-02-01 14:17 +1100
        Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-01-31 18:14 -0700
          Re: Help with some python homework... Denis McMahon <denismfmcmahon@gmail.com> - 2014-02-01 19:32 +0000
            Re: Help with some python homework... David Hutto <dwightdhutto@gmail.com> - 2014-02-02 17:12 -0800
              Re: Help with some python homework... Larry Hudson <orgnut@yahoo.com> - 2014-02-02 23:48 -0800
        Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-01-31 17:46 -0700
        Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-01-31 17:42 -0700
        Re: Help with some python homework... David <bouncingcats@gmail.com> - 2014-02-01 17:13 +1100
        Re: Help with some python homework... Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-02-01 10:44 -0500
  Re: Help with some python homework... Neil Cerutti <neilc@norwich.edu> - 2014-01-31 13:51 +0000
  Re: Help with some python homework... Denis McMahon <denismfmcmahon@gmail.com> - 2014-02-01 03:02 +0000
  Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-01-31 17:35 -0700
  Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-01-31 22:18 -0700
    Re: Help with some python homework... Denis McMahon <denismfmcmahon@gmail.com> - 2014-02-01 19:45 +0000
    Re: Help with some python homework... David Hutto <dwightdhutto@gmail.com> - 2014-02-02 08:11 -0800
      Re: Help with some python homework... David Hutto <dwightdhutto@gmail.com> - 2014-02-02 08:36 -0800
      Re: Help with some python homework... MRAB <python@mrabarnett.plus.com> - 2014-02-02 16:38 +0000
        Re: Help with some python homework... David Hutto <dwightdhutto@gmail.com> - 2014-02-02 08:57 -0800
          Re: Help with some python homework... Denis McMahon <denismfmcmahon@gmail.com> - 2014-02-02 17:43 +0000
            Re: Help with some python homework... David Hutto <dwightdhutto@gmail.com> - 2014-02-02 10:09 -0800
            Re: Help with some python homework... David Hutto <dwightdhutto@gmail.com> - 2014-02-02 11:08 -0800
              Re: Help with some python homework... David Hutto <dwightdhutto@gmail.com> - 2014-02-02 11:21 -0800
    Re: Help with some python homework... "Rhodri James" <rhodri@wildebst.org.uk> - 2014-02-02 17:15 +0000
  Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-01-31 22:04 -0700
  Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-01-31 17:07 -0700
  Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-01-31 22:19 -0700
  Re: Help with some python homework... Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-02-01 10:50 -0500
  Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-02-01 23:06 -0700

csiph-web