0% found this document useful (0 votes)
7 views11 pages

Python Data Types Overview

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

Python Data Types Overview

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

pyton Data

Types
TYPES
[Link]:
[Link] Type:
[Link] Type:
[Link]:
[Link] Type:
[Link] Types:
- Numeric data types
Python data types represent data that has a numeric value. a numeric valuecan be an
integer,floating no. or even a complex no. these values are defined as int,float and
complex classes.
• integers : value is represented by int class. .it contains positive or negative whole no.
(without fractions or decimals).there is no limit to how long an integer value can be.

• float : value is represented by float class . it is a real no. with a floating-point


representation. it is specified by a decimal point. optionally, character e or E
FOLLOWED BY A POSITIVE OR NEGATIVE integer may be appended to specify
notation.

• complex numbers : it is represented by a complex class. it is specified as (real part)+


(imaginary part). for example - 2+3j
- sequence data types
a sequence is an ordered collection of items , which can be of different data types.
Sequence allow storing of multiple values in an organized and efficient fashion. there are
several data types of python:

• String Data Type: python strings are arrays of bytes representing unicodwe characters.
in python , there is no character data type , a character is a string of length one. it is
represented by str class.

Strings in python can be created using single quotes, double quotes or even triple
quotes. we can access individual characters of a string using index

• list data typr: lists are similar to arrys found in other languages . they are an ordered and
mutable collection of items. it is very flexible as items in a list do not need to be of the
same type .
Lists in python can be created by just placing sequence inside the square brackets[]
• tuple data types: tuple is an ordered collection of python objects. they only difference
between a tuple and a list is that tuples are immutable .Tuples cannot be modifies
after it is created.
in python ,tuples are created by placing a sequence of values separated by a ‘comma’
with or without the use of parentheses for grouping data sequence . tuples can contain
any number of elements and of any datatype (like strings,integers,lists, etc)

- boolean data type


python boolean data type is one of the two built-in values,true or false. boolean objects
that are equal to true are truthy (true) and those equal to false are falsy (false). however
non-boolean objects can be evaluated in a boolean context as well and determined to be
true or false. it is denoted by class bool.

• truthy and falsy values : in python truthy and falsy values are values that evaluate to
true or false in a boolean context . truthy values behave like true , while falsy behave
like false when used in conditions.
- set data type
in python data types , set is an unordered collection of data types that is iterable ,mutable
and has no duplicate elements. the order of elements in a set is undefined though it may
consist of various elements.
• sets can be created by using the built-in-set() function with an iterable object or a
sequence by placing the sequence inside curly braces, separated by a “comma”. the
type of element in a set need not be the same, various mixed - up data type values
can also be passed to the set
• frozenset type :
1. immutable: a frozenset is an immutable data type , meaning its contents cannot be
changed once it is created . you cannot add, remove or modify elements after
initialization.

2 hashable: because frozenset objects are immutable, they are hashable. this allows
them to be used as keys in dictionaries or as elements within other set or
frozenset objects.
- mapping data type
a type which specify where to retrieve data for ypur context definitions . you can map all
context definitions to a source objects. the source objecys can be a standard object, data
model object, context definitions object or any other input data source that you choose.

• dictionary: a dictionary in python is collection of data values, used to store data


values like a map, inlike other python data types, a dictionary holds a key: value pair.
key-value is provided in dictionary to make it more optimized . each key-value pair in a
dictionary is separated by a colon:, whereAS EACH KEY IS SEPARATED BY A ‘COMMA’.

VALUES IN A DICTIONARY CAN BE OF ANY DATATYPE AND CAN BE DUPLICATE , WHEREAS

KEYS CAN’T BE REPEATED AND MUST BE IMMUTABLE. THE DICTIONARY CAN ALSO BE
CREATED
BY THE BUILT-IN FUNCTION DICT(). .
- binary data type
python provides 3 primary binary types for handling raw byte data: bytes, bytearray and
memoryview. these types are essential when working with files, network communication
or any scenario requiring direct manipulation of binary information.

[Link]

• bytes objects are immutable sequence of bytes. this means once a bytes object is
created, its contents cannot be changed.

• they are ideal for representing fixed binary data, such as data read from a file that will
be processed without modification or cryptographic hashes.

• bytes literals are denoted with a b prefix: b “hello”.


2. bytearray
• bytearray objects are mutable sequence of bytes. unlike bytes, their contents can be
modified after creation.

• they are suitable for situations where binary data needs to be manipulated, such as
building up a binary message, modifying image data, or decoding/encoding binary
streams.

• bytearray objects can be created from bytes objects, other bytearray objects or
iterable of integers.

3.
memoryview
memoryview objects provide a zero-copy view into the memory of another object that
supports the buffer protocol (ex: bytes, bytearray, [Link]).
thank
you!!!

You might also like