Skip to content

Python Programming! Variables and Data Types | Lectures 2

Python Programming A cartoon robot holding three labeled boxes

Lets Start Python Programming For Beginners. Variables and Data Types, Lectures 2

🐍 Variables and Data Types

🎯 Goal

By the end of this lecture, you will:

  • Understand what a variable is.
  • Know how to store different types of data (numbers, words, yes/no).
  • Be able to print and use variables in simple code.

🧠 What is a Variable?

A variable is like a labeled box where you can store information.

πŸ“¦ For example:

  • You can put your name in a box called name.
  • Put your age in a box called age.

In Python, we do this like:

name = "Alice"
age = 10

This means:

  • The word "Alice" is stored in the variable name.
  • The number 10 is stored in the variable age.

πŸ’‘ Naming Rules for Variables

You can name your boxes (variables) almost anything, but follow these rules:

βœ… Good names:

  • name
  • score
  • player_1

🚫 Bad names:

  • 1player ❌ (can’t start with a number)
  • my-name ❌ (no dashes)
  • print ❌ (don’t use special Python words)
Python Programming A cartoon robot holding three labeled boxes
A cartoon robot holding three labeled boxes

πŸ”’ Types of Data

There are three main types of data we’ll use:

TypeExampleDescription
str"Hello"Text (called a string)
int10Whole numbers
float3.14Decimal numbers
boolTrue/FalseYes or No (true or false)

Let’s look at each one!

πŸ“ Strings (str) – Words and Sentences

We use quotes to make strings:

greeting = "Hi there!"
name = "Bob"

To show them on screen:

print(greeting)
print("My name is", name)

πŸ‘‰ Output:

Hi there!
My name is Bob

πŸ§’ Kids Corner: Think of strings like labels on your lunchbox β€” they tell you what’s inside!

βž• Numbers: Integers (int) and Floats (float)
Integers – Whole Numbers
score = 100
lives = 3
Floats – Decimal Numbers
height = 1.5
price = 9.99

Try printing them:

print("Your score is", score)
print("Price:", price)

πŸ‘‰ Output:

Your score is 100
Price: 9.99

βœ… Boolean (bool) – True or False

Booleans are used to say YES or NO:

is_student = True
has_key = False

You can print them too:

print("Are you a student?", is_student)

πŸ‘‰ Output:

Are you a student? True

πŸ” Changing the Value of a Variable

You can change what’s inside the box anytime:

name = "Alice"
print(name)

name = "Emma"
print(name)

πŸ‘‰ Output:

Alice
Emma

πŸ§ͺ Try It Yourself!

Write code that does the following:

  1. Stores your name in a variable called name.
  2. Stores your favorite number in favorite_number.
  3. Prints both out like this:
My name is Alice.
My favorite number is 7.

πŸ’‘ Tip: Use commas to print multiple things.

πŸ§’ Kids Corner

🧠 Imagine your computer is a robot with memory boxes. When you say:

name = "Tom"

It’s like putting a sticky note labeled β€œname” on a box that says β€œTom”.

πŸ€– Robot thinks:
β€œI remember Tom!”

[adrotate banner=”3″]

πŸš€ Challenge (Optional)

Can you write a sentence using all these variables?

animal = "dog"
color = "brown"
number = 3

Example output:

I saw a brown dog today. It was the 3rd one I saw!

πŸ“Œ Summary

  • A variable stores data like a labeled box.
  • Common types: str, int, float, bool.
  • You can change the value of a variable anytime.
  • Use print() to show what’s inside the box.
πŸ”Ή Call Of Action

If this article was helpful to you, please Share and leave your feedback in the comment section below.

Python Programming For Beginners To Advanced

Python Programming For Beginners! Lecture 1

Python Programming! Variables and Data Types | Lectures 2

Python Programming! Input And Output | Lectures 3

Python Programming! Operators in Python Lectures 4

Python Programming! Conditional Statements Lectures 5

Najeeb Alam

Najeeb Alam

Technical writer specializes in developer, Blogging and Online Journalism. I have been working in this field for the last 20 years.

Leave a Reply

Your email address will not be published. Required fields are marked *