Exploring Python Data Types Simplified

Fifehan Adekunle
2 min readOct 11, 2023

--

In the world of data analysis, understanding the types of data you’re dealing with is crucial. Just like extracting oil from the ground, working with data requires a deep understanding. In Python, you’ll encounter various data types, and I’m here to simplify it for you.

You’ll come across various data type categories like:

1. Numeric Data Types:

just like the name numeric covers the numeric type of data. There are 3 types of numeric data types:

a. Integers: These are whole numbers.

Example: print(type(10)) -> <class 'int'>

b. Float: These are numbers with decimal points.

Example: print(type(5.10)) -> <class 'float'>

c. Complex: Combining numbers with special characters like 'j'.

Example: print(type(3j)) -> <class 'complex'>

2. Boolean data type:

This type has only two values: True or False.

Example: 1 > 5 -> False

3. Sequence Data Types:

a. Strings: Text data that can be enclosed in single (‘’), double (“”), or triple quotes (for multiline).strings can be indexed which means you can search within it. Index in Python starts from 0–1–2–3-x

Example 1:

a = “hello fife”
print(a[2:5]) # Output: llo

Example 2:

multiline = “””
Common fruit types:
Apple
Orange
Watermelon
Banana
“””
print(multiline)

b. Lists: These allow you to store multiple values in a single variable. Lists are indexed, and their elements can be of different data types.

Example:

content_creation_tools = [‘Ringlight’, ‘Camera’, ‘Tripod’,50]
print(content_creation_tools)

c. Tuples: Similar to lists, but they cannot be changed or modified once created.

Example:

cannot_be_changed = (1, 2, 3, 4)
print(cannot_be_changed)

d.Sets: Sets do not allow duplicate values and cannot be indexed. They are useful for comparing two variables. Sets can also be used for comparison

Example:

wives_daily_log = {2, 10, 5, 8, 9, 10}

4. Mapping Type:

Dictionaries: These data structures use key-value pairs for organizing data. You can call and update values using keys.

Example:

about_me = {‘name’: ‘Fifehan Adekunle’, ‘Age’: 12, ‘FFS’: [‘amala’, ‘candc’]}
print(about_me)
about_me.keys() : This helps you check the keys example of keys here is name, Age, FFS.
about_me.values(): This helps you check the values example of keys here is Fifehan Adekunle,12,[‘amala’, ‘candc’].
about_me.update({‘name’: ‘Fifz’, ‘FFS’: [‘amala’, ‘candc’, ‘Kuli’]}): this updates your dictionaries.

Understanding these data types is essential for working with data in Python. If you found this article helpful, please like and share it with your friends. What’s your favorite data type in Python? Comment below and let me know why you prefer it. Happy coding!

--

--