Hi in Python 3 we have 6 Basic Types for categorize things, let me show you:

In Python 3 we have:

INTEGERS
We can say an ‘integer’ is an integer, some examples of this could be:
1, 23, 3909, -23, 4, -189

explodingnumbers_mainpic

Unlike other programming languages python use Integers not matter how high or small it is as long as it is integer the type of the number will be INTEGER

With INTEGERS we can do many things, the basic could be math like:

>>>3+9
12

>>> 5-6
-1

But also INTEGERS can be used in the rest of the program, they are a essential part of Python, you  have to be very attentive in do not confuse with string because 43 != ’43’.

Example of assign a INTEGER to a variable and assign a INTEGER of an input.

>>>num_Int = 3

#The first number is a variable that has the value of 3

>>>input_Int= int(input(‘Give me a number’))

#The second ask for the user to put a number and covert it to INTEGER


 

FLOAT
Float numbers are similar to integer just because they’re numbers too, but FLOAT allow you to use decimal numbers and this open a new world, because just imagine try to work with numbers like π or ‘e’ and use INTEGERS… it won’t work right?

istock_pi_daysmall

As equal as INTEGER, FLOAT numbers can be used in mathematical operations.

>>>1.2+5.1
6.3

Also the float numbers can be also be assign to a variable or an input.

>>>num_Float = 3

#The first number is a variable that has the value of 3

>>>input_Float= int(input(‘Give me a number’))

#The second ask for the user to put a number and covert it to FLOAT


 

STRINGS
Strings are a very special type in Python because if you are familiar with other programming languages maybe you know that strings are not objects, but here in Python THEY ARE!

comillas

So you can use a string like a object and make a lot of things with it.

>example_string = ‘Hi everyone!’
>>>example_string
Hi everyone!
>>>len(example_string)            #Length of the string
5
>>>type(example_string)          #Type of the class
<class ‘str’>

Python String Official Reference


 

TUPLES
Tuples are a special type of ordered list in Python 3, because with Tuples you can make a list but you can’t modify it,  it remains always the same.

To make a tuple the process is the following (very simple):

>>>example_Tuple = 1,2,3
>>>type(example_Tuple)
<class ‘tuple’>

To create a tuple just type the elements without any bracket or keys!

But why use tuples if they can’t be edited?
Well sometimes even if you don’t believe me Tuples are necessary just imagine for example that you are in charge of many schools of a region and you really don’t want to miss information, does a tuple can be useful?…

Of course because this way you secure the fact that any school name will be missed.

Python Tuples Official Reference


 

LISTS
List are amazing, as its name says it is a ordered list of things like Tuples but LIST CAN BE EDITED.

To make a list is very simple:

>>example_List = [1, 2, 3]
>>>type(example_List)
<class ‘list’>
#in Lists you can add [use list.append(x)]
>>>example_List.append(4)
>>>example_List
[1, 2, 3, 4]

#in Lists you can remove [use list.remove(x) or list.pop(x)]
>>>example_List.remove(3)
>>>example_List
[1, 2, 4]

#In Lists you can move elements inside and outside [use list.insert(x,y)]
>>>example_List.insert(2,3) #In second space insert number 3
>>>example_List
[1, 2, 3, 4]

Lists are very useful when you know how to use it, because it can help you with stacks and also when you are open a file in Python

Python3 Lists Official Reference

DICTIONARIES
Dictionaries are a link between anything and anything, they are very useful because it keep order the information, and provides different uses.

To make a dictionary follow the following example:

>>family_Age = {‘Me’:18, ‘Sister’:24, ‘Mom’:50, ‘Dad’:55}
>>>type(family_Age)
<class ‘dict’>

#If you call a specific element it return the value
>>>family_Age[‘Mom’]50

#You can add elements very simple
>>>family_Age[‘Uncle’]=47
>>>family_Age
{‘Me’:18, ‘Sister’:24, ‘Mom’:50, ‘Dad’:55, ‘Uncle’:47}

#Also delete
>>>del family_Age[‘Me’]
>>>family_Age
{‘Sister’:24, ‘Mom’:50, ‘Dad’:55, ‘Uncle’:47}

Dictionaries are very useful for several things,  if you want to know more about click the following link.

Python Dictionaries Official Reference

CC BY 4.0 Basic Types and their use in Python3 by cesarisc is licensed under a Creative Commons Attribution 4.0 International License.