Experiencia Técnica durante Semestre i

--Originally published at Programming

Siento nostalgia al volver a escribir en este blog que comencé a utilizar hace dos años, pero me gusta ver todo lo que he avanzado desde el momento en el que puse un pie en la universidad. He adquirido muchos conocimientos y conocido profesores que además de tener pasión por la educación son buenas personas. Todo esto me ha ido forjando el camino hacia este famoso semestre i. Por eso, en este blog hablaré sobre mi experiencia técnica con la aplicación web y al montar la base de datos. Antes de comenzar me gustaría clarificar qué fue lo que hicimos en el semestre i para aquellos que no están familiarizados con el reto. Este reto se trataba de buscar una solución a la problemática del alumbrado público utilizando el internet de las cosas. Nuestra solución fue la implementación de alumbrado inteligente con un servicio en la nube de administración remota, el cual les permite a los administradores de forma sencilla visualizar datos y estadísticas, así como ver las fallas de las lámparas y asignar técnicos para la pronta reparación de estas.

Mi equipo de semestre i estuvo muy bien balanceado, teníamos personas con experiencia y conocimientos en diversas áreas. Por lo que la realización de la parte técnica del reto fue pan comido. Cada integrante se encargaba de lo suyo y luego compartía sus conocimientos a los demás integrantes del equipo para que todos supieran cómo lo hizo y cuáles eran las mejores prácticas. En mi caso, al ser estudiante de ISC, no me tocó meterme tanto en el microcontrolador, yo me encargué principalmente del diseño y la implementación de la base de datos y parte de la aplicación web. Como estudiante de computación pensarían que principalmente me enfoqué en la aplicación web, pero la verdad es que en nuestro Continue reading "Experiencia Técnica durante Semestre i"

Mi experiencia durante el Semestre i

--Originally published at Programming

Ya son casi dos años desde la última vez que había escrito en este blog. Durante este periodo de tiempo muchas cosas han cambiado y cabe resaltar que esta será la única publicación que haré en español. El motivo de este blog es transmitir mis experiencias, gustos, disgustos y preocupaciones sobre el semestre i, una nueva forma de aprendizaje del modelo Tec 21, de las carreras ISC (Ingeniería en Sistemas Computacionales) e ITE (Ingeniería en Tecnologías Electrónicas). Describir detalladamente toda la experiencia de este semestre es casi imposible, ya que me llevaría muchísimo tiempo hablar sobre cada pequeño detalle y es posible que se me escapen varios. Por lo que decidí segmentar esta entrada en cuatro diferentes secciones: Lo bueno, lo malo, el trabajo en equipo y una opinión sobre el semestre. Trataré de ser lo más objetivo durante los primeros dos puntos. Sin más que decir, comencemos.

Lo bueno

Al iniciar el semestre, tenía grandes expectativas del reto, ya que la idea de combinar todas las materias del semestre (Interconexión de redes 1, Interconexión de redes 2, Microcontroladores, Administración de proyectos, Bases de datos y ciudadanía) en un solo proyecto era una oferta tentativa con muchas posibilidades y, a decir verdad, fue así por la mayor parte. En lo personal, aprendí bastante sobre diferentes temas de cada materia y logré hacer una conexión de la mayoría de los aprendizajes de todas las materias. La mayoría de las clases no eran aburridas, al contrario, algunas hasta tenían dinámicas entretenidas y útiles para retener conocimientos y tener una mejor comprensión del tema. Cabe resaltar que la mayoría de los profesores mostraron una actitud positiva y servicial ante los alumnos durante el desarrollo del semestre y principalmente durante las semanas de inmersión.

A diferencia de los otros semestres que he tenido, algo Continue reading "Mi experiencia durante el Semestre i"

TC101 course review

--Originally published at Programming

As my last blog post of this semester I’m going to be reviewing my experience with the flipped learning TC101 course. I’m going to be completely honest by saying what I liked, what I didn’t like and give some suggestions that could help to improve the student’s experience as well as their desire to learn.

