Description
Complete 2 of the 3 parts below. Please note that each
part is expected to be written in the form of a function
which is passed parameters.
Part 1
Create a function which passed a string will return True
if the string is a palindrome (spelled the same forward
as backward) and False otherwise.
Hint: Slicing will make this doable in one simple line in
the function, but feel free to use a longer approach if itโs
more clear to you.
Part 2
Create a function which passed integers w, x, y, and z,
will return the list of integers divisible by z given by n
y
where w <= n < x. In other words, starting with all the
integers from w to x, take the yth power of each. Then
of the result of this, return a list of each of those which
is divisible by z.
Note: a**b is a
b
(e.g. 3**2 == 9 ) and a%b is a modulo b (e.g. 5%4 == 1 )
1
Hint: List comprehension can make this doable in one
fairly simple line. However, feel free to use a longer approach if itโs more clear to you.
Part 3
Create a function which passed an unsorted list of n integers will return the list sorted such that index 0 will hold
the smallest number, index n the second smallest, index
1 the third smallest, index n โ 1 the fourth smallest,
index 2 the fifth smallest, etc.
(e.g. given [5,1,2,3,4,6,7] the function returns
[1,3,5,7,6,4,2] )
Hint: Slicing can make this fairly easy, but feel free to
use any approach.
2