LAB 02.01 - Python¶
Task 1: Palindrome¶
Determine whether an integer number n is a palindrome, this is, if it is the same number when read left to right and when read right to left. Return True
if so, otherwise return False
.
Execution example
hint: transform it into string, reverse it and check equality
challenge: use one single line of code
check your code manually
submit your code
Task 2: Money Change¶
En este ejercicio, su programa recibirá un monto entre 1 y 99 centavos de Dolar, Escriba un metodo que retorne en una lista, cuantas monedas son necesarias para devolverle a alguien dicho valor, si únicamente se cuenta con monedas de 1, 10 y 25 centavos. La lista debe entregarse de la siguiente manera:
In this task your function will receive an amount between 1 and 99 cents and will have to return a list with three numbers [n1, n10, n25], specifying how many coins of 1, 10 and 25 cents are required to obtain the given amonut. We only have coints of 1, 10 and 25 cents. There are no other kinds of coins.
If the amount given is less than 1 or more than 99 you must return None
.
Execution example
hint: use \\
for integer division
submit your code
Task 3: Fibonacci¶
Complete the function below so that given an integer n it computes the nth term of the Fibonacci series:
Where $f0=0 y f1=1sothat:f2=1+0=1f3=1+1=2f4=2+1=3$ and so on
Task 4: Perfect number¶
complete the following function so that it accepts an integer n and returns True
if n is a perfect number and False
otherwise.
A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For instance 6=3+2+1
See https://en.wikipedia.org/wiki/Perfect_number
Execution example
hint: make a loop of all numbers up to n and use the modulus operator %
to identify which are the divisors, then sum them up.
check your answer
submit your code