📎 Referral Code:
📊 Dashboard Sign In
Navigation
🗺️
Live Classes
🗺️
Courses
🎬
Assignments
💡
Q & A
💡
My Profile
💡
Recruiter Board
Job Support
🎯
Interview Board
AI Tools
🌐
Project Explanation Agent
🛟
Support Works
📂 1. Python Basics To Advanced Level ⏱ 1.0h 📋 Video 2 of 21
📝 Class Notes
Class Documentation · Python Fundamentals

Python Data Types

What data types are, why Python cares about them, and how each one shows up in real code you'll write on the job.

01

What Is a Data Type, and Why Does Python Care?

You write "5" + 3 expecting the answer 8, but Python throws an error instead. Why? Because "5" is TEXT and 3 is a NUMBER — Python refuses to guess which one you actually meant.

A Data Type tells Python exactly WHAT KIND of value you're working with — a number, text, a true/false answer, or a whole collection of values. Python uses this to decide what operations (+, -, comparisons, loops) are even allowed on that value.

Why You're Learning This

Every single bug you'll debug in your first months as a developer will very often trace back to a data type mismatch — treating text as a number, or expecting a list where you actually got a single value. Understanding data types isn't optional theory; it's the #1 skill that prevents confusing, hard-to-read error messages from ruining your day.

check_type.py
age = 25
name = "Sai"

print(type(age))    # <class 'int'>
print(type(name))   # <class 'str'>
Remember This
  • Data type = what KIND of value Python is dealing with
  • type(value) tells you exactly what type something is — use it whenever you're unsure
  • Most "weird" Python errors are actually type mismatches in disguise
02

Numeric Types — int, float, complex

You're calculating someone's age (a whole number) and their average test score (which can have decimals, like 87.5). Python needs to distinguish between these, since dividing whole numbers can behave differently than dividing decimals.

Simple Answer: int is a whole number (no decimal point). float is a number WITH a decimal point, used for anything that needs precision (money, measurements, averages). complex handles numbers with a real and imaginary part — rare in everyday coding, mostly used in scientific/engineering calculations.

numeric_types.py
age = 25              # int - whole number
average_score = 87.5    # float - has a decimal point
signal = 3 + 4j         # complex - rarely used in everyday code

print(type(age))            # <class 'int'>
print(type(average_score))  # <class 'float'>
Where You'll Use This in Your Career

In real data engineering work, choosing int vs float correctly matters — storing money as float can cause tiny rounding errors that add up over millions of transactions (a real, famous class of bugs in finance systems). You'll often deliberately choose specific numeric precision when designing database columns and PySpark schemas for exactly this reason.

Remember This
  • int → whole numbers (1, 25, -10)
  • float → decimal numbers (3.14, 87.5, -0.5)
  • complex → real + imaginary parts (3+4j) — rare in typical coding
03

String (str) — Working With Text

You need to display "Welcome, Sai!" on a webpage, combining a fixed greeting with the user's actual name — text needs its own type because you can't "add" letters the same way you add numbers.

Simple Answer: A string is any text, wrapped in quotes (single or double). Strings support their own set of operations — combining (concatenation), repeating, slicing out parts of the text, and searching within it.

strings.py
name = "Sai"
greeting = "Welcome, " + name + "!"   # concatenation

print(greeting)              # Welcome, Sai!
print(name.upper())         # SAI
print(name[0])              # S  (first character)
print(len(name))            # 3  (number of characters)
Where You'll Use This in Your Career

String handling is everywhere — cleaning messy text data from CSVs (extra spaces, wrong casing), building SQL queries dynamically, parsing log files, and formatting reports. Nearly every ETL pipeline you'll build involves cleaning and reshaping strings at some point.

Remember This
  • String = text, wrapped in quotes ("like this" or 'like this')
  • Strings are indexed from 0 — the first character is name[0], not name[1]
  • Strings are immutable — you can't change one character directly, you create a new string instead
04

Boolean (bool) — True or False Answers

Your program needs to decide: "is this user old enough to register?" The answer can only ever be Yes or No — there's no in-between value that makes sense here.

Simple Answer: A Boolean holds exactly one of two values: True or False. It's what every comparison (>, ==, in) produces, and what every if statement checks.

booleans.py
age = 20
is_adult = age >= 18     # comparison produces a boolean

print(is_adult)        # True
print(type(is_adult))  # <class 'bool'>

if is_adult:
    print("You can register")
Where You'll Use This in Your Career

Booleans drive EVERY decision your code makes — validation checks, filtering data ("is this row valid?"), controlling loops, and feature flags in production systems. In PySpark, filter conditions like df.filter(col("salary") > 50000) are built entirely on boolean logic underneath.

