0% found this document useful (0 votes)
5 views

Python Unit1 Part 4

The document provides an overview of data types in Python, categorizing them into standard types such as Numeric, Sequence, Boolean, Set, Dictionary, and Binary Types. It explains specific data types like List, Tuple, String, Boolean, Set, and Dictionary, highlighting their characteristics such as mutability and how they are defined and accessed. The document emphasizes that in Python, everything is an object, and data types are classes with variables as their instances.

Uploaded by

de meme
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Python Unit1 Part 4

The document provides an overview of data types in Python, categorizing them into standard types such as Numeric, Sequence, Boolean, Set, Dictionary, and Binary Types. It explains specific data types like List, Tuple, String, Boolean, Set, and Dictionary, highlighting their characteristics such as mutability and how they are defined and accessed. The document emphasizes that in Python, everything is an object, and data types are classes with variables as their instances.

Uploaded by

de meme
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Data Types in

Python
Python Data Types
Data types are the classification or categorization of data items. It
represents the kind of value that tells what operations can be performed on
a particular data. Since everything is an object in Python programming, data
types are actually classes and variables are instances (object) of these
classes. The following are the standard or built-in data types in Python:
• Numeric
• Sequence Type
• Boolean
• Set
• Dictionary
• Binary Types( memoryview, bytearray, bytes)
Since everything is an object in Python programming, data types are
actually classes and variables are instances(object) of these classes.
Python Numeric Data type
In Python, numeric data type is used to hold numeric values.
Integers, floating-point numbers and complex numbers fall under Python numbers
category. They are defined as int, float and complex classes in Python.
• int - holds signed integers of non-limited length.
• float - holds floating decimal points and it's accurate up to 15 decimal places.
• complex - holds complex numbers.
We can use the type() function to know which class a variable or a value belongs to.
Python List Data Type
List is an ordered collection of similar or different types of items
separated by commas and enclosed within brackets [ ].
List is mutable.
Here, we have created a list named languages with 3 string values inside
it.
To access items from a list, we use the index number (0, 1, 2 ...).
Python Tuple Data Type
Tuple is an ordered sequence of items same as a list. The only
difference is that tuples are immutable. Tuples once created cannot be
modified.
In Python, we use the parentheses () to store items of a tuple.
We use the index number to access tuple items in Python .
Python String Data Type
String is a sequence of characters enclosed within either single
or double quotes or triple quotes.
String is immutable.
Python Boolean Data Type
Data type with 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). True and False with capital ‘T’ and ‘F’ are valid
booleans otherwise python will throw an error.
Python Set Data Type
Set is an unordered collection of unique items. Set is defined by values
separated by commas inside braces { }.
Since sets are unordered collections, indexing has no meaning. Hence,
the slicing operator [] does not work.
Set is mutable.
Python Dictionary Data Type
Python dictionary is an ordered collection of items. It stores elements in
key/value pairs. Dictionary is is mutable.
Here, keys are unique identifiers that are associated with each value.
We use keys to retrieve the respective value. But not the other way
around.
Thankyou
Made by Sukanya Rakshit

You might also like