Due Tuesday 3-Sep, at 9:00pm
hw1.py
using Thonny and modify the functions as requiredhw1.py
to Gradescope.
For this hw, you may submit up to 20 times
(which is way more than you should require), but only your last submission counts.hw1.py
file includes test functions to help you test on your own before
you submit to Gradescope. When you run your file, problems will be tested in order. If
you wish to temporarily bypass specific tests (say, because you have not yet completed
some functions), you can comment out individual test function calls at the bottom
of your file in main()
. However, be sure to uncomment and test everything together
before you submit! Ask a CA if you need help with this.If you have used Discord before, feel free to use your existing account. However, please note that your Discord username will be visible with your profile, even after you change your server nickname. (So if having other people see your Discord username would be embarrassing, then keep that in mind...)
For this task, do the following:isValidYearOfBirth(year)
which, given a
value year
, returns True
if it is an integer value that
represents a valid year of birth, False
otherwise. Keep in mind
that, according to Wikipedia, the oldest person was born in 1907.
numberOfPoolBalls(rows)
that takes a non-negative int
value, the number of rows, and returns another int value, the number of pool balls in that number of full rows. For example, numberOfPoolBalls(3)
returns 6. We will not limit our analysis to a "rack" of 15 balls. Rather, our pool table can contain an unlimited number of rows. Hint: you may want to briefly read about
Triangular Numbers. Also, remember not to use loops!
getTheCents(n)
which takes a
value n
(which represents a payment in US dollars) as input and
returns the number of cents in the payment. If n
is
an int
, the function should return 0, as it has 0 cents; otherwise,
if it isn't a float, it should also return 0, because a non-number payment make no
cents (ha!). You can assume that n
will have up to 2 decimal places.
For instance,
isSymmetricNumber(n)
, which takes a value n
and returns True
if n
is a symmetric number and False
otherwise. Notes: The numbers can be arbitrarily large. For example, 444555666444555666 is a symmetric number.
colorBlender(rgb1, rgb2, midpoints, n)
,
which takes two integers representing colors encoded
as just described, a non-negative integer number of
midpoints, and a non-negative integer n, and
returns the nth color in the palette that the tool
creates between those two colors with that many midpoints. If n
is out of range (too small or too large), return None
.colorBlender(220020060, 189252201, 3, 1)
returns 212078095