Instructions

Two numbers are relatively prime if there is no number, other than 1, of which they are both multiples.

Use a for loop to write a function rel_prime that consumes two positive integers and determines if they are relatively prime, producing True if they are and False otherwise.

You might wish to use is_multiple as a helper function.

Note:

Hint:

  • Choose a range that does not include 1.

Use a for loop to write a function password that produces True if a string is a suitable password and False otherwise. The string must contain at least one upper-case letter, at least one lower-case letter, at least one digit, and be of length at least eight.

Note:

Hints:

  • Checking the length of the input can be done outside of the loop.

Julius Caesar used a simple code to keep his private correspondence private.

Use a for loop to write a function caesar that encodes a string using Caesar's code. The two inputs are the string in upper-case letters and the integer offset; each character is replaced by the character offset positions away in the alphabet.

You may find it useful to use chr and ord as well as the remainder function, which will allow you to ensure that letters at the end of the alphabet are mapped to upper-case letters at the beginning of the alphabet when the offset is positive; letters at the beginning of the alphabet will be mapped to letters at the end of the alphabet when the offset is negative. The Unicode values of "A" through "Z" are 65 through 90.

Note:

Hints:

  • Consider writing a helper function that adjusts a number to be in the range from 65 to 90.

Use a for loop to write a function equals that consumes two lists and produces True if each pair of corresponding values is equal and False otherwise.

Note:

Hints:

  • Make sure that your function works when the lengths of the lists are not the same.

Modify your previous example to use a for loop to write a function compare that consumes two lists of numbers and produces "Smaller" if the first list is smaller than the second, "Larger" if the second list is smaller than the first, and "Equal" if they are equal. The results should be the same as using comparisons on lists.

Note:

Hints:

  • Unlike in the previous question, you cannot determine the answer by looking at the lengths alone.

Use a for loop to write a function multisplit that consumes two positive integers total and split and produces the number of times total is repeatedly divided into split even pieces before each piece is of size at most 1.

For example, the value returned by multisplit(8, 2) will be 3, since 8 can be split into 2 pieces of size 4, which are then each split into 2 pieces of size 2, which are then each split into 2 pieces of size 1 (at which point no further splitting takes place since the pieces are of size at most 1). The value returned by multisplit(8, 3) will be 2, since 8 can be split into 3 pieces of size 8/3, which are then each split into 3 pieces of size 8/9 (at which point no further splitting takes place since the pieces are of size at most 1).

Note:

Hints:

  • You can use break to exit the loop as soon as the pieces are of size at most 1.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX