This assessment consists of functions you need to write involving primarily boolean expressions. It is a closed book assessment. You should stay on this tab until you are done and there should be no talking. This assessment is about how much you understand. There are no automatic tests but you can use the REPL to test things yourself.
You can move through the questions with the arrows at the upper right next
to the 1 of indicator so if you're not
sure how to write one function move on to another one and come back if you
have time at the end. I want to see how much you do know. Note: you
can also click on thingsLikeThis
in these instructions and
the questions to copy them to the clipboard to avoid spelling mistakes.
(I.e. click to copy and then ⌘-v to paste wherever you want.)
When you are done, please click on your Github username above and
submit a GitHub pull request of the branch
and request me as a reviewer. Doing this correctly is part of the
assessment. If you are unsure how to request a review, please ask for
help!
Write a function named needHeavyCoat
that takes two
boolean arguments, one that is true if a person is going outside and
the other that is true if they are somewhere cold, and returns a
boolean indicating whether they need a heavy coat which they only
need if they are going outside somewhere cold.
Write a function named needSunscreen
that takes two
boolean arguments, one that is true if someone is going to the beach
and the other that is true if they are going skiing, and returns a
boolean indicating whether they need to wear sunscreen which they
need to do both at the beach and on the ski slopes.
Write a function named needMittens
that takes two
boolean arguments, one which is true if a person is going outside
and the other which is true if they are somewhere warm, and returns
a boolean indicating whether they need to wear mittens which they
need if they are going outside somewhere that isn’t warm.
Write a function named isVenomous
that returns a
boolean indicating whether a snake on the island of Booleana is
venomous based on two boolean arguments, one which is true if the
snake is striped and the other of which is true if the snake has a
blue head. All striped snakes on Booleana are venomous as are all of
the unstriped snakes on the island except the blue-headed Blooby
Snake.
Write a function named okaySpeed
that takes two numeric
arguments, one indicating the posted speed limit in miles per hour
and the other the speed a car is going, also in miles per hour. It
should return true if and only if the speed is no more than ten mph
below the posted limit and no more than ten mph above the posted
limit.
Write a function named twiceAsExpensive
that takes two
numeric arguments, each indicating the price of an item you are
considering buying. The function should return true if and only if
the first item costs more than twice as much as the second item.
Write a function named winningRecord
that takes three
numeric arguments, a team’s number of wins, losses, and ties. It
should return true if the team has a winning record, meaning it has
won more than half of the games it has played.
Write a function named isMagicNumber
that takes a
single numeric argument and returns true if the number is one of the
two magic numbers, 42
or 17
. (For
10,000,000 extra credit points, include a comment about why you
think 42 and 17 are magic numbers.)