You are only allowed to access this course webpage, the Python documentation, Graphics documentation, and Sprite webpages. You are not allowed to access any other websites. You are not allowed to access files from your directory, or files from any other user's directories. Failure to abide by these rules is a violation of Academic Integrity, and will be treated as such.
Write a function number_of_divisions(a_number)
,
which takes
an integer value as input. Your function should return an
integer number,
representing the number of times you can sequentially
divide
a_number by 2 before you get a value less than or
equal to 1.
>>> print(number_of_divisions(5)) 2
Write a function title_case(text)
that cases a
string as a
parameter. Your function should return a string, which is
the equivalent
to text in title case.
Title case is what is used for titles, where the first letter of each principal word is capitalized, and the first word is always capitalized. For this function, assume the only non-principal words are 'a', 'the', 'and', 'in', 'of', and 'to'.
You may assume that test only consists of lower case
alphabetic
characters and spaces. You may also assume that there is
exactly one
space character between words in the text
string. Your function
may use the isalpha
and upper
methods. You may
not use any other string methods.
>>> print(title_case("monty python and the holy grail")) Monty Python and the Holy Grail
Write a function find_local_minima(a_list)
, which
takes a
list of integers as a parameter. Your function should
return a list of
integers, the indices of all local minima contained
within a_list.
A value is a local minima if it is less than the number before it in the list, and is less than the number after it in the list (assuming they exist).
>>> print(find_local_minima([1, 0, 1])) [1]
In a transposition cipher, instead of shifting each character of the plaintext string through the alphabet, you shift the position of the plaintext character in the cipher text.
For example, the string "hello" could be encoded using the transposition cipher into: "lheol". The key for this would be "1 2 0 4 3". This key means that the character at position 0 goes to position 1 in the cipher text, the character at position 1 goes to position 2 in the cipher text, and so on.
In a file called question_bonus.py, write a function
called encode_transposition(plaintext, key)
. This
function takes two strings. The key is of the form specified
above. Your function should return a string, which is the encoded
version of the plaintext using the key.
(5 points)
When you have finished, create a tar file of your test3
directory. To create a tar file, execute the following commands:
cd ~/cs120 tar czvf test3.tgz test3/
To submit your coding activities, go to inquire.roanoke.edu. You should
see an available assignment called Test #3 Bonus
.