To start I want to thank ken for what he is trying to do. He’s encouraging people to learn by themselves by changing the traditional educational system that we have in our country. Technically he’s “breaking” TEC rules and imposing his own grading system (abolish grades) which is good! He wants people not to depend on a teacher to learn, he wants them to think out of the box and do research, find their own solution to problems and stay connected. He wants his students to work in pairs because that way they can learn from each other. This doesn’t mean that he won’t help you, he’s encouraging you to learn but if at some point you get stuck he’ll be always there to help you and make sure you understand the topic.

Now the video reviewing this semester’s TC101.


Challenge TC101 Frequency Dictionary

--Originally published at Programming

The first challenge posted by ken is the next one:

Using a file full of words, create a program that counts how many times each word is repeated in the file. We are going to do first some functions that’ll help us throughout this process. First we’ll create a function read_from_file which will basically open a file and read from it every word, storing them in a list. This function returns a list of words.

def read_from_file(file):
    """
    :param file: The file words are going to be read from
    :return: a list with the words inside the file
    """
    lista = []
    try:
        f = open(file, 'r')
        for line in f:
            line = line.strip('\n')  # Get rid of the \n at the end of each line
            lista += line.split(" ")  # get every word of the line and store it inside a list
        f.close()
    except IOError:
        print("Cannot open " + file)
    return lista

Now we are going to create a function that counts the frequencies of the words inside a list by storing it in a dictionary. The dictionary keys will be the words and the values will be the number of times each word appears in the list. This function returns a dictionary with frequencies.

def count_frequency(words):
    """
    :param words: List of words
    :return: A dictionary with frequencies of words
    """
    frequency_words = {}
    for word in words:  # iterate over the list
        # If the word is not already inside the dictionary's keys, create it
        if word not in frequency_words.keys():
            frequency_words[word] = 1
        else:
            frequency_words[word] += 1
    return frequency_words

Now we have the dictionary and it’s time for us to test whether this program works or not. So create a text file with random words, repeat some of them on purpose so that you can check

testfile.png
Continue reading "Challenge TC101 Frequency Dictionary"

Challenge TC101 Frequency Dictionary

--Originally published at Programming

The first challenge posted by ken is the next one:

Using a file full of words, create a program that counts how many times each word is repeated in the file. We are going to do first some functions that’ll help us throughout this process. First we’ll create a function read_from_file which will basically open a file and read from it every word, storing them in a list. This function returns a list of words.

def read_from_file(file):
    """
    :param file: The file words are going to be read from
    :return: a list with the words inside the file
    """
    lista = []
    try:
        f = open(file, 'r')
        for line in f:
            line = line.strip('\n')  # Get rid of the \n at the end of each line
            lista += line.split(" ")  # get every word of the line and store it inside a list
        f.close()
    except IOError:
        print("Cannot open " + file)
    return lista

Now we are going to create a function that counts the frequencies of the words inside a list by storing it in a dictionary. The dictionary keys will be the words and the values will be the number of times each word appears in the list. This function returns a dictionary with frequencies.

def count_frequency(words):
    """
    :param words: List of words
    :return: A dictionary with frequencies of words
    """
    frequency_words = {}
    for word in words:  # iterate over the list
        # If the word is not already inside the dictionary's keys, create it
        if word not in frequency_words.keys():
            frequency_words[word] = 1
        else:
            frequency_words[word] += 1
    return frequency_words

Now we have the dictionary and it’s time for us to test whether this program works or not. So create a text file with random words, repeat some of them on purpose so that you can check

testfile.png
Continue reading "Challenge TC101 Frequency Dictionary"

Reading and Writing of Text Files

--Originally published at Programming

Introduction

This is going to be the last blog post for this semester’s introduction to programming using Python. Today we are going to talk about files, how to create a file, how to read a file and how to write on a file.

Create a file

To create a file, we need a file object. In order to do that, you need to create a variable, name it however you want, and set it equal to the built-in function open(), which takes two parameters. The first parameter is the name of the file, if the file already exists, Python will use it and if it doesn’t exist, it’ll be created. The second parameter is going to take a character  which might be ‘w’ or ‘r’. The ‘w’ character means you are going to be writing to the file you’ve created. The ‘r’ characters means you are going to be reading the contents of the file. At this point you have created a file object.

1.png

Write on File

