CPSC120A
Fundamentals of Computer Science I

Lab 9

Test 1 Review

Programming Exercises

For review for Friday, answer the following programming questions:

  1. Write a program that prompts the user to enter a string (stored as name) and an integer (stored as num_times). Your program should then print the name entered by the user num_times times.

  2. Write a program that prompts the user to enter a floating point number (referred to here as x). x represents some angle in degrees. Your program should print the value of x converted to radians.

    \[radians = \frac{\pi}{180} \cdot degrees\]

Fish

Since we have a test on Friday, lets do a little bit of a fun activity. One of the badges of honor for the CS major comes from the CS120 class: drawing a fish. This activity was originally created by Dr. N. Jane Ingram and Dr. Adrienne Bloss for their Java labs in the 2000's. We are keeping their tradition alive today.

Details

Create a python program in a file called fish.py. This program should prompt the user to enter two integers, which is the location on the turtle window to draw a line drawing of a fish. Your fish should be drawn centered on the specified coordinate.

Start on paper first!. The activity will progress much easier for you if you figure out the coordinates of various points before you begin coding. Start with a plan and your code will come together very quickly.

Make sure to test your program by running it multiple times with different parameters. Make sure your code follows the course's code conventions.

Example

Hint

While this looks very complicated, it's just two partial circles and three lines. You just need to figure out the locations of certain points before you get started. Consider the following image if you need assistance:

Where the fish is 3 × r pixels wide from tail to the tip of the head.

Challenge

What do you call a fish with no eyes? FSH! Add eyes to your fish so it won't accidentally swim into a dam!

Submission

Please show your source code and run your programs for the instructor or lab assistant. Only a programs that have perfect style and flawless functionality will be accepted as complete.