๐ Phase 1: Programming Fundamentals
๐ Topic 1: Python Basics โ Variables & Data Types
Welcome to the Complete Data Science Roadmap! ๐
Over the coming lessons, we'll learn everything you need to become a job-ready Data Scientistโfrom Python and SQL to Machine Learning, Deep Learning, Generative AI, and MLOps.
Today, we're starting with the first and most important topic of the roadmap: Python Basics โ Variables & Data Types.
Python is the most widely used programming language in Data Science because it is easy to learn, highly readable, and supported by powerful libraries such as NumPy, Pandas, Matplotlib, Scikit-learn, TensorFlow, and PyTorch.
Before building machine learning models or analyzing data, you must understand how Python stores and manages data. Every Python program begins with variables and data types, making them the foundation of your Data Science journey.
๐น 1. What is Python?
Python is a high-level, interpreted programming language used for:
โ Data Science
โ Machine Learning
โ Artificial Intelligence
โ Data Analysis
โ Automation
โ Web Development
๐น 2. What is a Variable?
A variable is a named container used to store data in memory.
Think of a variable like a labeled box. You store information inside the box, and whenever you need that information later, you simply use the label (variable name).
For example:
name = "Aman"
age = 25
salary = 175000
Here:
โข "name" stores a string.
โข "age" stores an integer.
โข "salary" stores a numeric value.
๐น 3. Rules for Naming Variables
โ Valid Rules
โข Must begin with a letter or underscore ("_")
โข Can contain letters, numbers, and underscores
โข Variable names are case-sensitive
Examples:
student_name = "Rahul"
marks = 90
age2 = 24
โ Invalid Examples
2name = "Rahul"
student name = "Rahul"
class = 10
Why?
โข Cannot start with a number
โข Spaces are not allowed
โข "class" is a reserved Python keyword
๐น 4. What are Data Types?
A data type tells Python what kind of value a variable stores.
Python automatically detects the data type when you assign a value.
Data Types in Python:
int: Whole numbers Example: 25
float : Decimal numbers Example: 99.99
str: Text
Example: "Python"
bool: True or False
complex: Complex numbers
Example: 3+4j
๐น 5. Integer (int)
Stores whole numbers.
age = 25
print(age)
print(type(age))
Output:
25
<class 'int'>
๐น 6. Float (float)
Stores decimal numbers.
price = 199.99
print(price)
print(type(price))
Output:
199.99
<class 'float'>
๐น 7. String (str)
Stores text.
name = "Suresh"
print(name)
print(type(name))
Output:
Deepak
<class 'str'>
Strings can be written using either single (' ') or double (" ") quotes.
๐น 8. Boolean (bool)
Boolean values are used for decision-making.
They can store only two values: True or False
is_student = True
print(type(is_student))
Output:
<class 'bool'>
๐น 9. Complex Numbers
Python also supports complex numbers.
number = 3 + 4j
print(type(number))
Output:
<class 'complex'>
Although rarely used in Data Science, they are useful in scientific and mathematical computations.
๐น 10. Checking the Data Type
Use the type() function.
salary = 50000
print(type(salary))
Output: