Python Data Types Class 11 CBSE Computer Science: Numbers, Boolean, String, List, Tuple, Dictionary and None
Class 11 · Computer Science
Knowledge of Data Types in Python (CBSE Class 11 Computer Science)
Every value stored in a Python program has a specific data type. A data type tells Python what kind of value is being stored and what operations can be performed on it. Choosing the correct data type makes programs efficient, accurate, and easier to understand.
Learning Objectives
- Understand Python Data Types.
- Learn Numeric Data Types.
- Understand Boolean Data Type.
- Learn Sequence Data Types.
- Understand Dictionary.
- Learn None Data Type.
- Differentiate between Mutable and Immutable Data Types.
What is a Data Type?
A Data Type specifies the type of value stored in a variable and determines the operations that can be performed on that value.
Classification of Python Data Types
Python Data Types
│
├── Number
│ ├── Integer
│ ├── Float
│ └── Complex
│
├── Boolean
│
├── Sequence
│ ├── String
│ ├── List
│ └── Tuple
│
├── Mapping
│ └── Dictionary
│
└── None
1. Number Data Type
The Number data type is used to store numeric values. Python supports three numeric types.
Integer (int)
Stores whole numbers without a decimal point.
age = 17
marks = 95
temperature = -5
| Value | Data Type |
|---|---|
| 25 | Integer |
| -100 | Integer |
| 0 | Integer |
Floating Point (float)
Stores numbers containing decimal points.
height = 5.8
price = 249.50
| Value | Data Type |
|---|---|
| 45.5 | Float |
| -12.75 | Float |
Complex Number (complex)
Stores numbers having a real part and an imaginary part.
z = 4 + 5j
print(z)
Output
(4+5j)
Here, j represents the imaginary part.
2. Boolean Data Type
The Boolean data type stores only two values.
- True
- False
passed = True
eligible = False
Boolean values are mainly used in decision-making statements such as if and while.
3. String Data Type
A String is a sequence of characters enclosed in single quotes, double quotes, or triple quotes.
name = "Aman"
city = 'Jaipur'
message = """Welcome to Python"""
Output
Aman
Jaipur
Welcome to Python
4. List Data Type
A List is an ordered collection of elements enclosed in square brackets [].
marks = [85, 90, 92, 88]
print(marks)
Output
[85, 90, 92, 88]
Lists are mutable, which means their elements can be changed after creation.
5. Tuple Data Type
A Tuple is an ordered collection enclosed in parentheses ().
months = ("Jan", "Feb", "Mar")
print(months)
Output
('Jan', 'Feb', 'Mar')
Tuples are immutable, meaning their values cannot be modified after creation.
6. Dictionary Data Type
A Dictionary stores data as key-value pairs enclosed in curly braces {}.
student = {
"Name": "Riya",
"Age": 17,
"Marks": 92
}
print(student)
Output
{'Name': 'Riya', 'Age': 17, 'Marks': 92}
7. None Data Type
The None data type represents the absence of any value.
result = None
print(result)
Output
None
Mutable and Immutable Data Types
Mutable Data Types
A mutable object can be modified after it is created.
- List
- Dictionary
Immutable Data Types
An immutable object cannot be modified after it is created.
- Integer
- Float
- Complex
- Boolean
- String
- Tuple
- None
Comparison of Python Data Types
| Data Type | Example | Mutable |
|---|---|---|
| Integer | 25 | No |
| Float | 25.5 | No |
| Complex | 4+5j | No |
| Boolean | True | No |
| String | "Python" | No |
| List | [1,2,3] | Yes |
| Tuple | (1,2,3) | No |
| Dictionary | {"A":10} | Yes |
| None | None | No |
Checking the Data Type
Python provides the type() function to determine the data type of a value or variable.
x = 25
print(type(x))
y = "Python"
print(type(y))
Output
<class 'int'>
<class 'str'>
Think Like a Programmer
Predict the data type of each variable.
a = 100
b = 45.6
c = "CBSE"
d = True
e = [10,20]
f = (5,6)
g = {"Name":"Aman"}
h = None
| Variable | Data Type |
|---|---|
| a | Integer |
| b | Float |
| c | String |
| d | Boolean |
| e | List |
| f | Tuple |
| g | Dictionary |
| h | NoneType |
Real-Life Example
Imagine a student admission form.
- Name → String
- Age → Integer
- Percentage → Float
- Sports Quota → Boolean
- Subjects → List
- Date of Birth (fixed values) → Tuple (conceptually fixed)
- Student Details → Dictionary
Common Beginner Mistakes
- Using square brackets instead of parentheses for tuples.
- Thinking strings are mutable.
- Confusing lists with dictionaries.
- Writing
trueinstead ofTrue. - Using
noneinstead ofNone. - Forgetting that dictionary keys should be unique.
Memory Trick
- [ ] → List → Mutable
- ( ) → Tuple → Immutable
- { } → Dictionary → Key-Value Pairs
- " " → String
- True / False → Boolean
- None → No Value
Exam Tips
- Remember which data types are mutable and immutable.
- Practice identifying data types using
type(). - Know the difference between List, Tuple, and Dictionary.
- Remember that
True,False, andNonestart with capital letters. - Learn the symbols used for each collection data type.
Practice Yourself
- Write one example of each Python data type.
- Differentiate between List and Tuple.
- Differentiate between Mutable and Immutable data types.
- Write a Python program to display the data type of five variables using
type(). - Create a dictionary to store your personal details.
Frequently Asked Questions (FAQs)
1. What is a data type?
A data type specifies the type of value stored in a variable.
2. Which Python data types are mutable?
List and Dictionary are mutable.
3. Which function is used to check the data type of a variable?
The type() function.
4. Can a string be modified after creation?
No. Strings are immutable.
5. What does None represent?
It represents the absence of a value.
Summary
- Python supports Number, Boolean, String, List, Tuple, Dictionary, and None data types.
- Lists and Dictionaries are mutable, whereas Strings, Tuples, Numbers, Boolean, and None are immutable.
- The
type()function is used to determine the data type of a variable. - Choosing the correct data type improves program efficiency and readability.
- Understanding data types is essential before learning operators, expressions, and control statements.