--Originally published at Python fundamentals

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”

--Originally published at Python fundamentals


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

--Originally published at Python fundamentals



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

Continue reading "Women in computing"


--Originally published at Python fundamentals

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.







--Originally published at Python fundamentals


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)


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.


I will give you a FREE BOOK

--Originally published at Python fundamentals


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.



--Originally published at Python fundamentals


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.


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.



--Originally published at Python fundamentals


You will find the instructions on Kencourses blog



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.


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.


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.


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).


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

Continue reading "#WSQ11"


--Originally published at Python fundamentals


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.


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)


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