Python Variables and Data Types
Variables store data values. Python supports multiple data types such as integers, strings, lists, and dictionaries.
Creating Variables
You can create variables simply by assigning values to them:
name = "Alice"
age = 25
is_student = True
Data Types
Python has various built-in data types, including:
- int: Integer (e.g., 5, -3)
- float: Decimal number (e.g., 3.14)
- str: String (e.g., "Hello, World!")
- bool: Boolean (e.g., True, False)
- list: Ordered collection (e.g., [1, 2, 3])
- dict: Dictionary (e.g., {'key': 'value'})
Activity
Try It Yourself!
Create variables for your favorite color, number, and whether you are a student, and print them out.
Quick Quiz
Quick Quiz
- What is a variable in Python?
- What are the basic data types in Python?
Answers: A variable stores a value. The basic data types are int, float, str, bool, list, and dict.