Python · Lesson 2 of 9
Variables & data types
Creating variables, int, float, str, bool and converting between types.
A variable is a name that points to a value. You create one by assigning with = — no keyword needed. Names use snake_case by convention.
int— whole numbers:25float— decimals:4.5str— text:"Kochi"or'Kochi'bool—TrueorFalse(capital letters)None— “no value yet”
type(x) tells you a value's type. Convert with int(), float(), str() — for example int("42") gives the number 42.
Try it yourself
Press Run to see the output.
Edit and press Run (or Ctrl/⌘ + Enter). Python runs in your browser — the first run downloads the Python engine and takes a few seconds.
Key points
- Assign with = ; no declaration keyword.
- True / False / None are capitalised.
- Convert text to numbers with int() or float() before calculations.
Quick check
What does int("7") + 3 give?
int("7") converts the text to the number 7, and 7 + 3 is 10.
Practice task
Create variables for a job title, a monthly salary and the number of openings. Print the yearly salary (monthly × 12).
Interview corner
What is dynamic typing?
In Python a variable has no fixed type — the value does. The same name can point to an int now and a str later. Type errors appear at run time rather than at compile time.
What is the difference between a mutable and an immutable type?
Mutable objects (list, dict, set) can be changed in place. Immutable objects (int, float, str, tuple) cannot — 'changing' them creates a new object.
Further reading
Official documentation, linked for deeper study. These are outside sites; this lesson's text is our own.
Original lesson written by the InfoparkDaily team · © 2026 InfoparkDaily · Free to learn — no paid course or subscription.