Computer Science 112
The Art & Science of Computer Graphics

Spring 2016, The College of Saint Rose

Lecture 22: Python Functions
Date: Monday, April 18, 2016


Agenda

Lecture 22 Assignment

Due at the start of class, Wednesday, April 20.

Please submit answers to these questions either as a hard copy (typeset or handwritten are OK) or by email to terescoj AT strose.edu by the start of class. Please use a clear subject line when submitting by email (e.g., CSC 112 Lecture 22 Assignment, Mary Smith). We will discuss these questions at the start of class, so no late submissions are accepted.

Some of these revisit questions from the previous lecture assignment, now working with Python functions. Just do your best on these. The topic is new and you haven't had a chance to practice much yet.

  1. Turn the Python statements that create a "plastic" material whose color is a randomly chosen shade of gray into a function named randomGrayPlastic that returns such a material. (5 points)
  2. Place the Python loop that prints out 5 random numbers in the range 1 through 6 into a Python function called yahtzeeRoll that prints out the 5 values, but also returns their sum. (5 points)
  3. Write a Python function that takes one parameter: a number, let's call it n, and then uses a loop to generates n random integers in the range 0-100 and returns their sum. (5 points)
  4. Write a function lighterHSV, similar in format to the lighterRGB function, that returns a lighter shade of a given HSV color. (5 points)

Terminology

Examples