← Lesson
BitWithBite
Python · Quick Reference

Lesson 2 — Variables & Data Types Cheat Sheet

Python
In one line: A variable is a named container that stores a value in your computer's memory. You give it a name, assign a value with =, and from that point on you can use that name anywhere i...

Key Ideas

1What is a Variable?. A variable is a named container that stores a value in your computer's memory. You give it a name, assign a value with =, and from that point on you can use that name ...
2Naming Rules & Best Practices. Variable names must follow specific rules, and following good conventions makes your code professional and readable.
3Python's Core Data Types. Every value in Python has a type. The five most important types you'll use every day are:
4Checking Types with type(). Python's built-in type() function tells you exactly what type a variable or value is. This is incredibly useful for debugging — especially when a program isn't behavin...
5Type Conversion (Casting). Sometimes you need to convert a value from one type to another. For example, user input is always a string — if you want to do maths with it, you must convert it to in...

Code Examples

# Creating variables — just use = (no keyword needed!) name = "Aisha" # stores a text value age = 17 # stores a whole number gpa = 3.85 # stores a decimal number is_enrolled = True # stores True or False # Using variables prin...
# ✅ VALID variable names student_name = "Ali" total_marks = 450 _private = "hidden" score2 = 99 # ❌ INVALID — Python will throw a SyntaxError # 2score = 99 (starts with number) # my-score = 99 (hyphen not allowed) # my score = 99 (space not allo...
# int — whole numbers students = 30 temperature = -5 big_number = 1_000_000 # underscores allowed for readability # float — decimal numbers price = 19.99 pi = 3.14159 scientific = 2.5e6 # scientific notation = 2,500,000.0 # str — text (single or d...