Creation and use of dictionaries in Python

--Originally published at Py(t)hon

This is the last post of the mastery topics, so let’s give everything to it. Dictionaries, they are just another type of data just like lists and tuples. They are indexed by keys, which can be any immutable type, or tuples if they don’t contain any mutable object.

You can create them with: {}, there is also a function dict() inside you put all the elements that you want inside the dictionary.Here is an example of a dictionary:

tel = {'jack': 4098, 'sape': 4139}

Here is a cool video:

That’s all of the semester, i have completed my mastery topics #PUG#Tec#TC101#TheEnd#Dictionaries


Reading and writing of text files

--Originally published at Py(t)hon

Computers can also read and write, for them to do so we have to first create a .txt file and we do this by typing file = open(“file name”, “action”).

The next thing that we can do are the next ones:

  • “w” this is use to write in a .txt file
  • “r” this is use to read
  • “a” open the file for apending

Here is an example:


That’s all #Pug#ISC#Tec#NoMore#Python#TextFiles

Validated user input (ensure correct/expected data entry)

--Originally published at Py(t)hon

Most of the time we want our program to be able to interact with the user, to ask him questions and him returning input, well, it is very important to validate the input the user is giving so our program doesn’t crash. For example we have a program were the user has to input a number, how we validate that that input will be indeed a number, we can use the try…except….else block, here is how:


That’s all #Pug#Valid#Input#ISC#Tec#TC101#NoMore


Creation and use of strings

--Originally published at Py(t)hon

This is very easy to learn, first to create a string what you should do is enclose all the characters between quotes like this Ex: str1= “Hello”, this is a string already.

You can play with the string and updated, change it, add more, print it completely, print it partially etc.


Here is a video of strings:

That’s all #Pug#Tec#TC101#Strings#TheEnd


Lists & Tuples

--Originally published at Py(t)hon

It is time for us to learn about lists and tuples, this is a very simple topic. Both are sequence type data, referring to the way they behave, as a sequence. The elements that go inside the list and the tuple can be different kind, a string, a number, even another list or tuple.

The difference between them is that the list is between [ ] and can be modify and the tuple is between parenthesis () and can’t be modify.

An example:

[10, 20, 30, 40, 50]
["spam", "bungee", "swallow"]
(2, 4, 6, 8)
("two", "four", "six", "eight")
[("cheese", "queso"), ("red", "rojo"), ("school", "escuela")]

Here is a video for better understanding:

That’s all? #Pug#Lists&Tuples #ISC#TC101#Tec

Use of recursion for repetitive algorithms

--Originally published at Py(t)hon

This time we are going to learn about recursion, what is recursion? Recursion is a method where the solution to a problem is based on solving smaller instances of the same problem or in other words  is a way of programming or coding a problem, in which a function calls itself one or more times in its body.

An example is the function of the factorial:


Click here for more examples.

Here is a video for better understanding:


Loops, loops, loops …

--Originally published at Py(t)hon

Is time for us to learn about loops, the loops help us to repeat a piece of code several times instead of writing the code all over again. There are two kinds a while loop and a for loop, the while loop  tests the condition before executing the loop body, while a given condition is TRUE, it will repeat a statement or a group of statements. On the other hand, we have the for loop that executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.

Here is an example of for loop:


and for while loop:loop-2

That will be all here is a video for better understanding:



Creation and use of Lists/Tuples (Python)

--Originally published at angelmendozas

  • Lists are what they seem – a list of values. Each one of them is numbered, starting from zero – the first one is numbered zero, the second 1, the third 2, etc. You can remove values from the list, and add new values to the end. Example: Your many cats’ names.
  • Tuples are just like lists, but you can’t change their values. The values that you give it first up, are the values that you are stuck with for the rest of the program. Again, each value is numbered starting from zero, for easy reference. Example: the names of the months of the year.

Here’s a really good page to learn about them:

Basically, you create lists when you can delete values, and change then as you wish in your code and tuples do not let you do this, they are constants we could say.

Creation and use of strings

--Originally published at angelmendozas

Strings are extremely useful in python programming, they can arrange data, return frases with data the user inputs, and several more things but in its most basic way you crate variables and ask the program to return whatever you want it to return.

potato1:’I love Canada’

potato2:’I hate Trump’

those are our variables, potato 1 and 2.

then we can ask the program to return part of the sentence as we know counting from zero (zero=one, the first word in the sentence)

print potato1[0:]

print potato2[6:]

Potato 1 will return ‘I love Canada’ and potato 2 will return ‘Trump’