Main Data Types of Python
Every value in Python is called an "object". Every object has a specific data type. The three most-used data types are the following:
Integers (int)
Integers are numbers used to represent an object such as number 3.
​
Integers = ...... -2, -1, 0, 1, 2, 3, 4, 5, .......
Floating-point numbers (float)
Used to represent floating-point numbers. Float-point numbers are any real numbers with a decimal point.
​
Floating-point numbers = .... -1.25, -1.0, 0.0 , 1,.5, 2.3, 3.5, ...
Strings
Strings are array of sequenced characters and is written inside single quotes, double quotes or triple quotes. Also, A string is a list of characters that is in order. You can codify a sequence of characters using a string. For instance, the word "hello".
​
Strings = 'Yo', "Hello!", "'Hi!"'
Lists
Lists are used to specify an ordered sequence of elements. Basically, they help programmers keep related data together and perform the same operations on several values at once. Compared to string, lists are mutable or changeable.
​
my_list = [1, 2, 3]
​
my_list2 = ["a", "b", "c"]
Tuples
Tuples are similar to lists. They allow you to display an ordered sequence of elements. But they are immutable and you cannot change the values stored in a tuple. These are slightly faster than lists in optimizing the codes.
​
my_tuple = (1, 2, 3, 4, 5)
​
my_tuple[1:3]
Dictionaries
Dictionaries holds indexes with keys that are mapped to certain values. These key-value pairs offers a great way of organizing and storing data in Python. A key value can either be a string, boolean, or integer.
​
Customer 1 = {'username': 'john-sea': 'online': false, 'friends':100}