Variables and Data Types
Learn how to create variables and work with Python's diverse data types.
Variables and Data Types is a free Learn AI with Python lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Learn AI with Python learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
1
Introduction to Variables and Data Types
Variables are used to store information, and data types define the kind of information stored in a variable.
In this lesson, you will learn how to use variables and explore the most common data types in Python.

2
What are Variables?
Variables are containers that store data in your program. You can think of them as labeled boxes that hold information.
For example:
name = "Alice"
Here, name is a variable, and it stores the value "Alice".
# Defining a variable
name = "Alice"
print(name)3
Data Types in Python
Every variable in Python has a data type. Here are some common ones:
- Integer (
int): Whole numbers (e.g.,42). - Float (
float): Decimal numbers (e.g.,3.14). - String (
str): Text (e.g.,"Hello"). - Boolean (
bool): True or False values.
4
Assigning Different Data Types
In Python, you can assign values of different data types to variables:
# Assigning different data types
age = 25
pi = 3.14
greeting = "Hi"
is_happy = True
print(age, pi, greeting, is_happy)5
Type Checking
You can check the type of a variable using the type() function:
# Checking data types
x = 42
y = 3.14
z = "Hello"
print(type(x), type(y), type(z))6
Dynamic Typing in Python
Python is a dynamically typed language. This means you don’t need to specify the type of a variable. Python determines it automatically based on the value assigned:
# Dynamic typing example
num = 42
print(num)
num = "Now I am a string!"
print(num)7
Converting Data Types
You can convert data types in Python using functions like int(), float(), str(), etc.:
# Converting data types
x = "123"
y = int(x)
print(y, type(y))8
9
What Did We Learn?
In this lesson, you learned:
- What variables are and how to use them in Python.
- Common data types in Python: integers, floats, strings, and booleans.
- How to check and convert data types.
Great job! Let’s move on to the next topic.

Frequently asked questions
Is the “Variables and Data Types” lesson free?
Yes — the full text of “Variables and Data Types” is free to read here on the web, and the Learn AI with Python course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Learn AI with Python course, upgrade to CoddyKit PRO.
What will I learn in “Variables and Data Types”?
Learn how to create variables and work with Python's diverse data types. You practise Learn AI with Python with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Learn AI with Python?
No prior experience is required. Learn AI with Python on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Variables and Data Types” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Learn AI with Python lesson?
Yes. Every Learn AI with Python lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Variables and Data Types
- Input and Output
- Basic Arithmetic and Operators
- Comments and Code Readability