CPSC120A
Fundamentals of Computer Science I

Lab 12

Condition Loops

Use the command line to create a new directory called lab12 in your labs directory. Make sure all of the .py files that you create for this activity are in that directory.

In Circle

Create a Python program in a file called in_circle.py. The program should draw a large circle and many random small circles. If the center point of a small circle is inside the large circle the small circle should be green. If the center point of a small circle is outside the large circle it should be red. Condsider exactly on the edge of the circle as inside the circle. The program should look something like the following:

Triangle of Stars

Create a function called print_star_triangle in a file called star_triangle.py. The function should take a positive integer that specifies the number of rows and should print a triangle made of asterisk characters. For example if the number of rows is 5 the function would print:

    *
   * *
  * * *
 * * * *
* * * * *
    

The function should not use the string + and * operators. The function should use nested while loops and the print function's end keyword argument. Be sure to create tests with coverage for the minimum number of times loops can run and for more times.

Submission

Please show your source code and run your test cases for the instructor or lab assistant. Only a program that has perfect style, thorough test cases, and flawless functionality will be accepted as complete.