Variables and Data Types in Python
📘 Python
👁 67 views
📅 Nov 05, 2025
⏱ Estimated reading time: 1 min
Variables and Data Types in Python
Variables in Python are used to store data. Python automatically detects the data type when a variable is assigned.
1. Variable Rules
-
Must start with a letter or underscore.
-
Can contain letters, digits, and underscores.
-
Cannot be a Python keyword.
-
Python is case-sensitive (
ageandAgeare different).
2. Basic Data Types
| Data Type | Description | Example |
|---|---|---|
int | Integer numbers | x = 10 |
float | Decimal numbers | y = 3.14 |
str | String (text) | name = "Python" |
bool | Boolean values | is_valid = True |
complex | Complex numbers | z = 2 + 3j |
3. Type Conversion (Casting)
4. Multiple Assignment
-
Assign values to multiple variables in one line:
5. Checking Data Type
-
Use
type()function to check the data type:
6. Constants
-
By convention, constants are uppercase:
7. Key Points
-
Variables store data values for later use.
-
Python infers the data type automatically.
-
Basic data types include int, float, str, bool, and complex.
-
Multiple variables can be assigned in one line.
-
Use
type()to check the data type.
🔒 Some advanced sections are available for Registered Members
Register Now
Register Now
Share this Post
← Back to Tutorials