Basic data types

--Originally published at Hector Martinez Alcantara

In this post we’re going to see the basic types of variables we can have in python 3.

Number: These are created by assigning a value to a variable, there are diferent types that python support automatically they are:

  • int (signed integers)
  • long (long integers, they can also be represented in octal and hexadecimal)
  • float (floating point real values)
  • complex (complex numbers)

Example of Numbers:

var=5 #integer
var=5.5 #float
var=555555555L #The letter L is to long numbers
var=5.55e-34j #Complex numbers have a j that's the imaginary unit

String: They are arrays of characters that are usually words or sentences.

They’re variables that saves sentences, that are usually shown in the screen or will be transformed to be shown in the screen.

Example of Strings:

var='Hello, I love tacos'

List: The lists are like arrays of diferent or common types of variables, the lists can be updated whenever you want, and can be enlarged.

Lists are often used as lists (even the word say it).

Example of List:

var=['Hello',5,'another thing',5.5]

Tuple: They are arrays of diferent or common types of variables, but ulike lists, the tuples can’t be updated, and are only one length.

Tuples are often used as normal arrays.

Example of Tuple:

var=('Hello',5,'another thing',5.5)

Dictionary: They are arrays of diferent or common types of variables but unlike tuples and lists every space in the array can be named diferent.

They are often used as tables (like the tables in databases).

Example of Dictionary:

var = {'a string': 'Hello','an integer': 5, 'a float': 5.5}

Now you feel like…

Thanks for reading.

Special thanks to Tutorials point Python Variable Types