EXAM

--Originally published at Hello World

  • 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


#WSQ13 – Cars

--Originally published at Hello World

Here are the instructions:

File input/output is our access to permanent stores of data that last beyond the run time of our application.Write a program that opens and reads the file 93cars.dat.txt and produces the following data:

  • average gas mileage in city (City MPG)
  • average gas mileage on highway (Highway MPG)
  • average midrange price of the vehicles in the set.

Here you can find the file 93cars.dat.txt https://ww2.amstat.org/publications/jse/v1n1/datasets.lock.html

First, you need to open the file, as seen before as f = open(“textfile.txt”). Then, with the built-in function readlines(), each character is read by the program. Then assigning lines = lines[::2] creates a substring, which means that the line is sliced while keeping all the characters. Then we need to define and set the counts to 0 (city, highway and price). We then need to add up all the values for each category and divide them by the number of car (you know that thanks to len(lines)).


WSQ12 – Estimating e

--Originally published at Hello World

Here are the instructions:

In this assignment you will estimate the mathematical constant e. You should create a function called calculate_e which receives one parameter called precision that should specify the number of decimal points of accuracy. You will want to use the infinite series to calculate the value, stopping when the accuracy is reached (previous and current calculation are the same at the specified accuracy).

https://docs.python.org/2/library/math.html


WSQ11 – Go Bananas

--Originally published at Hello World

still need to solve some issues!

http://stackoverflow.com/questions/6797984/how-to-convert-string-to-lowercase-in-python

Here are the instructions:

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”  (or “BANANA” ) is found in the file. The banana can be any case (‘BaNana’ or ‘BANANA’ or ‘banana’, etc) and they can be “stuck together” like “banAnaBANANA” (that counts as two). Create your own test file (plain text) to check your work.


My Virus

--Originally published at Hello World

via OSxdaily

 

My computer is not that young. And one day the worst happened: a virus was here. My teacher helped me a lot in the steps of cleaning up my computer. He told me to back up my computer with time machine. Then, we wipe out all the memory on the mac in order to install Sierra. It was easy and now my computer is like brand new.

If you ever encounter this problem, reading this can be really helpful https://support.apple.com/kb/PH25649?locale=en_US


#WSQ10 – Babylonian Method

--Originally published at Hello World

In this assignment you will write a function to calculate the square root of a number using the Babylonian method. You can search for that method, it will be easy to find.The function should receive a number and return floating point number. Obviously you should test your function, so create a main program that asks the user a value, calculates the square root and displays that.As usual, create a blog post explaining what you did, where you found resources (books, videos, web pages, friends) to help you solve this. Remember to put the tag #WSQ10 on your post so our blog hub picks that up. You should include your code as a link to GitHub. And of course, leave any questions here as well as asking those questions in our Slack channel so we all see your question posted there.

First, I searched what was the Babylonian Method. It was used when calculators did not exist in order to find the square root of a number. I found that this page explains really well how this method works: https://mathlesstraveled.com/2009/05/18/square-roots-with-pencil-and-paper-the-babylonian-method/


#WSQ08 – Yo Soy 196

--Originally published at Hello World

Here are the instructions:

Your job is to create a program that asks the user for two pieces of data: the lower bound of the sequence & the upper bound of the sequence. Then you check the values from the lower bound (inclusive) to the upper bound (inclusive) and make a report of them. During the analysis of each number, if a Lychrel number is found it should be reported immediately with something like “Found a Lychrel number: 196”. The report must show: the range of numbers analysed (lower to upper bound), the number of natural palindromes (no addition to inverse needed), the number of non-Lycherels encountered (become palindromes), the number of Lycherel number candidates (that did not converge to palindrome). Since you will not be able to prove that a number is Lychrel (since you cannot computer forever to check), our definition for a Lychrel candidate will be if a number does not converge after 30 iterations of applying the addition to the inverse.

 

A lychrel number that cannot form a palindrome, through the iterative process of repeatedly reversing its digits and adding the resulting numbers. A palindrome is a number that remains the same when its digits are reversed.

Ken helped me a lot to understand the process, and how to think like a computer scientist! Here is the picture of what the schema looks like: 18053262_10156098806474447_1963899969_o.jpg


Alan Turing

--Originally published at Hello World

Via http://www.ifa.de/en/visual-arts/exhibitions-abroad/fine-arts/future-perfect.html

Sunday, a friend and I went to see an exhibition in the MUSA of Guadalajara. One of the exhibition was called future perfect. And there, we saw the 6 pictures representing either binary symbols, or the face of Alan Turing. I had never heard about him before, but the binary codes did strike me, thus I decided to search some informations. The story of Turing is related on the 6 boards. In short, the man was one of the most influential in the development of theoretical computer science. He played a crucial role during WWII by intercepting coded messages that enabled the Allies to defeat the Nazis in many crucial engagements. He committed suicide two years after being accused to be gay.

 

 


#WSQ09 – Multipart Data and Files

--Originally published at Hello World

Here are the instructions:

So for this assignment I would like to see you create a function that receives as parameter the name of a file (this would be a string value like data.txt) and your function counts the number of lines and the number of characters in the file which it returns as a single value (but with two values). You will want to look at how to use and return a tuple from a function and how to open and read text files line by line.