Remember This
  • Boolean = only True or False, nothing else
  • Comparisons (>, <, ==, !=) always produce a boolean result
  • Capital T and capital F matter: True, not true
05

List — An Ordered, Changeable Collection

You need to store the names of 5 students in a class, and later you might need to add a new student, remove one, or check the order they joined in.

Simple Answer: A list is an ordered collection of values, written with square brackets [ ]. Order is remembered, duplicate values are allowed, and you CAN change it after creating it (add, remove, update items) — this is what "mutable" means.

lists.py
students = ["Sai", "Ravi", "Anu"]

students.append("Priya")   # add a new student
students.remove("Ravi")     # remove a student

print(students)          # ['Sai', 'Anu', 'Priya']
print(students[0])       # Sai (first item, index 0)
Where You'll Use This in Your Career

Lists are how you'll hold rows of data before loading them into a database, store results from an API call, or collect items during a loop. In data engineering, when you read a CSV with core Python (before even touching Pandas/PySpark), you're often working with a list of dictionaries.

Remember This
  • List = [ ], ordered, allows duplicates, MUTABLE (changeable)
  • Indexing starts at 0, just like strings
  • Common uses: append(), remove(), sort(), looping with for
06

Tuple — An Ordered, UNCHANGEABLE Collection

You're storing a fixed GPS coordinate (latitude, longitude) for a store location. This pair should NEVER accidentally get modified somewhere else in a large codebase — that would corrupt your data.

Simple Answer: A tuple looks like a list, but uses round brackets ( ) and CANNOT be changed after creation — it's "immutable." Use a tuple whenever the data should stay fixed and protected from accidental changes.

tuples.py
store_location = (17.385, 78.4867)   # latitude, longitude

print(store_location[0])   # 17.385

# store_location[0] = 20.0   -> this would raise an ERROR, tuples can't be changed
Where You'll Use This in Your Career

Tuples are used for fixed, protected data — function return values that shouldn't be altered, dictionary keys (which must be immutable), and configuration values you want to guarantee never change accidentally in a large codebase.

Remember This
  • Tuple = ( ), ordered, allows duplicates, IMMUTABLE (cannot be changed)
  • Use it when the data should NEVER be accidentally modified
  • Memory trick: "List can change, Tuple can't — Tuple is Tough."
07

Dictionary (dict) — Key-Value Pairs

You need to store a student's details — name, age, department — but looking them up by POSITION ("the 3rd item") is confusing and error-prone. You want to look them up by NAME instead, like "give me the age."

Simple Answer: A dictionary stores data as key-value pairs, written with curly brackets { }. Instead of a numeric position, you look up values using a meaningful KEY — much closer to how real-world data (like a JSON API response) is naturally structured.

dictionaries.py
student = {
    "name": "Sai",
    "age": 21,
    "department": "Data Engineering"
}

print(student["name"])   # Sai
student["age"] = 22       # update a value using its key
Where You'll Use This in Your Career

Dictionaries are EXTREMELY common in real work — every JSON API response, every row read from MongoDB, every config file (like your database connection settings) naturally maps to a Python dictionary. If you understand dicts well, working with APIs and NoSQL databases feels immediately familiar.

Remember This
  • Dictionary = { }, key-value pairs, look up by KEY not position
  • Keys must be unique — using the same key twice overwrites the earlier value
  • This is basically what JSON looks like when loaded into Python
08

Set — Unique Values, No Duplicates

You have a list of 10,000 customer emails, but many are accidentally repeated. You just want the list of UNIQUE emails, with no duplicates at all.

Simple Answer: A set automatically removes duplicates and stores only unique values, written with curly brackets { } (like a dict, but without key-value pairs). Order is NOT guaranteed — sets care about uniqueness, not sequence.

sets.py
emails = ["a@x.com", "b@x.com", "a@x.com", "c@x.com"]

unique_emails = set(emails)

print(unique_emails)   # {'a@x.com', 'b@x.com', 'c@x.com'}  (order may vary)
Where You'll Use This in Your Career

Sets are a quick, efficient way to de-duplicate data during cleaning steps, and to quickly check "does this value exist?" — checking membership in a set is much faster than checking membership in a list on large data. You'll use this exact pattern often during data cleaning before loading data into a database.

Remember This
  • Set = { }, unique values only, no guaranteed order
  • Fast way to remove duplicates from a list: set(my_list)
  • Don't confuse an empty {} with a set — that actually creates an empty dictionary
09

NoneType — Representing "Nothing" On Purpose

A user hasn't entered their middle name yet. Should that field be an empty string "", the number 0, or something else entirely? None of those really mean "this doesn't exist yet."

Simple Answer: None is Python's way of saying "there is intentionally no value here" — different from an empty string or zero, which ARE actual values. It's Python's version of NULL, which you already know from SQL.

