Skip to content

Lesson 03 — Python Data Types

Imagine you’re building a cloud automation script.

The script needs to store:

  • A server name
  • The number of virtual machines
  • CPU utilization
  • Whether a server is running
  • A list of AWS regions
  • A collection of IAM users
  • Configuration settings

Each piece of information is different.

Some are numbers.

Some are text.

Some are either True or False.

Some are collections of values.

Python stores these different kinds of information using Data Types.

Choosing the correct data type makes programs easier to understand, more efficient, and less prone to errors.


After completing this lesson, you will be able to:

  • Understand Python data types.
  • Work with numbers and strings.
  • Use Boolean values.
  • Learn Lists, Tuples, Dictionaries, and Sets.
  • Convert between data types.
  • Inspect variable types.
  • Apply data types in real-world IT automation.

A Data Type defines the kind of value a variable can store.

Examples include:

  • Numbers
  • Text
  • True or False values
  • Collections of data

Python automatically determines the data type based on the value assigned.


Choosing the correct data type helps you:

  • Store information efficiently.
  • Perform calculations.
  • Compare values.
  • Process collections of data.
  • Write reliable automation scripts.

Almost every Python program uses multiple data types.


Data Type Example Purpose
int 100 Whole Numbers
float 95.5 Decimal Numbers
str “AWS” Text
bool True True or False
list [“EC2”,“S3”] Ordered Collection
tuple (“AWS”,“Azure”) Fixed Collection
dict {“Region”:“Mumbai”} Key-Value Pairs
set {“SSH”,“HTTPS”} Unique Values

Integers represent whole numbers.

Example:

servers = 10
users = 250
ports = 443

Integers are commonly used for:

  • Port Numbers
  • User Counts
  • CPU Cores
  • Memory Size
  • Number of Resources

Floats represent decimal values.

Example:

cpu = 73.6
memory = 82.4

Common uses include:

  • CPU Utilization
  • Storage Usage
  • Temperature
  • Network Latency
  • Pricing

Strings store text.

Example:

cloud = "AWS"
name = "GoHackersCloud"

Strings are enclosed using:

" "
' '

Strings are one of the most frequently used data types.


Python supports multi-line strings.

Example:

message = """
Welcome to
GoHackersCloud Academy
"""

Useful for documentation and long messages.


Booleans represent two possible values.

True
False

Example:

server_running = True
vpn_connected = False

Booleans are heavily used in decision-making.


logged_in = True
print(logged_in)

Output:

True

Lists store multiple values in a specific order.

Example:

clouds = ["AWS", "Azure", "GCP"]

Access an item:

print(clouds[0])

Output:

AWS

Lists are mutable, meaning they can be changed after creation.


clouds.append("Oracle Cloud")

Updated list:

AWS
Azure
GCP
Oracle Cloud

Tuples also store multiple values.

Example:

regions = ("Mumbai", "London", "Tokyo")

Unlike lists, tuples are immutable.

Once created, they cannot be modified.

Tuples are useful for storing fixed configuration values.


A Dictionary stores data as Key : Value pairs.

Example:

server = {
"Name": "WebServer01",
"OS": "Windows",
"Status": "Running"
}

Retrieve a value:

print(server["OS"])

Output:

Windows

Dictionaries are widely used in APIs and cloud automation.


Sets store unique values.

Example:

ports = {80, 443, 22}

Duplicate values are automatically removed.

Example:

{22,22,80,443}

Becomes:

{22,80,443}

Sets are useful for removing duplicates.


Python has a special value:

None

Example:

response = None

This means:

No value has been assigned yet.


Use the type() function.

Example:

name = "Python"
print(type(name))

Output:

<class 'str'>

Another example:

age = 25
print(type(age))

Output:

<class 'int'>

Python allows conversion between data types.

Convert String to Integer:

age = int("25")

Convert Integer to String:

age = str(25)

Convert Integer to Float:

price = float(100)

Type conversion is common when processing user input.


age = int(input("Enter Age: "))
print(age + 5)

Without int(), Python treats input as text.


Join strings together.

Example:

first = "Cloud"
second = "Engineer"
print(first + " " + second)

Output:

Cloud Engineer

a = 20
b = 5
print(a + b)
print(a - b)
print(a * b)
print(a / b)

Output:

25
15
100
4.0

Cloud Engineers commonly store:

instance_name = "WebServer01"
cpu = 45.8
running = True
regions = ["Mumbai","London"]
config = {
"Region":"Mumbai",
"Instance":"t3.micro"
}

Automation scripts rely heavily on dictionaries and lists.


Security professionals work with:

  • IP Addresses
  • Usernames
  • Event IDs
  • Log Entries
  • Port Numbers
  • Alerts
  • JSON Responses

Example:

event = {
"EventID":4625,
"Status":"Failed Login"
}

Machine Learning applications use:

  • Numbers
  • Lists
  • Dictionaries
  • Matrices
  • DataFrames

Every AI model begins with structured data.


Beginners often:

  • Forget quotation marks around strings.
  • Try adding numbers to strings.
  • Use the wrong data type.
  • Modify tuples.
  • Misspell dictionary keys.

Understanding data types helps prevent these errors.


A cloud inventory script stores information about virtual machines.

server = {
"Name":"WebServer01",
"CPU":45.5,
"Running":True,
"Services":["HTTP","HTTPS"],
"Region":"Mumbai"
}

Each value uses a different data type to represent the appropriate kind of information.


As a Python developer:

  • Choose the correct data type for each variable.
  • Use dictionaries for structured data.
  • Use lists for collections that change.
  • Use tuples for fixed values.
  • Use meaningful variable names.
  • Verify data types with type().
  • Convert user input before calculations.
  • Keep data structures simple and readable.

Choosing the right data type improves code quality and maintainability.


After completing this lesson, you should understand:

  • Integer
  • Float
  • String
  • Boolean
  • List
  • Tuple
  • Dictionary
  • Set
  • None
  • Type Conversion
  • type() Function

Python Data Types are the foundation of every Python program.

By understanding how to store numbers, text, logical values, and collections of data, you’ll be able to build reliable automation scripts, cloud applications, cybersecurity tools, and AI solutions.

Mastering data types is one of the most important steps toward becoming an effective Python developer.


➡️ Lesson 04 — Python Functions

In the next lesson, you’ll learn how to create reusable blocks of code using functions, understand parameters, arguments, return values, variable scope, and build modular Python programs that are easier to maintain and scale.