You’re not my Type sorry

--Originally published at M E R I N O

Variables:

First, we have to know what is a variable?

In programming, a variable is a value that can change, depending on conditions or on information passed to the program

-WhatIs.com

Now, we know what is a variable but… How do I assign it?

To assign a variable you just need to add the equal sign (=) that’s it, you now have a variable… Kinda.

Also you can do multiples assignments like this:

Or assign the same value to different variables like this:

 

Types of variables:

There are 6 main datatypes of variables.

1- Numbers:

In this category are 4 “subcategories”:

  • Integers (int)
  • Long Integers (long)
  • Floating point real values (float)
  • Complex Numbers (complex)

Here are some examples:

captura-de-pantalla-2016-09-11-a-las-20-37-28

captura-de-pantalla-2016-09-11-a-las-20-38-17

2 -String:

In a string variable you can add any type of characters, number, symbols letters, you only need to add “” and write whatever you want, like this.Captura de pantalla 2016-09-11 a la(s) 20.40.43.png

 

3- List:

In this variable you can add various values to a single variable, you declare it with [] and separate the values with a ” , ” like thisCaptura de pantalla 2016-09-11 a la(s) 20.49.27.pngCaptura de pantalla 2016-09-11 a la(s) 20.50.01.png

Then you can choose the value you want or the range of values. For a single value you only write between the [] the number in which the value is positioned, be careful because in Python, the first value is the value 0

Captura de pantalla 2016-09-11 a la(s) 20.50.41.pngCaptura de pantalla 2016-09-11 a la(s) 20.51.09.png

Captura de pantalla 2016-09-11 a la(s) 21.03.25.pngCaptura de pantalla 2016-09-11 a la(s) 21.03.42.png

To remove an element from the list, you can use del list [#]  or you can use list.remove (“value”). It only takes out the value but the sequence keeps going with the next value . Here is an example:

Captura de pantalla 2016-09-11 a la(s) 21.07.45.png
Captura de pantalla 2016-09-11 a la(s) 21.08.02.png

Also you can change or update the values of a list, like this:
Captura de pantalla 2016-09-11 a la(s) 22.16.10.png

Captura de pantalla 2016-09-11 a la(s) 22.16.35.png

4 – Tuple:

A Tuple is like a list, but less flexible and instead of using [] we use (). You can’t replace values. Example:Captura de pantalla 2016-09-11 a la(s) 22.04.52.png

Captura de pantalla 2016-09-11 a la(s) 22.05.33.png5-

Captura de pantalla 2016-09-11 a la(s) 22.11.10.png
Captura de pantalla 2016-09-11 a la(s) 22.11.23.png
Captura de pantalla 2016-09-11 a la(s) 22.21.35.png
Captura de pantalla 2016-09-11 a la(s) 22.21.56.png

Set is also like a list, but there is no order, you cannot call a certain value of the Set and you can only write unique values. To declare a Set we use {}. If you look closely , in the code are 2 “3” and in the final program it only shows 1.

Captura de pantalla 2016-09-11 a la(s) 22.11.10.png

Captura de pantalla 2016-09-11 a la(s) 22.11.23.png

6- Dictionary:

A Dictionary is often used when you have a lot of data. You assign a keyword to a value.
dic = {“key”:”value”, “key2″:”value2”} .Like this:

Captura de pantalla 2016-09-11 a la(s) 22.21.35.png

Captura de pantalla 2016-09-11 a la(s) 22.21.56.png

If you want to learn more you can click here. Thanks for reading.