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

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…"

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"

NO STRINGS ATTACHED

--Originally published at Coding The Future

Photo by Everton Vila

Hey everyone! It's been so long since my last post, but trust me, there's reasons for my absence and I am back with exiting stuff.

To begin today's topic, I have another of my quick stories... Lately, my life has been overtaken by discernment confusion on what I want to do, what I must do, and what is expected of me. I don't think a lot people go through this kind of crisis as often as I do, but I think we've all been there at some point in our lives. How is this relevant? Again, it really isn't, but I wish I could just try things sometimes without any strings attached.

Oh, well. That was deep. But now let's focus on strings, yay!

What are strings?

As you may know from my previous posts on types, one of the most interesting and common types in programming languages are strings.

Strings are a literally a chain of characters of any type. So any text-based variable is a string. Strings can include numbers, but these are not treated like numbers, rather like labels. So if you declare two strings like "2" and "4" and try to multiply them, you will get an error, because you can't multiply text! Get it? String is just plain text.

Declaring strings

Declaring strings in Python could not be easier. All you need to do is declare a variable and assign it a value within quotation marks. Take a look:

firstName = "Emanuel"

Now, we can do all sorts of things with this string! We can print it, we can concatenate it (join it with another string), split it, you name it!

How can they be used?

As I just mentioned, strings can be pretty powerful. I know I said you Continue reading "NO STRINGS ATTACHED"

FOR ALL THOSE PROCRASTINATORS

--Originally published at Coding The Future

If you are reading this right now, you were probably procrastinating, and just started studying for tomorrow's test, right?

Well, as always, I've got you covered. Here's a quick video summary of what you need to know for the first partial. I hope things are not too strange.

Good luck!

I AIN’T GOT NO TYPE

--Originally published at Coding The Future

Image via GIPHY

Personally, I am not a rap fan, but again, I am making a reference to a song. This time, No Type by Rae Sremmurd came to mind when thinking about the different types of data you can work with on Python.

Even though we've already been working with them, let's discuss these data types in more detail...

  • Integers: They store a whole numeric value with no decimals, e.g.: 5.
  • Floats: They store a numeric value with decimals, e.g.: 23.43.
  • String: They store a string of characters of any type, e.g.: "Hello". Note that in Python there is no char (character) type. If you wanted to store only one character, use a string of length one. Also, just like it's name suggests, it is a string of characters tied together, so you can access each character using it's position. For example, in "Hello", string[1] is 'e'.
  • Booleans: They store a binary value of true or false. Basically, a variable of this type can only have a value of true or false. The false value can be expressed as 0, and true as any other number. E.g.: userIsMale = false.

Also, there are types in which several items can be stored within one variable. In other programming languages, they are usually called arrays, but in python they are somewhat different.

  • Lists: A list that stores several variables, and can be expansible. They are not limited to just storing one type of data; or in other words, you can store ints, strings, floats, in just one list. E.g.: list = [1, 2, hey, music, 12.34]
  • Tuples: Similar to a list, but static. Once it is declared, it remains fixed. E.g.: tuple = {1, 3, hello}

That's Continue reading "I AIN’T GOT NO TYPE"

I AIN’T GOT NO TYPE

--Originally published at Coding The Future

Image via GIPHY

Personally, I am not a rap fan, but again, I am making a reference to a song. This time, No Type by Rae Sremmurd came to mind when thinking about the different types of data you can work with on Python.

Even though we've already been working with them, let's discuss these data types in more detail...

  • Integers: They store a whole numeric value with no decimals, e.g.: 5.
  • Floats: They store a numeric value with decimals, e.g.: 23.43.
  • String: They store a string of characters of any type, e.g.: "Hello". Note that in Python there is no char (character) type. If you wanted to store only one character, use a string of length one. Also, just like it's name suggests, it is a string of characters tied together, so you can access each character using it's position. For example, in "Hello", string[1] is 'e'.
  • Booleans: They store a binary value of true or false. Basically, a variable of this type can only have a value of true or false. The false value can be expressed as 0, and true as any other number. E.g.: userIsMale = false.

Also, there are types in which several items can be stored within one variable. In other programming languages, they are usually called arrays, but in python they are somewhat different.

  • Lists: A list that stores several variables, and can be expansible. They are not limited to just storing one type of data; or in other words, you can store ints, strings, floats, in just one list. E.g.: list = [1, 2, hey, music, 12.34]
  • Tuples: Similar to a list, but static. Once it is declared, it remains fixed. E.g.: tuple = {1, 3, hello}

That's Continue reading "I AIN’T GOT NO TYPE"