[pythonvis] Re: exercise discussion

  • From: "Richard Dinger" <rrdinger@xxxxxxxxxx>
  • To: <pythonvis@xxxxxxxxxxxxx>
  • Date: Sun, 18 May 2014 08:34:25 -0700

Before everyone gets too wrapped up in code, take a look at the instructions for exercise 4:

"Practice using the Python interpreter as a calculator"

So for the books, maybe -
books = 24.95 * 0.6 * 60 = 898.1999
ship = 3.0 + 0.75 * 59 = 47.25
total = round(books, 2) + ship = 945.45

And the runner -
minutes = 8.25 + 3*7.2 + 8.25
leave at 7:52 so
52 + minutes - 60 is 8:30 and 6 seconds

Richard

-----Original Message----- From: Ivan Pivac
Sent: Sunday, May 18, 2014 3:03 AM
To: pythonvis@xxxxxxxxxxxxx
Subject: [pythonvis] exercise discussion

Hi everyone,

Since Thursday's learning room meeting, I have been working my way
through the two exercises at the end of chapter 2 in the book, Think
Like a Computer Scientist.  I wonder if if would be a a good idea to go
through these two exercises, looking at the code and how best to produce
the final output?

In the first task looking at the cost of retailing books, I resolved the
problem, but, I wonder if my code could be more efficiently written.
One question in this exercise is how to write the code where the retail
cost of the book is $24.95 but the dealer receives a 40% discount.  My
solution was:
24.95/10*6
however, the code didn't seem correct to me although the answer was
after doing the maths on a calculator. .

In exercise two regarding what time a walker returned home, I have the
total time taken to walk the distance but don't know how to add those
minutes onto the time of 6.52 am.

Would it be worth while, I wonder, if the experts on the list could
actually code the exercises as we work through them so that we can
discuss the tasks on the learning room forum?  there may be several ways
of producing the answer so examining those methods would also be an
invaluable learning experience.  Meanwhile, I'll continue working on the
home arrival time.



Regards
Ivan

--
Ivan Pivac
4271 Great North Rd
P O Box 69-203
Glendene
Auckland 0645
New Zealand
Tel: (64) 9 836-8876
Fax: (64) 9 836-4668
Email: ivan@xxxxxxxxxxxxx



---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com


Other related posts: