ATENCIÓN, IMPORTANTE

 

Estos post NO  tratan de la versión traducida de el libro «How to think like a computer scientist:Python»sino de un resumen, bastante sintetizado de las partes claves del libro, que buscan ayudar en el aprendizaje y del estudio del libro en cuestión, sin embargo no intentan suplantarlo.

#WSQ13

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.

 

Screenshot 2017-05-02 11.29.07.png

#WSQ12 finding «e»

Instructions

In this assignment you will estimate the mathematical constant e. You should create a function called calculuate_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).

Screenshot 2017-05-02 11.10.49

Screenshot 2017-05-02 11.08.27

Women in computing

 

Introduction

On the past Wednesday i was attending an event with my little sister called “Women in computing”, the idea behind this was to bring women engineers working on the tech industry to share their experiences and encourage other women to work on technology.

The truth is that even though I wasn’t part of the target audience I really enjoy it and learn a lot.

The event

The first exponent was Elizabeth López an Oracle engineer that told us about the serious problem of the lack of women in our industry, among other things.

Now, as someone that its working on get a degree in engineer I know that this it’s a sadly truth.

Then after a few minutes she came up with reasons about why we don’t have to many women in tech.

  1. The first one it’s that too many women are interested in science.
  2. Second, the small part that its interested in science are not interested in IT

Finally, she made a very good work trying to motivate and encourage to other women to study not just IT but to reach their potential and made it clear that IT it’s not just about programming.

The last and second speaker was Mireya, she was a former employee at CISCO Systems and now it’s an employee at Oracle with a managerial position.

Her talk was interesting, she told us about her life and the experiences that gave shape to her career.

The story that I enjoy it the most was when she told us that gave up a promotion because she wanted to spend more time with her childs and if she took it she would be transferred, at the end she concluded.

“Even though I gave up to the promotion i handle it to get the opportunity to compete to a different promotion. The fact that I wasn’t able to be transferred it doesn’t mean that I wasn’t able to improve my career”.

What did I learn?

With Mireya that you can always grow as a professional, but that grow must be tied to your life purpose, because we work to get a life, we don’t live to work.

With Elizabeth that the lack of women in the industry it’s something that we has to fix, and as men we should help.

#WSQ11

To find out how many times the word banana its found it on a text file, we firstly will create our own file. Once we do that we will create another function that will help us to finish the main program, this function is going to use the string module to transform each character of a string into a lower case letter. If the character can’t be transform it will omit it and just don’t add it into a new variable.

Then it will return a new string which will be a copy of the original one, but this time without characters that are not lower case letters. This function will be called “Just_lowercases”.

Then we are going to create our main program “find_bananas”, this program will use a counter and a for loop that will iterate on each line of the text and on each line will call the “Just_lowercases” function that will convert the text and use the “count” method to count how many times the word “banana” its found it.

I read that on windows if we don’t use the close() function once we open a file using python, the file will have troubles later, i forget to do it the first time but nothig happened. Nevertheless just in case we will do it to avoid posibles errors.

 

wsq11

 

sources:

https://therealgiovasblog.wordpress.com/2017/04/05/wsq11/

#Quizz3

Instructions

For this quiz I want you to (in class) create a program with two functions:

  • def square_root(x):  // returns the square root of x (float)
  • def cube_root(x): // returns the cube root of x (float)

Procedure

I used the math module, in the square_root I just use the function «sqrt» and on the cube_root i used a matemathical equivalent using 1/3.

quizz3.png

I will give you a FREE BOOK

4235156633_8b155f5339_m

image by David Feng

This its a book called Coders at Work, this its a very interesting book about reporter that made an enterview to ones fo the best coders on the planet.

We have Jamie Zawinski an early programmer at Netscape that drop out the university at Carnegie Mellon.

Douglas Crockford the inventor of JSON

L Peter Deutsch a fellow ACM member that started in the programming in the 50’s by the age of 11.

And many other interesting personalities more.

 

Now, the book has two conditions:

The first one its that once you finish to read it, you will have to give the book to another person and the next person should do the same.

The second one its that you will have to wait untill may 31… because i didn’t fish it yet jaja.

So do you want it?

If the answer its yes just let me know in the comments or contact me and i will give it to you.

 

#WSQ10

Instructions

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.

Procedure

To find the square root  of our given number we are going to create a funciton with a while loop, this loop will be execute untill the square root calculated using the babylonian method reaches a precision of  a thousandths decimals.

If you want even more details about this exercise you can read it here on another blog post that i made.

WSQ11-08Babylonian

#Quizz11

Instrunctions

You will find the instructions on Kencourses blog

Procedure

First exercise:

In the «distance» function we will create a function that takes 4 paramethers and return us the formula of distance between 2 points.

We are not going to use them on this point but, for the rest of the #WSQ11 we are going to use the math module and the string module, i will point it out when the time to use them comes, nevertheless im not repeating how to import both in the same file. So keep atention and see the picture because this is the way to do it.

wsq11-011.png

Second exercise:

In order to make the second one we will create 2 for loops, one in wich the i variable is going to be increasing untill the value is the same as a. On the second one our i variable will be decreasing  untill the value is 0.

WSQ11-02

Third exercise:

We will create a function that using an if will determine if the factorial of the number its going to be find it using an algorithm or by just returning 1. (Which is the case for 0 and 1 factorial).

If the algorithm its required we are going to set the formula on a while loop and stops the loop if our counter reach our given number.

WSQ11-03

fourth exercise:

To calculate the main of a list we will create a for loop that is adding each one of the elements of our list in a variable to finally divide this value by the number of elelements (wich is found it using a counter that counts on every iteration).

WSQ11-04

Fifth exercise:

To find the samaller number between 4 values, i created a function that determines the smaller number between two values, it wasn’t the most eficient way to solve it, because the math module has already its own function that does exactly the same thing, nevertheless regartless of what you choose to do (use min() or make your own function) the next step is going to be the same.

We will create a function that receives 4 paramethers and using a binary operation will determine wich one in the two operations is the smallest and then it will take the result of each one of the previus function to determine wich one of this two final values is the greater.

wsq11-05a.png

wsq11-05b.png

Sixth exercise:

For the fibonacci sequence we will do almost the same process like the third exercise (we will evaluate if its necesary to use an algorithm or not). If the answer is yes, we will use the algorithm of the fibonacci sequence inside a while loop.

WSQ11-06

 

 

 

Seventh exercise:

We are going to use a for loop that will iterate in every element of our list, on each iteration we will add the square of the current element and when the loop has ended we will return the total.

WSQ11-07

 

 

Eighth exercise:

We will find two elements that multiplied results on the number that was given as a paramether, in this case we will use the number 2 and the half of the given number.

Then we are going to use a while loop that will iterate untill the diference between the number a and the number b, results on a number less than 0.001.

While the loop its iterating the a and b value will be update using the babylonian method (a+b/2 for the base of the same square and x/a to find out the other side).

At the end of the loop will return one side of the square.

WSQ11-08Babylonian

 

Ninth exercise:

To find out how many times the word banana its found it on a text file, we firstly will create our own file. Once we do that we will create another function that will help us to finish the main program, this function is going to use the string module to transform each character of a string into a lower case letter. If the character can’t be transform it will omit it and just don’t add it into a new variable.

Then it will return a new string which will be a copy of the original one, but this time without characters that are not lower case letters. This function will be called «Just_lowercases».

Then we are going to create our main program «find_bananas», this program will use a counter and a for loop that will iterate on each line of the text and on each line will call the «Just_lowercases» function that will convert the text and use the «count» method to count how many times the word «banana» its found it.

I read that on windows if we don’t use the close() function once we open a file using python, the file will have troubles later, i forget to do it the first time but nothig happened. Nevertheless just in case we will do it to avoid posibles errors.

WSQ11-09

 

Tenth exercise:

To find the common divisor of each number we will use a for loop that using the min() function of the math module will determine wich number its the smaller one. This number will be the maximum posible common divisor.

Finally on our for loop we will determine if a number its divisor of both using the module operator.

WSQ11-10

Resources:

Finally I want to say thank you to one friend of mine, Brian, that helped me to solve the exercise number ten. It was very help full and not just that it actually helped me to change the way in which i was solving my exercises.

 

#quiz09

Instructions

Write a function that receives four parameters: x1, y1, x2, y2 which are all floating point values.

The function is called distance and returns (float) the distance between x1,y1 and x2,y2 on the cartesian coordinate plane.

Procedure

We will just type the formula to find the distance between two points in the return of a function (we will use the math module to calculate the square root)

quiz09

Sources: http://www.mathportal.org/calculators/analytic-geometry/distance-and-midpoint-calculator.php