Chapter 4 Quiz A
The first quiz on Chapter 4, based on Chapter 4 Discussion III and similar CodingBat problems.
- You may ask for help with “red error messages”.
- No internet sources.
- No help from other students.
- No notes.
Write three tests, a signature, and the function for each.
nearTen
Logic-1. Given a positive Integern
, return True ifn
is within two of a multiple of ten.matchUp
Array-2. Given two lists of the same number ofInt
, consider the each pair of elements with the same index (same position in the list when lined up). Return the count of the number of times that the two elements differ by two or less, but are not equal.
Periods are short today.
Extra credit. Write a signature using class constraints:
f x a y = if x == a then sqrt(y) else y