In the previous post I showed the first batch of exercises (1.-5.). Here are the next 5:

6. Define a function sum() and a function multiply() that sums and multiplies (respectively) all the numbers in a list of numbers. For example, sum([1, 2, 3, 4]) should return 10, and multiply([1, 2, 3, 4]) should return 24.

Captura de pantalla 2017-02-10 a la(s) 09.44.36.png

Captura de pantalla 2017-02-10 a la(s) 09.44.59.png

7. Define a function reverse() that computes the reversal of a string. For example, reverse("I am testing") should return the string "gnitset ma I".

Captura de pantalla 2017-02-10 a la(s) 10.32.20.png

Captura de pantalla 2017-02-10 a la(s) 10.32.43.png

8. Define a function is_palindrome() that recognizes palindromes (i.e. words that look the same written backwards). For example, is_palindrome("radar") should return True.

Captura de pantalla 2017-02-10 a la(s) 10.37.30.png

Captura de pantalla 2017-02-10 a la(s) 10.37.39.png

9. Write a function is_member() that takes a value (i.e. a number, string, etc) x and a list of values a, and returns True if x is a member of a, False otherwise. (Note that this is exactly what the in operator does, but for the sake of the exercise you should pretend Python did not have this operator.)

Captura de pantalla 2017-02-11 a la(s) 14.42.56.png

Captura de pantalla 2017-02-11 a la(s) 14.43.19.png

10. Define a function overlapping() that takes two lists and returns True if they have at least one member in common, False otherwise. You may use your is_member() function, or the in operator, but for the sake of the exercise, you should (also) write it using two nested for-loops.

Captura de pantalla 2017-02-11 a la(s) 14.59.36.png

Captura de pantalla 2017-02-11 a la(s) 15.01.00.png