Module 1: Variables & Data Types

Learning to store and categorize information in Python.

💾 Storing Information

Welcome to Module 1! In the real world, and in AI, we constantly deal with information: names, ages, prices, sensor readings, image pixels... Programs need a way to remember and work with this information.

That's where variables come in. They are like labeled containers for storing data. Let's see how they work!

📦 What are Variables?

Think of them as labeled boxes for your data.

📊

Your Data

A piece of information (e.g., the number 42, the text "AI").

➡️
🏷️ =

Assignment (=)

The equals sign assigns the data to a label (variable name).

➡️
🗳️

Labeled Box (Variable)

The data is now stored in a "box" with that label, ready to be used.

Variables let us give meaningful names to data so we can easily reuse it.

🏷️ Common Data Types

Python automatically figures out the *type* of data you store. Here are the basics:

🔢

Integers (int)

Whole numbers, positive or negative, without decimals. Examples: 0, 10, -55.

💧

Floats (float)

Numbers with a decimal point. Examples: 3.14, -0.5, 99.0.

🔡

Strings (str)

Sequences of characters (text), enclosed in quotes (' ' or " "). Examples: 'Hello', "Python AI".

Click on the cards above to reveal more!

⚙️ Variables in Action

Let's assign data to variables and check their types.

robot_name = "Unit 734" # Assigning text (string) accuracy = 0.95 # Assigning a decimal (float) tasks_completed = 15 # Assigning a whole number (int) print(robot_name) # Display the value stored print(type(accuracy)) # Check the data type print(type(tasks_completed)) # Check this one too

Here, we create three variables: `robot_name`, `accuracy`, and `tasks_completed`.

The =The assignment operator stores the value on the right into the variable on the left. sign is used to assign values.

We store different types of data: "Unit 734"This is text data, a 'string' (str). Needs quotes! (a string), 0.95This number has a decimal, making it a 'float'. (a float), and 15This is a whole number, an 'integer' (int). (an integer).

The print()Displays the value of a variable or other data. function shows the stored value. The type()A built-in function to tell you the data type of a variable or value. function tells us what kind of data Python thinks is in the variable (like `` or ``).

🧠 Quick Check!

Module 1 Theory Complete!

Excellent! You've learned how to store data using variables and understand basic data types.
Ready to practice? Head to the Practice Zone or tackle the Advanced Practice for Module 1.