Variables and basic data types

Store information in variables and recognize common Python value types.

A variable is a name that refers to a value. Common beginner types include str for text, int for whole numbers, float for decimal numbers, and bool for True or False. Python infers a value's type when you assign it.

Assign and display values

python · static example

name = "Asha"
age = 19
is_student = True
print(name, age, is_student)
print(type(age).__name__)

Variable names are case-sensitive. `type()` can help inspect a value while learning.

Sample output
Asha 19 True
int

Labeled sample only — nothing was run on this page.

Case study

Scenario

A campus event form collects a student's name, semester number, and whether they need accessibility support.

Task

Choose a suitable Python type for each value and explain why.

Explanation / example

The name is text (`str`), semester is a whole number (`int`), and the support answer can be a Boolean (`bool`). Real forms also need input validation.

Knowledge check

What is the type of `3.5`?

Pick an answer to check.