|
|
|
Guidelines
Acceptable resources include:
- Notes, handouts, printed and written material from class or labs
- Textbooks
- The following online resources
- This semester's web pages (i.e. all pages under
http://www.cs.duke.edu/courses/spring09/)
- Python documentation
- JES Documentation
- Myro Documentatrion
- How to Think Like a Computer Scientist
- Learning Computing with Robots
- All files in your own cps001 directory on acpub/WebFiles
It is UNACCEPTABLE to view the directories or web pages of other students
or engage in electronic messaging of any form. You also may not discuss
your lab final with any other student who has not taken the lab final. Any
impermissible communication constitutes a violation of the Duke Community
Standard and will be dealt with as such.
Problems
Problem: Sum of Squares
The sum of squares is the sum of a sequence of numbers
up to a specified integer. For example, the sum of squares from 1 to 5
should be 55 because
12 + 22 + 32 + 42 + 52 = 55.
Given start and end values as integers, write a function, sumSquares, that returns the
sum of squares.
Example runs below:
>>> sumSquares(1,5)
55
>>> sumSquares(1,1)
1
>>> sumSquares(-4,3)
44
Problem: Maximum Value
A common programming task is to find the extreme values (either largest or
smallest) in a collection of values.
Write a function, largestInt, that takes an list of integers and returns the value of the
largest element.
>>> largestInt([5, 1, 4, 7, 3, 2, 6, 0])
7
>>> largestInt([1, 0, 1, 0, 1, 1, 0, 1, 0, 1])
1
>>> largestInt([-7, -43, -6, -57, 84, 76, 36, 73, -59, 24])
84
Problem: Change Blue
Write a function called
changeBlue that takes as input a picture and
an amount to increase or decrease the amount of blue by a
specified amount. For
example:
-
changeBlue(pict,-10) should decrease the
amount of blue in pict by 10%.
-
changeBlue(pict,85) should increase the
amount of blue in pict by 85%.
-
changeBlue(pict,0) should not change the
color values of pict.
Submitting
Submit using Eclipse assignment name lab11.
|