none_type.py
middle_name = None

if middle_name is None:
    print("No middle name provided")
Where You'll Use This in Your Career

This connects directly to what you already learned about NULL values in SQL — None is Python's equivalent. You'll constantly check for None when handling missing data, optional function arguments, and API responses where a field might genuinely be absent.

Remember This
  • None = intentionally "no value," not the same as 0, "", or False
  • Always check with is None, not == None
  • Python's None ≈ SQL's NULL
10

Type Conversion — Switching Between Types

A user types their age into a web form. Every value from a web form arrives as TEXT (a string) — even though "25" looks like a number, Python still sees it as text until you explicitly convert it.

Simple Answer: Type conversion (also called "casting") means deliberately switching a value from one type to another using functions like int(), float(), or str().

type_conversion.py
age_text = "25"          # this is a STRING, not a number
age_number = int(age_text)  # now it's an actual int

print(age_number + 5)   # 30 (works now, would fail on the string version)
print(str(100))       # "100" - number converted back to text
Where You'll Use This in Your Career

This is one of the most common real bugs in data engineering: a CSV column that LOOKS numeric actually gets read as text, and every calculation silently fails or behaves unexpectedly until you explicitly convert it. Recognizing "this data is the wrong type" is often the very first debugging step in a broken pipeline.

Remember This
  • int(), float(), str(), bool() convert between types
  • Data from files, forms, and APIs often arrives as text, even if it "looks" numeric
  • When in doubt, use type() to confirm before you assume
11

Quick Reference — All Data Types at a Glance

Use this table to quickly recall every type covered today, side by side — great for a last-minute review before a quiz or interview.

Data Type Syntax Mutable? Example Common Real-World Use
int 25 age = 25 Counts, IDs, ages, quantities
float 87.5 score = 87.5 Prices, averages, measurements
complex 3+4j z = 3 + 4j Scientific/engineering calculations
str "text" No name = "Sai" Names, messages, cleaning text data
bool True / False is_adult = True Conditions, validation, filters
list [ ] Yes names = ["Sai","Anu"] Collections you'll add/remove from
tuple ( ) No loc = (17.3, 78.4) Fixed values that must stay protected
dict { key: value } Yes {"name":"Sai"} JSON/API data, config, records
set { } (no keys) Yes {"a","b","c"} Removing duplicates, fast lookups
NoneType None middle_name = None Representing intentionally missing data
Remember This
  • Numbers (int, float, complex) and Booleans → always immutable by nature
  • Text (str) and Tuples → immutable, protect data from accidental changes
  • List, Dict, Set → mutable, meant to be updated as your program runs
  • When unsure which type you're holding, always run type(value) to check
12

List vs Tuple vs Set vs Dictionary — Feature Comparison

A fresher in an interview is asked: "You need to store student names — would you use a list, tuple, set, or dictionary?" Without understanding the FEATURE differences between these four, it's just a guess. With them, the right choice becomes obvious based on what the data actually needs.

All four are Python's main ways to hold MULTIPLE values together — the difference is entirely in HOW they behave: do they remember order, can they change, do they allow duplicates, and how do you look values up?

Feature List Tuple Set Dictionary
Syntax [ ] ( ) { } {key: value}
Ordered? Yes Yes No Yes (insertion order)
Mutable? (changeable) Yes No Yes Yes
Allows Duplicate Values? Yes Yes No Keys: No · Values: Yes
How You Access Items By position: list[0] By position: tup[0] No indexing — check membership only By key: dict["name"]
Typical Use Case A changing collection of items Fixed, protected values Removing duplicates, fast lookups Labeled data (like a JSON record)
Why You're Learning This

This exact comparison ("list vs tuple vs set vs dict") is one of the most frequently asked Python fresher interview questions — because it tests whether you understand WHY each type exists, not just their syntax. Answering with the right feature (mutability, order, uniqueness) instead of a memorized definition instantly signals real understanding.

Remember This (mind map)
  • Need order + changeable + duplicates OK → List
  • Need order + must stay fixed/protected → Tuple
  • Need only unique values, order doesn't matter → Set
  • Need to label each value with a meaningful name → Dictionary
Big Picture Takeaway

Every value in Python has a type, and that type decides what you're allowed to do with it. Numbers (int/float) for math, strings for text, booleans for decisions, lists/tuples for ordered collections (changeable vs fixed), dictionaries for labeled data, sets for uniqueness, and None for intentionally missing values. Getting comfortable recognizing and converting between these types is the single most useful debugging skill you'll build in your first months of writing real code.

June-08-2026:Morning 9:00AM - 10:00AM
June-08-2026:Morning 9:00AM - 10:00AM
0% done
5
6. AWS Core
1 videos