Python Tutorial
Variables and Data Types
Work with numbers, strings, booleans, type conversion and simple expressions.
Concept
A variable is a name bound to a value. Python determines the value type at runtime, so you do not declare a fixed variable type before assignment.
Common built-in types include int, float, str and bool. Conversions such as int(), float() and str() are useful when input and calculations use different representations.
Example
age = 21
price = 499.50
course = "Python"
is_active = True
print(course, age, price, is_active)
print(int("25") + 5)
Type the example yourself and change at least one value. Small experiments reveal syntax and behavior faster than passive reading.
Practice Tasks
- Create variables for student name, age and fee.
- Convert a numeric string to an integer and add 10.
- Use type() to inspect at least four values.
Key Takeaways
- Names can be rebound to new values.
- Built-in data types support different operations.
- Convert input deliberately before calculations.
Previous
← Python Getting Started
← Python Getting Started