# Activecode Exercises¶

Answer the following **Activecode** questions to
assess what you have learned in this chapter.

Construct a block of code that prints the remainder of 18 when divided by 13.

Below is one way to write the code to print the remainder of 18 when divided by 13.

Construct a function, `is_even`

, that prints whether a number
is even.

Below is one way to construct the `is_even`

function.

Construct a function, `difference`

, that prints the difference of a and b if the result
would result in a positive number. Otherwise, prints -1.

Below is one way to write the `difference`

function.

Construct a function, `matic`

, that takes as inputs 2 integers, x and y, and prints “automatic” if x is
an odd number, “systematic” if x is greater than y, AND
“hydromatic” if y is not equal to x. Check all 3 conditions.

Below is one way to construct the code.

Construct a block of code that prints “Pick me!” if x is equal to y, “Choose me!” if x is less than y, OR “Love me!” if x + y is even.

Below is one way to construct the code.

Construct a function, `printLetterGrade`

, that prints your letter grade according to this scheme.
[0, 70) = F, [70, 80) = C, [80, 90) = B, and [90, 100] = A.

Below is one way to write the `printLetterGrade`

function.

According to a logic game, a knight is someone who cannot tell a lie, and a knave is someone who cannot tell the truth. Construct a function that takes two booleans: the truth value of the story, and the truth value told by the person. The function should print whether the person was a knight or a knave.

Below is one way to construct the `knightKnave`

function.

If a cat is in a good mood, it purrs; when it’s in a bad mood, it meows. If a doog is in a good mood, it barks; when it’s in a bad mood it woofs. Construct a function that accomplishes this.

Below is one way to construct the `makeVocals`

function.

Construct a recursive function that tells the user to enter a positive number. It should then output that number to the terminal. If the user enters a negative number or zero, prompt the user again.

Below is one way to write the `takeSum`

recursive function.

In the table of ASCII characters, the lowercase alphabet consists of characters 97-122. The uppercase alphabet consists of characters 65-90, which is a 32 character shift back from the lowercase. Construct a recursive function that asks the user to input a LOWERCASE character, converts that character to UPPERCASE character and prints it. If the user enters a character outside of the range of the LOWERCASE alphabet, prompt the user again. Hint: “||” means “or” when used between two conditional statements.

Below is one way to write the `capitalize`

function.