Introduction
Welcome to your first lesson on the path to becoming an expert in AI. Your goal of building transformative technology, much like the 'Tony Stark' archetype you admire, begins with mastering the fundamental language of computation. We will start with Python, a powerful and widely-used language in the world of artificial intelligence.
This course is designed to take you from a complete beginner to someone who can confidently build AI models. In this inaugural lesson, you will learn the most basic and essential concept in programming: variables and data types. Think of these as the nouns of a programming language—they are how we label and store information.
By the end of this 60-minute lesson, you will be able to:
- Assign values to variables.
- Identify and use Python's four fundamental data types: integers (
int), floating-point numbers (float), strings (str), and booleans (bool).
This knowledge is the first building block. All the complex AI systems you aim to create are, at their core, built upon manipulating data stored in variables.
What are Variables?
In programming, a variable is a name you give to a storage location in the computer's memory. This allows you to store a piece of data, refer to it, and manipulate it throughout your program using a descriptive name.
The primary way to create a variable in Python is through assignment, using the equals sign (=). The syntax is simple:
variable_name = value
To get a clear and practical introduction to this concept, let's start with a short video.
Python Variables - Python Tutorial for Beginners with Examples | Mosh
Watch this segment from the video 'Python Variables' by Programming with Mosh. It provides an excellent explanation of what variables are and how we use them to store different kinds of data.
Watch the video from the beginning until the timestamp 02:58. Focus on how a variable is defined as a 'label' for a memory location and pay attention to the four types of data introduced: integers, floats, booleans, and strings.
As you saw in the video, we can store different types of information in variables. Let's formalize these core data types.
The Four Fundamental Data Types
Every value in Python has a data type. While there are many, we will start with the four most basic and common ones. Understanding these is non-negotiable for writing any program.
-
Integer (
int): Represents whole numbers, both positive and negative, without any decimal points.- Examples:
42,-150,0
- Examples:
-
Float (
float): Represents numbers with a decimal point, or floating-point numbers. These are used for values that require precision.- Examples:
3.14159,-0.001,2.0
- Examples:
-
String (
str): Represents a sequence of characters, or text. In Python, strings are enclosed in either single quotes ('...') or double quotes ("...").- Examples:
"Hello, world",'Python',"123"(Note: this is text, not a number)
- Examples:
-
Boolean (
bool): Represents one of two logical values:TrueorFalse. These are crucial for decision-making in code. Note that the first letter is always capitalized.- Examples:
True,False
- Examples:
This image provides a helpful visual summary of these data types.

To reinforce these concepts with more examples, let's watch another video. Seeing the same ideas presented differently can often deepen understanding.
Python variables for beginners ❎
This video from Bro Code, 'Python variables for beginners ❎', offers another great walkthrough of variables and the four basic data types. It uses different examples which will help solidify your understanding.
Watch the video from 03:55 to 11:22. This covers integers, floats, strings, and booleans with practical examples for each.
Python's Approach: Dynamic Typing and Object References
You may have noticed that you don't have to tell Python the type of data a variable will hold. This is because Python is a dynamically typed language. It automatically figures out the data type at the moment you assign a value.
A deeper, more theoretical point that fits your theory-first preference is how Python handles this internally. In Python, variables don't contain the values directly. Instead, they hold a reference—like a pointer or a memory address—to an object that contains the actual data.
When you write age = 21, Python does the following:
- Creates an integer object with the value
21. - Creates a variable named
age. - Makes
agerefer to, or point at, that integer object in memory.
This is why you can reassign a variable to a completely different type of data later on.
x = 10 # x refers to an integer object
print(type(x)) # Output: <class 'int'>
x = "hello" # Now, x refers to a string object
print(type(x)) # Output: <class 'str'>
The function type() is a built-in Python tool that tells you the data type of the object a variable is currently referencing.
To explore this crucial theoretical concept further, please read the following sections from a comprehensive article on Real Python.
Variables in Python: Usage and Best Practices
This article, 'Variables in Python: Usage and Best Practices,' provides a detailed explanation of how variables work. We'll focus on the sections that cover variable creation, Python's dynamic typing, and the core concept of variables as references.
Read the sections 'Creating Variables With Assignments,' 'Setting and Changing a Variable’s Data Type,' and 'Variables Hold References to Objects.' These sections will give you a solid theoretical foundation for what's happening 'under the hood.'
Your Turn: Creating Variables in Python
Now it's time to apply what you've learned. An essential part of becoming a proficient programmer is writing clean, readable code from the very beginning. A key aspect of this is choosing good variable names.
Watch this final video clip, which covers best practices for naming your variables.
Python Variables - Python Tutorial for Beginners with Examples | Mosh
Let's return to the Programming with Mosh video to learn about variable naming conventions. Following these rules will make your code professional and easy for others (and your future self) to read.
Watch from 03:15 to 05:58. Pay close attention to the four rules for writing clean variable names: descriptive names, lowercase letters, using underscores, and spacing around the = operator.
Hands-On Exercise
Open a Python environment (like a Jupyter Notebook, an online Python interpreter, or an IDE like VS Code). Your task is to create a set of variables that could describe a project, then print their values and types.
- Create a variable named
project_nameand assign it a string value, for example,"JARVIS_AI". - Create a variable named
version_numberand assign it a float value, like1.0. - Create a variable named
build_yearand assign it an integer value, such as2024. - Create a variable named
is_activeand assign it a boolean value,True. - For each variable, use the
print()function to display its value. - After printing the value, use
print(type(...))to display the data type of each variable.
Example Code Structure:
# Your code for project_name
print(project_name)
print(type(project_name))
# Your code for version_number
print(version_number)
print(type(version_number))
# ... and so on for the other two variables
After you run your code, your output should look something like this:
JARVIS_AI
<class 'str'>
1.0
<class 'float'>
2024
<class 'int'>
True
<class 'bool'>
This exercise directly confirms that you can successfully assign values and identify the corresponding data types, achieving our lesson's goal.
Conclusion
In this lesson, you took the first critical step in your programming journey. You learned how to use variables to store and label information, and you became familiar with the four most fundamental data types in Python.
Key Takeaways:
- Variables are names that refer to data stored in memory. You create them using the assignment operator (
=). - Python is dynamically typed, meaning the type of a variable is determined by the value it holds at runtime.
- The four basic data types are:
intfor whole numbers.floatfor numbers with decimals.strfor text.boolforTrueorFalsevalues.
- Writing clean code with descriptive variable names is a professional habit to build from day one.
You now have the tools to represent data. The next logical step is to learn how to operate on that data.
Preview of the Next Lesson:
In the next lesson, we will explore Python operators. You will learn how to perform arithmetic (+, -, *, /) and make comparisons (==, !=, >, <). This will unlock your ability to perform calculations and make logical decisions in your code—a foundational skill for the complex problem-solving required in AI.