[pythonvis] Re: exercise discussion

  • From: Ivan Pivac <Ivan@xxxxxxxxxxxxx>
  • To: pythonvis@xxxxxxxxxxxxx
  • Date: Mon, 19 May 2014 19:22:56 +1200

Hi Joe,

Many thanks for your reply and suggestions. When I ran the code, the answers were all the same, $14.97. Here is the code I used based on your suggestion:

j = 24.95/10*6
print j
k = 24.95*(0.6)
print k
l = float(24.95*0.6)
print l

Perhaps, tomorrow, we can discuss why this was the case? Is there any way at the time of the forum that I can send my code for us to examine?


Many thanks
\Ivan



On 18/05/2014 10:22 p.m., Joseph Lee wrote:
Hi Ivan,
Ah, okay.
Let's try this way:
For retailer problem, examine what would the following code fragments will
do (without using the Pythone interpreter first):
1. 24.95/10*6
2. 24.95*(0.6)
3. float(24.95*0.6)
Now try running these fragments in the interpreter and write down what you
hear/see/read. Then write down similarities and differences in the reply
(hint: two of them do the same thing).
For the walking problem, can you tell us the exercise, any hints that the
book provides, how will you solve it and what you wrote (code) in the reply
so we can provide some comments? In other words, what I'm personally after
is how you are thinking about the problem, not just cooking up a quick
solution.
Thanks.
Cheers,
Joseph P.S. Richard, would it be okay for us to publish our solution to your
number divisibility problem here?


-----Original Message-----
From: pythonvis-bounce@xxxxxxxxxxxxx [mailto:pythonvis-bounce@xxxxxxxxxxxxx]
On Behalf Of 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





--
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

List web page is //www.freelists.org/webpage/pythonvis

To unsubscribe, send email to pythonvis-request@xxxxxxxxxxxxx with "unsubscribe" in the Subject field.

Other related posts: