Thank you TC101!

--Originally published at Coding The Future

If there us one thing that we know for sure is that all good things in this life must come to an end sooner or later.

Today, as the semester comes to an end, I am officially ending this blog. I must say it really has been an amazing experience learning by sharing with you, my amazing readers.

I have included a video above where I share my thoughts on the course, but if I had to summarize my opinion in a few words, it would come to this:

TC101 with Professor Ken Bauer is a course that changes anyone's perspective on how learning should be. Would definitely recommend, especially for proactive learners. Prof. Bauer will teach you things that go beyond programming; he will teach you about life itself.

I wish you all the best in all go your future endeavours and in the upcoming semester.

With love,

Emanuel.

EASY AS 1,2,3?

--Originally published at Coding The Future

Image by Austris Augustus

Greetings everyone! And welcome to my last mastery article. To be honest, I thought I was done, but I just noticed I was missing an important concept in Python: ranges.

Ranges in Python are quite peculiar, because they work a little differently from other languages and also a little differently from what we're used to in Math class. Let's get right into it.

Declaring Ranges

Ranges can be used when we need to work with a set number of elements, like running a loop for a determined range.

To declare a range, we simply call the range( ) function, like in the following example:

range(7)

In this example, where only one number is included, Python asumes that your range will begin at zero, and end in 7. This range has seven elements, and it starts at zero. So if I printed a counter for the range, it would return 0,1,2,3,4,5,6.

However, things get a little tricky when we add a second number to the function, like this:

range(1,7)

In this example, I am working with a range from 1 to 7, but in Python this means from 1 to 6. The first number indicates where the range starts, but the second number represents the number after the last number in the range. So once again, if I were to print a counter, I would get 1,2,3,4,5,6. See? The seven is not included, and even though there is mathematically seven numbers between 1 and 7, the range only has six.

Using Ranges

We can use ranges for a variety of things, but the most common use is for loops. Here's an example of a for loop that prints Hello #n 5 times:

for n in range(1,6): print("Hello #" + n)

If we run this loop, it would Continue reading "EASY AS 1,2,3?"

LOVE TRUMPS HATE? – A student’s views on politics

--Originally published at Coding The Future

Image by Jamie Street

It's been a while since I wrote my last article, and truly I tell you, I wanted to write this article before. I was planning to write this article right after the U.S. election. But then I decided to write it after Remembrance Day. And then I had to push it again, but for a legitimate reason: I needed time. Time to think about the current situation, and time to process all the events that happened in just a matter of days.

Today's topic is not necessarily related to my career, but I am writing about it because it will have an impact in my future, especially since I am part of a minority, and I am Mexican.

After a tough fight, Donald Trump became the president-elect of the United States on November the 8th (also my grandma's birthday). At first, I could not believe it, because all the polls clearly pointed at Clinton as the potential winner, but apparently things weren't as good as they appeared to be. And don't misinterpret me, I am not saying that Hillary was a perfect candidate (she wasn't), but at least I believe that she was more a inclusive and open-minded candidate.

The following days, I sank into a strange kind of crisis, because I was worried about what the future would hold, not only for me, but for my fellow Mexicans. Even though I am not in the US, and I am a permanent resident in Canada, I worry about my country's economy being affected, I worry about the effects that the possible mass-deportation could bring, I worry about the violence that could come as a result of the US government forcing Mexico to pay for the wall, I worry about the suffering that many families will Continue reading "LOVE TRUMPS HATE? – A student’s views on politics"

TEACH ME HOW TO BOT – Building a simple Twitter Bot

--Originally published at Coding The Future

Greetings everyone! I am back, and although this is long overdue, it's finally here!

Today I am releasing my tutorial on how to build a simple Twitter Bot. I have been working on a bot called Manny's Fortune Ball, a simple bot that replies with future predictions every time you ask it a question. You can go check it out by visiting its Twitter profile, and asking him a question. Its handle is @askemanuel.

Above I have attached a interactive slideshow. To move on to the next slide, just click on it, or tap the arrows.

Finally, this is the link to the GitHub repository so that you can check my source code: https://github.com/emamex98/TwitterFortuneBall

I hope you enjoy the tutorial! If you have any questions, do not hesitate to contact me:
Twitter: @emamex98
Email: em (at) nuel.xyz

comments powered by Disqus

Got an old PC?

--Originally published at Coding The Future

It's Sunday night, and I was just reading my weekly article digest, when I suddenly came across an article that I had previously read a few months ago. I instantly knew I had to turn on my laptop and share it with you.

The article targets people who have an old PC just laying around in their homes, or just simply an old PC that's too slow to use. And I think its sad to see a computer like this. But here's a creative way of making that computer useful again! I did it with my old PC a couple months ago and I love it!

Without further due, I leave you with the article, written by Ben Popper and was originally published on The Verge. Please go show him some love by also visiting the original article and leaving a nice comment!


How to turn your old PC into a speedy Chromebook for free

A step-by-step guide to making your old machine into a Chrome capable computer

One of the great ironies of the cloud computing age is that the five to ten year old laptop gathering dust in your desk drawer probably has more horsepower than a top of the line Chromebook which just hit the market. That means you can take a long dormant unit out of retirement and it will typically run quite quickly when paired with a lightweight operating system like Chrome.

Today we're going to walk you through the process for converting an old Mac or Windows PC into a Chrome capable computer. We'll be using a program called CloudReady made by a New York City startup named Neverware. The software actually uses a modified version of Chromium, the open source version of Chrome that Google makes available to third party developers. For the Continue reading "Got an old PC?"

I HAVE NO IDEA OF WHAT THIS IS…

--Originally published at Coding The Future

Picture by Syd Wachs.

Yup... I really don't. Thankfully I was able to find it on my dictionary, and I can now explain to you what a dictionary in Python is.

Remember lists and tuples? Dictionaries are very similar, only that this time, indexes have names, and can hold several types of information within one variable. Little confused? So was I... Here's an example.

Declaring Dictionaries

Let's say I wanted to create a dictionary with all of my personal information, instead of having a single variable for each thing. This is what it would look like:

myInfo = {'Name': 'Emanuel', 'Age': 18, 'University': 'Tec de Monterrey'}

As you can see, declaring a dictionary is quite easy. All I did was to begin with the dictionary's name, and then I assigned values inside of curly brackets. Inside of the brackets, I start by naming the first index Name, and declared the value after the colon. The second index comes after the coma, and if you pay close attention, you'll notice it is not a string, like the first and last index. That's because dictionaries can have several types, unlike lists and tuples.

Therefore, if I wanted to print my name from the dictionary, here's what I would do:

print(myInfo[Name])

Notice how I use the index name and not its number. That's what makes dictionaries different from lists and tuples.

Dictionaries can come in handy when you are dealing with information that can be identified with a name easier than with a number. If you want to learn more ways of how you can use them, be sure to check this tutorial by TutorialsPoint and this one Learn Python The Hard Way –they both really helped me!

That's it for today! Stay tuned for exiting content about bots coming up next Continue reading "I HAVE NO IDEA OF WHAT THIS IS…"

YOUR ARGUMENT IS INVALID, isn’t it?

--Originally published at Coding The Future

via GIPHY

If you had been in my house while I was watching the US Presidential Debates you would probably had heard me scream to my computer "YOUR ARGUMENT IS INVALID DONALD!". Not only do I hate that guy for being so racist, but also because everything he says is just so dumb. And then my girl Hillary comes in saying that you can fact-check Donald from her website in real time. Gotta love that QUEEN!

But aside from US politics, let's move on to today's topic: validating user input. This will not exactly help us to fact-check Donald, but to make sure that the user is entering the right kind of information.

Let's take a registration form for example. We want to collect the user's name, email, and phone number. Therefore, we must make sure that the user includes an @ and a .something and that only numbers are inputted in the phone number field. Here's how it works...

Using the "Try" Approach

To validate input, we could use if-statements, but there's a more effective approach commonly known as Try-catch. This method tries to do something, and if it can't, instead of crashing the program, makes it do something else.

Take a look at the following sample code:

try: phoneNum = int(input("Please enter your phone #: ")) except ValueError: print("Sorry, that phone number is not valid.")

As you can see, the first step was to type try followed by the code you need to validate, which in this case is making sure the input only whole numbers, and then using an except statement to break out of if an error was returned. This prevents the program from crashing, and if combined with a while loop, can prompt the user to enter their number again until they get Continue reading "YOUR ARGUMENT IS INVALID, isn’t it?"

TUPLE UP! – Diving deeper into Lists and Tuples

--Originally published at Coding The Future

Picture by Ed.ward

Greetings everyone! Time to tuple-up! Or is it bucle-up? Who cares... Just make sure to fasten your seatbelt because we are about to begin a journey!

Today, we'll be discussing two very simple yet very powerful types in Python: Lists and Tuples. You may have heard of arrays in other programming languages, but in Python, we have lists and tuples instead, which are in fact, very similar to them.

Let's begging by quickly defining what a list or tuple is. A list is a variable that can store several values, just like it's name suggests. For example, a list of all of your friends' names. A tuple, on the other hand, is a constant that can hold several values, and obviously it remains unchanged throughout the program. For example, a tuple with the months of the year. Let us begin.

Lists

Declaring a new list is quite simple. All you have to do is type the name of the list, followed by the values you would like to assign inside of square brackets. Take a look:

myFriends = ['Daniela', 'Diego', 'Christian', 'Jillian']
myLuckyNumbers = [2, 3, 7, 13, 10, 15]

As you can see above, I declared two lists. The first one, a list that stores strings, and the second one, stores integers. As you may have intuited from the example, you cannot store different data types in the same list.

Each item is stored in an index number of the list, starting from 0. So if I had to chart the second list for example, it would look something like this:

Index Value Stored
0 2
1 3
2 7
3 13
4 10
5 15

Consequently, if you need to work with a specific value stored in n index, you would simply call Continue reading "TUPLE UP! – Diving deeper into Lists and Tuples"

DO NOT READ THIS!!

--Originally published at Coding The Future

Original image by Romain Vignes.

Hello! Ok, I must begging by saying that reading this article will not kill you nor hurt you in any way. In fact, it will be beneficial! So why the title, you may ask? Just to catch your attention! ?

Today's topic is reading and writing text files. This is one of the most important aspects in programming, because if you think about it, 99% of things online are text-based. Think about it... although Google has the option to search through voice and image, 99.9% of the times you probably just type what you need to find and hit enter. See? This is why programs must be able to interpret text because we live in a text-based world.

I want to get things clear though... When I say text files, I am not referring to MS Word documents –those are processed word docs– instead of plain .txt files. Let's get going.

Opening text files

Let's begging by looking at how to open a text file, which is the first step to reading or writing on the file.

In order to do this, we will need to declare a variable where a text file object will be stored. To do so, use the open( ) method and pass the filename as a parameter.

textFile = open(loremIpsum.txt)

Reading text files

Once we have the text stored in textFile, our sample variable, we can read it to process its contents. To do so, we need to use the .read() function.

In the following sample code, I read the text file I previously imported and print it:

print(textFile.read())

As you can see, since the text file is already stored in the textFile variable, I use the function within the file object.

Processing files

By processing, Continue reading "DO NOT READ THIS!!"

OOPS! I DID IT AGAIN

--Originally published at Coding The Future

via GIPHY

Hello my fellow programmers! I'm back again with a new and interesting topic for today. And I know, I said I would stop with the song references, but I just can't!

Today, I'm quoting Britney and her masterpiece Oops! I did it again to get us started on the topic of recursion. Recursion is the repetition of an algorithm for as many times as necessary to generate a conclusion.

What is recursion?

Recursion is funny because it's kind of related to infinity. Is not the same as loop, because the function "calls itself more than one time within its own body"1, becoming something like a function inside a function, inside a function, inside a function, and so on. It can also be interpreted as solving a big problem in smaller and smaller portions, and solving the first and smallest, followed by the second, until reaching the final big problem. However, a recursive function must end at some point to successfully obtain an answer.

Let's dive deeper into the topic. To do that, we will explore a popular example.

Examples of recursion

The Fibonacci numbers are the numbers of the following sequence of integer values:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

The Fibonacci numbers are defined by:
Fn = Fn-1 + Fn-2 with F0 = 0 and F1 = 1.

If we wanted to write a function that returns a determined index of the of Fibonacci series we would use something like this:

def fibo(n): if n == 0: return 0 elif n == 1: return 1 else: return fibo(n-1) + fibo(n-2)

As you may notice, the else statement, which exits within fibo calls itself again, until the the if or the elif are reached. If Continue reading "OOPS! I DID IT AGAIN"