-
Define a function
max()
that takes two numbers as arguments and returns the largest of them. Use the if-then-else construct available in Python. (It is true that Python has themax()
function built in, but writing it yourself is nevertheless a good exercise). -
Define a function
max_of_three()
that takes three numbers as arguments and returns the largest of them. -
Define a function that computes the length of a given list or string. (It is true that Python has the
len()
function built in, but writing it yourself is nevertheless a good exercise). -
Write a function that takes a character (i.e. a string of length 1) and returns
True
if it is a vowel,False
otherwise. -
Write a function
translate()
that will translate a text into "rövarspråket" (Swedish for "robber's language"). That is, double every consonant and place an occurrence of "o" in between. For example,translate("this is fun")
should return the string"tothohisos isos fofunon".
-
Define a function
sum()
and a functionmultiply()
that sums and multiplies (respectively) all the numbers in a list of numbers. For example,sum([1, 2, 3, 4])
should return10
, andmultiply([1, 2, 3, 4])
should return24
. -
Define a procedure
histogram()
that takes a list of integers and prints a histogram to the screen. For example,histogram([4, 9, 7])
should print the following:**** ********* *******
-
Write a program that maps a list of words into a list of integers representing the lengths of the corresponding words.
-
A pangram is a sentence that contains all the letters of the English alphabet at least once, for example: "The quick brown fox jumps over the lazy dog". Your task here is to write a function to check a sentence to see if it is a pangram or not.
-
"99 Bottles of Beer" is a traditional song in the United States and Canada. It is popular to sing on long trips, as it has a very repetitive format which is easy to memorize, and can take a long time to sing. The song's simple lyrics are as follows:
99 bottles of beer on the wall, 99 bottles of beer. Take one down, pass it around, 98 bottles of beer on the wall.
The same verse is repeated, each time with one fewer bottle. The song is completed when the singer or singers reach zero. Your task here is write a Python program capable of generating all the verses of the song.
Source: https://github.com/jivoi/junky/blob/master/python_simple_ex/README.md