Difference between revisions of "CSC111 Homework 4 2014"

From dftwiki3
Jump to: navigation, search
(Problem #2)
(Problem #2: Magic Lily)
Line 29: Line 29:
 
<br />
 
<br />
 
=Problem #2: Magic Lily=
 
=Problem #2: Magic Lily=
 +
<br />
 +
Assume that we have a put a magic lily in Paradise Pond.  The magic lily grows in surface every 24 hours.  When we first put it in the pond, it is only 1 square inch in area.  We approximate the size of the pond to be 31,416 square feet. 
 +
 +
We assume that the lily is magic is that it can cover areas that are as irregular as the pond is.  It's magic, remember?
 +
 +
Write a program that uses a '''while''' loop and that will output the number of days it will take for the lily to cover the whole pond.  Make your program output all the known information and the final result (the actual result shown here is incorrect, on purpose).
 +
 +
 +
Magic Lily
 +
Initial size: 1 square inch
 +
Growth rate: 2 times its size in 1 day
 +
Pond size: 31416 square feet
 +
Total number of days required to cover the whole pond (or more): 16 days
 +
 +
Call your program '''hw4b.py'''.
 +
<br />
 +
==Additional Information ==
 +
===Computation===
 +
<br />
 +
Those of you who are math inclined can probably figure out an equation giving the size of the lily after some number of days.  You are welcome to code this equation to verify the output of your while loop, but you need to also compute the solution using a while loop that doubles the size of the lily every iteration.
 +
<br />
 +
===Conversion==
 +
<br />
 +
Use the Web to convert square feet into square inches.  [http://www.wolframalpha.com/ Wolfram Alpha] is a great resource for every type of translation from one unit into another.
 +
<br />
 +
===Where did Paradise Pond get its name?===
 +
<br />
 +
Could it be the Swedish Nightingale Jenny Lind?  You can read all about it [http://www.smith.edu/news/2005-06/JennyLind.html here!]
 +
<br />
 +
===Approximating the Area of the Pond===
 +
<br />
 +
I simply tried to cover as tightly as possible a map of the pond with disks that had a diameter of 200 ft.  I counted 16. 
 
<br />
 
<br />
 
<center>[[Image:ParadisePondArea.png|650px]]</center>
 
<center>[[Image:ParadisePondArea.png|650px]]</center>

Revision as of 13:15, 19 February 2014

--D. Thiebaut (talk) 12:26, 18 February 2014 (EST)



This assignment can be do individually or in Programming-Pair mode. You are not restricted in your selection of a partner if you are working in pair. The assignment is due on Thursday evening, February 27th, 2014, at midnight.






Problem #1


Rewrite the Rock-Scissors-Paper game using while loops. Call your program hw4a.py.

Requirements


  • The program will stop only once the difference in score between computer and human players is 3.
  • You should not include the mug of Homework 3 in this program/game.
  • The program will keep on prompting the user if the input is not one of 'P', 'R', or 'S'. The program will accept valid letters in lower or upper case, and with extra spaces before or after the letter.
  • The program will indicate the winner of each round.
  • The program will output a final string at the end, when the difference in score is 3, pointing out and congratulating the winner.



Problem #2: Magic Lily


Assume that we have a put a magic lily in Paradise Pond. The magic lily grows in surface every 24 hours. When we first put it in the pond, it is only 1 square inch in area. We approximate the size of the pond to be 31,416 square feet.

We assume that the lily is magic is that it can cover areas that are as irregular as the pond is. It's magic, remember?

Write a program that uses a while loop and that will output the number of days it will take for the lily to cover the whole pond. Make your program output all the known information and the final result (the actual result shown here is incorrect, on purpose).


Magic Lily
Initial size: 1 square inch 
Growth rate: 2 times its size in 1 day
Pond size: 31416 square feet
Total number of days required to cover the whole pond (or more): 16 days

Call your program hw4b.py.

Additional Information

Computation


Those of you who are math inclined can probably figure out an equation giving the size of the lily after some number of days. You are welcome to code this equation to verify the output of your while loop, but you need to also compute the solution using a while loop that doubles the size of the lily every iteration.

=Conversion


Use the Web to convert square feet into square inches. Wolfram Alpha is a great resource for every type of translation from one unit into another.

Where did Paradise Pond get its name?


Could it be the Swedish Nightingale Jenny Lind? You can read all about it here!

Approximating the Area of the Pond


I simply tried to cover as tightly as possible a map of the pond with disks that had a diameter of 200 ft. I counted 16.

ParadisePondArea.png



Submission


Submit your programs to cs.smith.edu/~thiebaut/111b/submit4.php.