En este post vamos a hacer los primeros 5 ejercicios de 46, son diferentes tipos de ejercicios en los cuales vamos a desarrollar diferentes habilidades.
- 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.)Resultados:
- Define a function
max_of_three()
that takes three numbers as arguments and returns the largest of them.Resultados:
- 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"
.
Deja un comentario