Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


index = 1
while index < 5:     # while the index is less than 5, the code below executes
     x = random.random()     # x is a random real number between 0 and 1
     if x > 0.5:
          index += 1     # adds 1 to the index
          # this part then draws a fish of scale factor x in a random location

basically i The index only increases if x is greater than 0.5, and fish only stop being drawn once i the index reaches 5. Here's the result:

It would have turned out better if my fish and seahorses were solid colored like my mojave scene.

In this project I learned that it is organizationally attractive to put a bunch of similar functions in one .py file as a repository for other .py files to draw from. I also learned how to use a while loop to ensure certain conditions are fulfilled before the loop terminates.