0% found this document useful (0 votes)
4 views2 pages

Python Data Types Explained

Python features various built-in data types, including numeric (int, float, complex), sequence (str, list, tuple, range), set (set, frozenset), mapping (dict), boolean (bool), and binary types (bytes, bytearray, memoryview). It is dynamically typed, meaning data types are determined at runtime. Understanding these data types is crucial for effective programming in Python.

Uploaded by

valiswaran1
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Python Data Types Explained

Python features various built-in data types, including numeric (int, float, complex), sequence (str, list, tuple, range), set (set, frozenset), mapping (dict), boolean (bool), and binary types (bytes, bytearray, memoryview). It is dynamically typed, meaning data types are determined at runtime. Understanding these data types is crucial for effective programming in Python.

Uploaded by

valiswaran1
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DATA TYPES IN PYTHON – 10 MARKS (WITH DEFINITIONS)

Data types in Python define the type of value a variable can hold and the operations that can be
performed on that value. Python is dynamically typed, meaning the data type is decided automatically
when a value is assigned. Python provides various built■in data types, grouped into several categories.
1. Numeric Data Types
(a) int (Integer)
Definition: Represents whole numbers without decimal points. Integers can be positive, negative, or
zero.
Example: x = 10
(b) float (Floating Point)
Definition: Represents real numbers with decimal points. Used for measurement and continuous
values.
Example: y = 3.14
(c) complex
Definition: Represents complex numbers with a real and imaginary part.
Example: z = 2 + 5j
2. Sequence Data Types
(a) str (String)
Definition: A sequence of characters enclosed in quotes. Strings are immutable.
Example: name = "Python"
(b) list
Definition: An ordered, mutable collection of items. Allows duplicates and mixed types.
Example: numbers = [1, 2, 3, "hello"]
(c) tuple
Definition: An ordered, immutable collection. Faster and memory■efficient.
Example: point = (10, 20)
(d) range
Definition: Represents a sequence of numbers, mainly used in loops.
Example: r = range(0, 10)
3. Set Data Types
(a) set
Definition: Unordered collection of unique items.
Example: s = {1, 2, 3}
(b) frozenset
Definition: Immutable version of a set.
Example: fs = frozenset([1, 2, 3])
4. Mapping Data Type
dict (Dictionary)
Definition: Stores data as key–value pairs. Mutable and unordered.
Example: student = {"name": "Arun", "age": 20}
5. Boolean Data Type
bool
Definition: Represents logical values: True or False.
Example: is_valid = True
6. Binary Data Types
(a) bytes
Definition: Immutable sequence of bytes.
(b) bytearray
Definition: Mutable sequence of bytes.
(c) memoryview
Definition: Accesses memory of other binary objects without copying.
Conclusion
Python provides built■in data types such as numeric, sequence, mapping, set, boolean, and binary
types. Understanding these types is essential for writing efficient programs.

You might also like