Python Basics
Variables & Data Types
Foundation concepts of Python programming — learn how to store and work with data effectively.
Python 3
✓ Beginner Friendly
2 Topics
01
Variables in Python
A variable is a name used to store data in memory. Python is dynamically typed and case-sensitive: age, Age, and AGE are three different variables.
Python — Variables
# Creating variables — just assign a value x = 10 name = "Alice" is_student = True # Case sensitivity demo age = 20 Age = 30 print(age) # 20 print(Age) # 30 # Updating a variable count = 1 count = 2 # value updated
Naming Rules
✓ Valid Names
total_marksstudent_name_countvalue2
✗ Invalid Names
2marks— starts with numbertotal-marks— contains hyphenfor— Python keyword
02
Data Types in Python
| Type | Keyword | Example | Used For |
|---|---|---|---|
| Integer | int | age = 25 | Counting, indexing, loops |
| Float | float | pi = 3.14 | Measurements, prices |
| String | str | name = "Alice" | Text, names, messages |
| Boolean | bool | flag = True | Conditions, loops |
| None | NoneType | result = None | No value / empty state |
| Complex | complex | z = 3 + 4j | Scientific calculations |
Type Conversion Rules: Allowed:
int→float, int→complex, float→complex, int→str. NOT allowed: complex→int or complex→float directly (use int(z.real) instead).✓
Quick Quiz
1. Which of these is mutable in Python?
2. What does type(3.14) return?
3. Which value is falsy?
4. Valid f-string syntax?
5. What is None's type?