EXAM

  • Escribe un función que se llama triangulo cual recibe un parámetro size y imprime un triangulo derecho como el siguiente. El renglón mas grande debe llevar size numero de “T”. SOLO imprime los “T”s y los endlines. Nota que no hay characteres (espacios) a la derecha de los T’s. Debe usar un ciclo “for” para controlar el repetición. Ejemplo es si size era 6.

  • Escribe una función que se llama promedio_lista que recibe un parámetro (una lista (Py- thon) o arreglo/Vector de C++) de valores float y regresa como float el promedio de los números en la lista.

  • Escribe una función que se llama smallest_of_four cual recibe cuatro valores float como parametros y regresa el minimo (más pequeño) de los valores. Ojo: puede recibir unos valores iguales.

  • Escribe una función que se llama fibonacci cual recibe un número n (puedes dar por cuenta que valor mayor o igual que cero) y regresa y valor correspondiente del serie de fibonacci.

  •  Write a function to calculate the square root of a number x using the Babylonian method, it receives a single parameter: the number x and returns the value of the square root of x when two successive estimates differ only by 0.0001 (or less).

 

  • Write a function called find_bananas which receives a single parameter called filename (a string) and returns a positive integer which is the number of times the word (string) “banana” is found in the file. The banana can be any case (‘BaNana’ or ‘BANANA’ or ‘ba- nana’, etc) and they can be “stuck together” like “banAnaBANANA” (that counts as two). Create your own test file (plain text) to check your work.

bananas.pngbabylne.png

Leave a comment