In order to write on the file we’ve just created, we have to use the file method write(). Basically this method is going to allow us to type on the file. This method takes one parameter, which is the text you are going to write on the file. After you hit the run button, you will find a .txt file in the folder where your .py file is. After you are done writing, you must close your file object by using the close() method so you don’t waste any extra memory.

1.png

3.png

Read From a File

In order to read from a file, another file object is going to be required. First you name your variable, then you set it equal to the function open(). The same function that we used in order to create our writable

2.png
3.png
Continue reading "Reading and Writing of Text Files"

You are the only Exception

--Originally published at Programming

Introduction to Exceptions

It’s been a long journey for some of you. Whether you’ve spent 10+ hours coding or just a couple, I’m pretty sure you are familiar with the error messages that the console displays when your code is wrong. So far you don’t care if the user enters a number when they are supposed to enter a string, but that’s from the past. It’s now time for us to take the next step and start handling exceptions. By now you should know that there are at least two important noticeable kinds of errors: syntax errors and exceptions.

Syntax Errors

Probably one of the most common kind of errors for the people that are still in the process of learning Python. The console will print a Syntax Error message showing you with an arrow ^ the earliest point in the line where the error was detected, followed by the number of the line so you know where to look.
1.png

2.png

Exceptions

A statement or an expression can be syntactically correct and yet, an error may occur when the program is executed. This is caused because of an exception, which is defined as an error occurred during the execution of a program. Exceptions come in different types, some types for the exceptions are:

  • ZeroDivisionError (Divide a number by 0)
  • TypeError(When an operation or function is applied to an object of inappropriate type)
  • ImportError(When an import statement fails to find the module)
  • IndexError(When a sequence substring is out of range)
  • KeyError(When a Dictionary key is not found in the set of existing keys)
  • ValueError()

Check out the documentation for the Python 3.5 Built-in Exceptions here

Handling Exceptions

Now that we know some types of exceptions, it’s time for us to learn how to handle them. Let’s take a look at the following example where the program asks

3.png
5.png
6.png
Continue reading "You are the only Exception"

Challenge #1

--Originally published at Programming

For those of you who already feel comfortable using Python I’d like to post a set of different challenging problems that involve all of the mastery topics we’ve covered so far. You can find the solution of these problems online,  but I encourage you to try and code them so you can start combining the mastery topics you’ve been studying and to start thinking as a computer scientist.

Challenge

Assuming that you have any string. Write a program that prints the longest substring of your string in which the letters occur in alphabetical order.

Example:

if str = “agdgijkab”, your program should print: Longest substring in alphabetical order: dgijk

Hint: “a” < “b”


Thou Shalt Not Take The Name Of Python In Vain

--Originally published at Programming

The Zen Of Python

Image retrieved from http://www.sniferl4bs.com/2015/04/zen-of-python.html#

 

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren’t special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one– and preferably only one –obvious way to do it.
Although that way may not be obvious at first unless you’re Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it’s a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea — let’s do more of those!


No strings attached

--Originally published at Programming

Creation and use of Strings

Today, we are going to be talking about a very simple topic, how to create and use strings in Python. You may think that you’ve already mastered the art of strings, but you would be surprised if you knew that you don’t know the full potential of strings. Let’s begin.

A string is one of the most popular data types in Python, they can be created by surrounding a sentence in double quotes “” or single quotes ”. You use them when you print them out to the console and when you assign a string to a variable.

Access substrings in Strings

Unlike other languages, Python does not support the character type, so any value that is contained within a string is going to be called substrings. To access is pretty simple, since it is the same as if we had a list and we wanted to get the value at i position. 1.png

Slicing Strings

Just like with lists, we can slice a string by using the square brackets along with the indices to obtain the new string.

2.png

3.png

Non Printable Characters

If you use a non printable character inside a string, they are not going to be printed. These non printable characters, also called escape characters, are not going to be printed by the console, instead they are going to make some changes to you string. Don’t worry if you don’w understand yet, let me use some examples.

4.png

5.png

Special Operators

Here is a list with examples of the most important string operators that you are eventually going to be using.

6.png

7.png

Built-in String Methods (Functions)

As you should remember, lists have their methods to manipulate and insert data. Some examples for those methods are the append() or the insert(). But fortunately strings have also their own set

Continue reading "No strings attached"