PROJECT ON
PYTHON'S DATA TYPES
Submitted by:
Debargha Chatterjee
Class XI
Subject: Computer Science
Submitted to:
Mr. Pinaki Datta Gupta
Acknowledgement
I would like to express my sincere gratitude to our respected teacher,
Mr. Pinaki Datta Gupta, for giving me the opportunity to prepare this project on Python’s
Data Types.
This project has helped me to understand the concept of data types in programming and
their importance in solving real-life computational problems.
Index
1. Introduction
2. Groups of Python Data Types
3. Explanation of Each Data Type with Example Code
- Numeric Types
- Sequence Types
- Set Types
- Mapping Type
- Boolean Type
- None Type
4. Conclusion
1. Introduction
In Python, data types represent the kind of value a variable can hold.
They define the operations that can be performed on the data. Python has several built-in
data types which can be grouped into categories.
2. Groups of Python Data Types
- Numeric Types → int, float, complex
- Sequence Types → list, tuple, range, str
- Set Types → set, frozenset
- Mapping Type → dict
- Boolean Type → bool
- None Type → None
3. Explanation of Data Types
Numeric Types
1. int → Stores integers
```python
a = 10
print(type(a)) # <class 'int'>
```
2. float → Stores decimal numbers
```python
b = 3.14
print(type(b)) # <class 'float'>
```
3. complex → Stores complex numbers
```python
c = 2 + 3j
print(type(c)) # <class 'complex'>
```
Sequence Types
1. list → Ordered, mutable collection
```python
fruits = ["apple", "banana", "mango"]
print(fruits[1]) # banana
```
2. tuple → Ordered, immutable collection
```python
point = (2, 4, 6)
print(point[0]) # 2
```
3. range → Sequence of numbers
```python
for i in range(1, 5):
print(i)
#1234
```
4. str → Stores text
```python
name = "Python"
print(name.upper()) # PYTHON
```
Set Types
1. set → Unordered unique elements
```python
s = {1, 2, 3, 2}
print(s) # {1, 2, 3}
```
2. frozenset → Immutable set
```python
fs = frozenset([1, 2, 3])
print(fs) # frozenset({1, 2, 3})
```
Mapping Type
dict → Key-value pairs
```python
student = {"name": "Debargha", "class": 11}
print(student["name"]) # Debargha
```
Boolean Type
bool → True/False values
```python
x=5>3
print(x) # True
```
None Type
None → Absence of value
```python
value = None
print(value) # None
```
4. Conclusion
Python’s data types provide flexibility and power in programming.
Understanding them helps us in writing efficient and error-free code.
Each type has its own purpose, making Python one of the most versatile languages.