Y termino el semestre…!

--Originally published at Start in the world of the #TC101

Ya terminaron las clases, pero aún no podemos cantar victoria, pues se viene en la recta final los exámenes finales, mañana (24 de noviembre) será el examen de esta materia (Fundamentos de programación) , y es justo de ella de quien quiero hablar, quiero platicarles un poco la experiencia que me dejo esta materia.

Creo que esta materia me ha dejado mucho aprendizaje, porque la manera de enseñar de Ken, es muy interesante, aunque al principio me parecía muy rara, pero creo que con el paso del semestre he podido entenderla mejor, y me ha quedado como una idea muy interesante, donde nos dan a los estudiantes la responsabilidad de nuestro propio desempeño académico, pero de la mano de un profesor que esta siempre disponible para resolver las dudas de los estudiantes.

En definitiva me gustaría volver a tener una clase con Ken o con alguien que tenga su misma ideología, pero creo que eso va a ser un tanto complicado, pero estaría genial que los profesores empezaran a tomar en cuenta el hacer sus clases de esta manera.


Reading and writing of text files

--Originally published at Start in the world of the #TC101

Variables are a fine way to store data while your program is running, but if you want your data to persist even after your program has finished, you need to save it to a file. You can think of a file’s contents as a single string value, potentially gigabytes in size. In this chapter, you will learn how to use Python to create, read, and save files on the hard drive.

In Python, you don’t need to import any library to read and write files.
The first step is to get a file object.
The way to do this is to use the open function.

In this link (http://www.pythonforbeginners.com/files/reading-and-writing-files-in-python) we can have a better explanation about the topic

And here are examples:

http://stackoverflow.com/questions/3925614/how-do-you-read-a-file-into-a-list-in-python


Validated user input (ensure correct/expected data entry)

--Originally published at Start in the world of the #TC101

An important part of making sure your program is as robust as possible is checking the user’s input to make sure they’ve entered the right sort of information. Here’s a simple example that illustrates the concept.

15135657_1123641437683377_1348959859_n.jpg

Reference:

https://a00344371.wordpress.com/2016/11/23/validated-user-input/

http://openbookproject.net/pybiblio/tips/wilson/validating.php


Creation and use of ranges in Python

--Originally published at Start in the world of the #TC101

  • Range() is a function, it is used to generate a list of numbers. And it has a set of parameters:
    start: Starting number of the sequence.
  • stop: Generate numbers up to, but not including this number.
  • step: Difference between each number in the sequence

NOTES:

  • All parameters must be integers.
  • All parameters can be positive or negative.

Example:
# One parameter

for i in range (16):

print (i)

print(“—————————–“)

# Two parameters

for i in range (2,8):

print (i)

print(“—————————–“)

# Three parameters

for i in range (2,9, 3):

print (i)

print(“—————————–“)

↓ ↓ ↓ ↓ ↓


Reference: http://pythoncentral.io/pythons-range-function-explained/


Creation and use of dictionaries in Python

--Originally published at Start in the world of the #TC101

A Dictionary  is a way to store data just like a list, but instead of using only numbers to get the data, you can use almost anything. This lets you treat a dictionary like it’s a database for storing and organizing data any kind of data. 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: {}.

Example:

states = {
“Oregon”: “OR”,
“Florida”: “FL”,
“California”: “CA”,
“New York”: “NY”,
“Michigan”: “MI”
}
print (“Michigan’s abbreviation is: “), print (states[“Michigan”])
print (“Florida’s abbreviation is: “), print (states[“Florida”])
print (“Oregon’s abbreviation is: “), print (states [“Oregon”])
print (“California’s abbreviation is: “), print (states [“California”])
print (“New York’s abbreviation is: “), print (states [“New York”])

↓  ↓  ↓  ↓  ↓  ↓  ↓

Karina-Ramirez:desktop Karina$ python3 dictionary.py

Michigan’s abbreviation is: MI

Florida’s abbreviation is: FL

Oregon’s abbreviation is: OR

California’s abbreviation is: CA

New York’s abbreviation is: NY


Creating functions

--Originally published at Start in the world of the #TC101

Functions are a convenient way to divide your code into useful blocks, allowing us to order our code, make it more readable, reuse it and save some time. Also functions are a key way to define interfaces so programmers can share their code.

To create a function you have to start with def follow by parenthesis (), inside this parenthesis goes the parameters necessary, if needed of course, after the parenthesis goes a colon (:) and then to close it, use the return function follow by the value statement, if you don’t want it to return anything, just leave a blank space, the system will take it like None.

Reference: http://www.learnpython.org/en/Functions

 


Importing and using modules/libraries

--Originally published at Start in the world of the #TC101

In Tutorialspoint tell us about A module allows you to logically organize your Python code. Grouping related code into a module makes the code easier to understand and use. A module is a Python object with arbitrarily named attributes that you can bind and reference.

Simply, a module is a file consisting of Python code. A module can define functions, classes and variables. A module can also include runnable code.

Creating a module is easy. All you have to do is create a new Python file and define the functions that will belong to that module, and once you wanted to use the library you just created or downloaded from the internet, the first step would be to import it. In the file where you will use it, type the word import followed by the name of the module.

 


Importing and using modules/libraries

--Originally published at Start in the world of the #TC101

In Tutorialspoint tell us about A module allows you to logically organize your Python code. Grouping related code into a module makes the code easier to understand and use. A module is a Python object with arbitrarily named attributes that you can bind and reference.

Simply, a module is a file consisting of Python code. A module can define functions, classes and variables. A module can also include runnable code.

Creating a module is easy. All you have to do is create a new Python file and define the functions that will belong to that module, and once you wanted to use the library you just created or downloaded from the internet, the first step would be to import it. In the file where you will use it, type the word import followed by the name of the module.