Python Data Types
1. What is a Data Type?
A data type tells Python what kind of value a variable is storing.
Example:
-
Number
-
Text
-
True or False
Python understands data types automatically.
2. Common Data Types in Python
Python has many data types, but beginners should first learn these:
-
Integer (int)
-
Float (float)
-
String (str)
-
Boolean (bool)
3. Integer (int)
An integer is a whole number.
It can be positive, negative, or zero.
Examples
4. Float (float)
A float is a number with decimal point.
Examples
5. String (str)
A string is text.
It is written inside quotes (" " or ' ').
Examples
Joining Strings
Length of a String
6. Boolean (bool)
A boolean has only two values:
-
True -
False
Used for decisions.
Examples
7. Checking Data Type (type())
You can check the data type of a variable.
Example
8. Type Conversion (Type Casting)
Sometimes we need to change one data type to another.
String to Integer
Integer to Float
Number to String
9. Input and Data Types
Input from user is always string.
Example
Convert it:
10. Simple Practice Examples
Example 1: Add Two Numbers
Example 2: Print User Details
11. Common Beginner Mistakes
❌ Mixing Text and Number
✔ Correct:
❌ Forgetting Conversion
✔ Correct:
12. Summary (Python Data Types)
✔ Data types tell value type
✔ Common types: int, float, str, bool
✔ Python detects type automatically
✔ type() checks data type
✔ Conversion is important
📘 Perfect for Beginner eBook
This chapter is ideal for:
-
Python beginner books
-
School & college students
-
Self-learners
If you want next, I can write:
-
Python Numbers (deep)
-
Python Strings (easy)
-
Boolean & Conditions
-
Data Type Exercises
-
MCQs with answers
Just tell me 😊
