Class 7 · CBSE AI · Strand B — Python for AI

Python variables and types explained for Class 7

A variable is a named container for a value. How Python figures out the type for you. A beginner guide for Class 7.

What this concept actually says

  • A variable is a named container that stores a value for later use
  • Python has four basic types: int, float, str, and bool — and the type matters for what operations make sense
  • Type errors are one of the most common beginner mistakes and are caused by mixing incompatible types

An analogy your child will recognise

Tiffin box with a name label

A variable is like a tiffin box with your name written on it. The name tells you whose box it is and what to expect inside. The type is like knowing whether the box holds rice, liquid curry, or a dry snack — you handle each differently.

Cricket scoreboard

A cricket scoreboard tracks runs (int), strike rate (float), player name (str), and whether they are out or not (bool). Each slot on the board holds a specific kind of information, and you cannot put a player's name where the run count goes.

Common misconceptions to watch for

  • A variable's value cannot change — in reality, variables can be reassigned at any point, which is why they are called 'variables'
  • Putting a number in quotes makes it a number — in reality, '95' is text and cannot be used in arithmetic without conversion

Key facts in one breath

  • Python is dynamically typed — you do not declare the type; Python infers it from the value you assign
  • The type() function tells you what type a variable currently holds
  • In Python, a single = assigns a value; a double == checks if two values are equal
  • Variable names must start with a letter or underscore and cannot contain spaces

How Dhee Learning teaches this — the 3-stage question loop

Every Dhee Learning session for this concept follows three stages. We share the questions Dhee actually asks, so you can hear what a session sounds like.

Stage 1 — Surface

If I write score = 95 in Python, what do you think is happening? What is 'score', and what is '95'?

Rote answer

"score is a variable and 95 is its value"

Understood

"score is a name we give to a box in the computer's memory so we can refer to that value later without writing 95 every time — and we can also change it"

Stage 2 — Reasoning

Why does Python care whether a value is an integer, a decimal, or text? What could go wrong if it did not?

Follow-up Dhee may use: What do you think Python does if you try to add a number to a piece of text? Guess before you try it.

Stage 3 — Application

You are building a student record. Create variables for a student's name, age, percentage score, and whether they passed. What type should each one be, and why?

Misconception Dhee watches for: Using strings for everything (e.g. age = '13') because it looks fine on screen but breaks any arithmetic or comparison operation

Related concepts

Want your child to actually understand this?

Dhee turns this concept into a 15-minute spoken session — asking, listening, and probing — so your child builds the idea themselves.

Frequently asked questions

What is variables and types — explained for kids? +

A variable is a named container for a value. How Python figures out the type for you. A beginner guide for Class 7.

What's the most common mistake children make about this concept? +

A variable's value cannot change — in reality, variables can be reassigned at any point, which is why they are called 'variables'

How does Dhee Learning teach this in a Class 7 session? +

Dhee opens with a question — for example: "If I write score = 95 in Python, what do you think is happening? What is 'score', and what is '95'?" — listens to your child's answer, then probes the reasoning behind it. The session ends when the child can apply the idea to a brand-new situation, not just recall it.