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

Python Has Several Built

Python has several built-in data types that classify data, including numeric types (int, float, complex), text type (str), sequence types (list, tuple, range), mapping type (dict), set types (set, frozenset), boolean type (bool), binary types (bytes, bytearray, memoryview), and None type (NoneType). It is dynamically typed, allowing the interpreter to infer variable types based on assigned values, and the type of a variable can be checked using the type() function. These data types define the operations that can be performed on the data and how it is stored in memory.

Uploaded by

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

Python Has Several Built

Python has several built-in data types that classify data, including numeric types (int, float, complex), text type (str), sequence types (list, tuple, range), mapping type (dict), set types (set, frozenset), boolean type (bool), binary types (bytes, bytearray, memoryview), and None type (NoneType). It is dynamically typed, allowing the interpreter to infer variable types based on assigned values, and the type of a variable can be checked using the type() function. These data types define the operations that can be performed on the data and how it is stored in memory.

Uploaded by

sandhyadevit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Python has several built-in data types used to classify data.

These types define what


operations can be performed on the data and how it is stored in memory. Here are some of the
main data types in Python:
Numeric Types:

 int: Represents whole numbers (e.g., 1, 2, 3, -5).


 float: Represents numbers with decimal points (e.g., 1.2, 3.14, -0.5).
 complex: Represents complex numbers with a real and imaginary part (e.g., 2+3j).

Text Type:

 str: Represents a sequence of characters enclosed in quotes (e.g., "hello", 'world').

Sequence Types:

 list:

An ordered, mutable (changeable) collection of items, enclosed in square brackets


(e.g., [1, 2, 3], ['a', 'b', 'c']).

 tuple:

An ordered, immutable (unchangeable) collection of items, enclosed in parentheses


(e.g., (1, 2, 3), ('a', 'b', 'c')).

 range:

Represents an immutable sequence of numbers, often used in loops (e.g., range(5)).

Mapping Type:

 dict: An unordered collection of key-value pairs, enclosed in curly braces (e.g.,


{'name': 'John', 'age': 30}).

Set Types:

 set: An unordered collection of unique items, enclosed in curly braces (e.g., {1, 2,
3}).
 frozenset: An immutable version of a set.


Boolean Type:

 bool: Represents logical values, either True or False.

Binary Types:

 bytes: Represents a sequence of single bytes.


 bytearray: Represents a mutable sequence of bytes.
 memoryview: Allows accessing the internal data of an object without copying.

None Type:

 NoneType: Represents the absence of a value, with its only instance being None.

Python is dynamically typed, meaning that you don't need to declare the data type of a
variable explicitly. The interpreter infers the type based on the value assigned to the variable.
You can check the type of a variable using the type() function.

You might also like