Author Archives: Jorge Padilla

Poster Proyecto Final

Tercer Post Proyecto Final

Nuestro proyecto consistirá en crear un programa interactivo para facilitar el aprendizaje de la lecto-escritura para los niños que cuenten con alguna discapacidad, ya sea síndrome de down, déficit de atención, dislexia, entre otros. Por lo que nuestro proyecto no está enfocado a una discapacidad en específico.


Here’s the last WSQ of the semester…. 🙁 totally gonna miss this course. Anyway, here’s the link to my code on github. You may wanna go and check it out!! 



Creation and use of dictionaries in Python

Dictionaries are all about keys and values. Each key is separated from its value by a colon (:), the items are separated by commas, and the whole thing is enclosed in curly braces. An empty dictionary without any items is written with just two curly braces, like this: {}.

Keys are unique within a dictionary while values may not be. The values of a dictionary can be of any type, but the keys must be of an immutable data type such as strings, numbers, or tuples.

Here’s a simple example of how to create dictionaries and how they run:



Validated user input in Python



This is very useful since it helps to make a good and clean code without too many errors to fix, for example:

while  True:
            q=int(input(“Please enter a non-negative integer number: “))
        except ValueError:
            print(“this is not a integer number, try again: “)


while q
            q=int(input(“this is not a positive number,try again: “))
        except ValueError:
            print (“this is not a integer number, try again:  “)
            while True:
                    q=int(input(“Please enter a non-negative integer number: “))
                except ValueError:
                    print (“this is not a integer number, try again: “)



I created a python 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.

Check out my code:



Final Dash

I have 28 points out of 40 for masteries. I’m going to work on those twelve points I have left and I also did my quizes 9, 10, and 11. Last week I did mi ECOS and I’ve also worked on each week’s WSQs in order to get ready for the final exam next Saturday.


Reading and writing of files in Python

For reading and writing of files in python, the first thing you need to do is to get a file object, using the “open” function.

The open function has two parameter, the first one is the name of the file that we are creating and the other parameter is going to check if you are going to read(r) or write(w) the file. Now to write inside the file you need to write the name of the object we just created followed by a dot with the word “write” adn you open parenthesis where you are going to write the text.It is important to point out that the end line is given by “/n”. To save it we just have to close our object.

this is the syntax: file = open(“newfile.txt”, “w”)

                                           file.write(“hello worldn”)

                                           file.write(“this is another linen”)


the object name is file and the text file is example.

Now we know how to use write(), I can explain read().

read() is used for reading the text file. The syntax is very simple like with the write() method, just where we wrote “w” now we have to write “r”.

this is the syntax of this:

                                              file = open(‘newfile.txt’, ‘r’)



In this example it shows us the two parameters, the first one tells us what the text file is going to open and the second parameter tells us what is going to do. In this case “r” means that is going to read. Print means that when you are in the terminal, it will print the text that is in the file. In this case it will print:

                                              hello world 
                                              this is another line

We can also specify how many characters the string should return, by using, where “n” determines the number of characters.

This reads the first 5 characters of data and returns it as a string.

In this case, it will print : hello

I learned all this stuff on this web page, you may want to check it out:



Quiz 11

Question 1: Create a function called readNumbersFromFile that receives as a parameter a string with the name of a file (located in the same directory) of numbers. The file has a number on each line (assume all integers).

The function will open the file, read the values and then print (that is right, this function returns no values) the following:

  • The total of the values
  • The number of values (same as number of lines btw)
  • The arithmetic mean (average) of the values
  • The standard deviation of the values.

Link to the answer for question 1:

Question 2: Write a function called check_banana that receives a single parameter of type string that is the name of a file in the same directory as the program. The function opens that file of text and counts the number of times that the string “banana” appears. For full marks it should ignore case (so count Banana, BANANA, bAnAnA regardless of mix of upper and lower case characters).

Link to the answer for question 2:

Quiz 10

I just finished quiz 10. The first question asked to create a a function called findThrees that recieves as a parameter a vector/array/list of numbers and returns the sum of all numbers in that vector/array/list that are evenly divisible by 3. Here’s a screenshot of my code running so that you can appreciate better how this program works.

The second question asked to create a function called dotProduct that recieves two vectors/arrays/lists of numbers (say v1 and v2). The function returns what the dot product of the two vectors/arrays/lists is. Here’s a screenshot of my code running so that you can appreciate better how this program works.

Nevertheless, I’ll leave here the links to my GitHub repository where i have my code for both q1 and q2. Feel free to have a look at them:

q1 :