SlideShare a Scribd company logo
BASIC DATA TYPES IN PYTHON
PROF. SUNIL D. CHUTE
HEAD DEPT OF COMPUTER SCIENC
M.G. COLLEGE ARMORI
BASIC DATA TYPES IN PYTHON
 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 instance (object) of these
classes.
One way to categorize these basic data types is in
one of four groups:
 Numeric: int, float and the less frequently
encountered complex
 Sequence: str (string), list and tuple
 Boolean: (True or False)
 Dictionary: dict(dictionary) data type, consisting
of (key, value) pairs
NOTE: It's important to point out that Python usually doesn't require you
to specify what data type you are using and will assign a data type to
your variable based on what it thinks you meant.
An equally important thing to point out is that Python is a
"loosely/weakly typed" programming language, meaning that a variable
can change its type over the course of the program's execution, which
isn't the case with "strongly typed" programming languages (such as
Java or C++).
NUMERIC DATA TYPES
These data types are fairly straight-forward and represent
numeric values. These can be decimal values, floating point
values or even complex numbers.
 Integer Data Type - int
The int data type deals with integers values. This means
values like 0, 1, -2 and -15, and not numbers like 0.5, 1.01, -
10.8, etc.
If you give Python the following code, it will conclude that a is
an integer and will assign the int data type to it:
>>> x = 5
>>> type(x)
<class 'int'>
We could have been more specific and said something along these
lines, to make sure Python understood our 5 as an integer, though,
it'll automatically do this exact same thing under the hood:
>>> x = int(5)
>>> type(x)
<class 'int‘>
It's worth noting that Python treats any sequence of numbers (without a
prefix) as a decimal number. This sequence, in fact, isn't constrained.
That is to say, unlike in some other languages like Java, the value of
the int doesn't have a maximum value - it's unbounded.
The sys.maxsize may sound counterintuitive then, since it implies that that's
the maximum value of an integer, though, it isn't.
>>> x = sys.maxsize
>>> x
2147483647
This appears to be a 32-bit signed binary integer value, though, let's see
what happens if we assign a higher number to x:
>>> x = sys.maxsize
>>> x+1
2147483648
In fact, we can even go as far as:
>>> y = sys.maxsize + sys.maxsize
>>> y
4294967294
The only real limit to how big an integer can be is the memory
of the machine you're running Python on.
 Prefixing Integers
What happens when you'd like to pack a numeric value in a
different form? You can prefix a sequence of numbers and tell
Python to treat them in a different system.
More specifically, the prefixes:
 0b or 0B - Will turn your integer into Binary
 0o or 0O - Will turn your integer into Octal
 0x or 0X - Will turn your integer into Hexadecimal
 # Decimal value of 5
>>> x = 5
>>> x
5
 # Binary value of 1
>>> x = 0b001
>>> x
1
 # Octal value of 5
>>> x = 0o5
>>> x
5
 # Hexadecimal value of 10
>>> x = 0x10
>>> x
16
FLOATING POINT DATA TYPE - FLOAT
 The float type in Python designates a floating-point number. float values
are specified with a decimal point. Optionally, the
character e or E followed by a positive or negative integer may be
appended to specify scientific notation
Ex.1 >>> 4.2 4.2
>>> type(4.2)
<class 'float'>
Ex.2 >>> 4.
4.0
Ex.3 >>> .2
0.2
Ex.4>>> .4e7 4000000.0
>>> type(.4e7)
<class 'float'>
Ex.5>>> 4.2e-4
COMPLEX NUMBERS
 Complex numbers are specified as <real
part>+<imaginary part>j.
Ex. >>> 2+3j
(2+3j)
>>> type(2+3j)
<class 'complex'>
STRINGS
 Strings are sequences of character data. The string
type in Python is called str.
 String literals may be delimited using either single or
double quotes. All the characters between the opening
delimiter and matching closing delimiter are part of the
string:
Ex.>>> print("I am a string.")
I am a string.
>>> type("I am a string.")
<class 'str'>
Ex.>>> print('I am too.')
I am too.
>>> type('I am too.')
<class 'str'>
 A string in Python can contain as many characters as you
wish. The only limit is your machine’s memory resources.
A string can also be empty:
Ex. >>> ''
''
 What if you want to include a quote character as part of
the string itself? Your first impulse might be to try
something like this:
Ex.>>> print('This string contains a single quote (')
character.')
SyntaxError: invalid syntax
Ex. >>> mystring = "This is not my first String"
>>> print (mystring);
This is not my first String
 to join two or more strings.
Ex.>>> print ("Hello" + "World");
HelloWorld
Ex. >>> s1 = "Name Python "
>>> s2 = "had been adapted "
>>> s3 = "from Monty Python"
>>> print (s1 + s2 + s3)
Name Python had been adapted from Monty
Python
 use input() function
Ex.>>> n = input("Number of times you
want the text to repeat: ")
Number of times you want the text to
repeat:
>>> print ("Text"*n);
TextTextTextTextText
 Check existence of a character or a sub-
string in a string
Ex.>>> "won" in "India won the match"
True
PYTHON LIST DATA TYPE
 List is an ordered sequence of items. It is one of
the most used datatype in Python and is very
flexible. All the items in a list do not need to be
of the same type.
 Declaring a list is pretty straight forward. Items
separated by commas are enclosed within
brackets [ ].
Ex. a = [1, 2.2, 'python']
We can use the slicing operator [ ] to extract an
item or a range of items from a list. The index
starts from 0 in Python.
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.
 Tuples are used to write-protect data and are
usually faster than lists as they cannot
change dynamically.
 It is defined within parentheses () where
items are separated by commas.
Ex. t = (5,'program', 1+3j)
 We can use the slicing operator [] to extract
items but we cannot change its value.
PYTHON SET DATA TYPE
 Set is an unordered collection of unique
items. Set is defined by values separated by
comma inside braces { }. Items in a set are
not ordered.
 A set is created by placing all the items
(elements) inside curly braces {}, separated
by comma, or by using the built-
in set() function.
 It can have any number of items and they
may be of different types (integer, float, tuple,
string etc.). But a set cannot have mutable
PYTHON DICTIONARY DATA TYPE
 Python dictionary is an unordered collection
of items. Each item of a dictionary has
a key/value pair.
 It is generally used when we have a huge
amount of data. Dictionaries are optimized
for retrieving data. We must know the key to
retrieve the value.
 In Python, dictionaries are defined within
braces {} with each item being a pair in the
form key:value. Key and value can be of any
type.
CONVERSION BETWEEN DATA TYPES
Basic data types in python

More Related Content

What's hot

What's hot (20)

Python ppt
Python pptPython ppt
Python ppt
 
Chapter 16 Dictionaries
Chapter 16 DictionariesChapter 16 Dictionaries
Chapter 16 Dictionaries
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python list
Python listPython list
Python list
 
Unit 4 python -list methods
Unit 4   python -list methodsUnit 4   python -list methods
Unit 4 python -list methods
 
Python for loop
Python for loopPython for loop
Python for loop
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in python
 
Linked list
Linked listLinked list
Linked list
 
Loops in Python
Loops in PythonLoops in Python
Loops in Python
 
Python numbers
Python numbersPython numbers
Python numbers
 
Python dictionary
Python   dictionaryPython   dictionary
Python dictionary
 
What is Range Function? | Range in Python Explained | Edureka
What is Range Function? | Range in Python Explained | EdurekaWhat is Range Function? | Range in Python Explained | Edureka
What is Range Function? | Range in Python Explained | Edureka
 
Lesson 03 python statement, indentation and comments
Lesson 03   python statement, indentation and commentsLesson 03   python statement, indentation and comments
Lesson 03 python statement, indentation and comments
 
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.ppt
 
Python Data-Types
Python Data-TypesPython Data-Types
Python Data-Types
 
Variables & Data Types In Python | Edureka
Variables & Data Types In Python | EdurekaVariables & Data Types In Python | Edureka
Variables & Data Types In Python | Edureka
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| Fundamentals
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
Python Flow Control
Python Flow ControlPython Flow Control
Python Flow Control
 

Similar to Basic data types in python

Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualize
IruolagbePius
 

Similar to Basic data types in python (20)

Python cheat-sheet
Python cheat-sheetPython cheat-sheet
Python cheat-sheet
 
Presentation on python data type
Presentation on python data typePresentation on python data type
Presentation on python data type
 
Python 3.pptx
Python 3.pptxPython 3.pptx
Python 3.pptx
 
python
pythonpython
python
 
Python slide.1
Python slide.1Python slide.1
Python slide.1
 
Python PPT2
Python PPT2Python PPT2
Python PPT2
 
unit 1.docx
unit 1.docxunit 1.docx
unit 1.docx
 
Introduction to Basics of Python
Introduction to Basics of PythonIntroduction to Basics of Python
Introduction to Basics of Python
 
Python basics
Python basicsPython basics
Python basics
 
Python Session - 3
Python Session - 3Python Session - 3
Python Session - 3
 
Python quick guide
Python quick guidePython quick guide
Python quick guide
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3Introduction To Programming with Python-3
Introduction To Programming with Python-3
 
Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualize
 
Improve Your Edge on Machine Learning - Day 1.pptx
Improve Your Edge on Machine Learning - Day 1.pptxImprove Your Edge on Machine Learning - Day 1.pptx
Improve Your Edge on Machine Learning - Day 1.pptx
 
TOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdfTOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdf
 
Python for beginners
Python for beginnersPython for beginners
Python for beginners
 
02python.ppt
02python.ppt02python.ppt
02python.ppt
 
02python.ppt
02python.ppt02python.ppt
02python.ppt
 
Python 3.x quick syntax guide
Python 3.x quick syntax guidePython 3.x quick syntax guide
Python 3.x quick syntax guide
 
GRADE 11 Chapter 5 - Python Fundamentals.pptx
GRADE 11 Chapter 5 - Python Fundamentals.pptxGRADE 11 Chapter 5 - Python Fundamentals.pptx
GRADE 11 Chapter 5 - Python Fundamentals.pptx
 

More from sunilchute1 (10)

Programming construction tools
Programming construction toolsProgramming construction tools
Programming construction tools
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Sorting method data structure
Sorting method data structureSorting method data structure
Sorting method data structure
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Input output statement
Input output statementInput output statement
Input output statement
 
Call by value and call by reference in java
Call by value and call by reference in javaCall by value and call by reference in java
Call by value and call by reference in java
 
Java method
Java methodJava method
Java method
 
Constructors in java
Constructors in javaConstructors in java
Constructors in java
 
C loops
C loopsC loops
C loops
 
Basic of c language
Basic of c languageBasic of c language
Basic of c language
 

Recently uploaded

Recently uploaded (20)

Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptx
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 

Basic data types in python

  • 1. BASIC DATA TYPES IN PYTHON PROF. SUNIL D. CHUTE HEAD DEPT OF COMPUTER SCIENC M.G. COLLEGE ARMORI
  • 2. BASIC DATA TYPES IN PYTHON  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 instance (object) of these classes.
  • 3. One way to categorize these basic data types is in one of four groups:  Numeric: int, float and the less frequently encountered complex  Sequence: str (string), list and tuple  Boolean: (True or False)  Dictionary: dict(dictionary) data type, consisting of (key, value) pairs NOTE: It's important to point out that Python usually doesn't require you to specify what data type you are using and will assign a data type to your variable based on what it thinks you meant. An equally important thing to point out is that Python is a "loosely/weakly typed" programming language, meaning that a variable can change its type over the course of the program's execution, which isn't the case with "strongly typed" programming languages (such as Java or C++).
  • 4.
  • 5. NUMERIC DATA TYPES These data types are fairly straight-forward and represent numeric values. These can be decimal values, floating point values or even complex numbers.  Integer Data Type - int The int data type deals with integers values. This means values like 0, 1, -2 and -15, and not numbers like 0.5, 1.01, - 10.8, etc. If you give Python the following code, it will conclude that a is an integer and will assign the int data type to it: >>> x = 5 >>> type(x) <class 'int'> We could have been more specific and said something along these lines, to make sure Python understood our 5 as an integer, though, it'll automatically do this exact same thing under the hood:
  • 6. >>> x = int(5) >>> type(x) <class 'int‘> It's worth noting that Python treats any sequence of numbers (without a prefix) as a decimal number. This sequence, in fact, isn't constrained. That is to say, unlike in some other languages like Java, the value of the int doesn't have a maximum value - it's unbounded. The sys.maxsize may sound counterintuitive then, since it implies that that's the maximum value of an integer, though, it isn't. >>> x = sys.maxsize >>> x 2147483647 This appears to be a 32-bit signed binary integer value, though, let's see what happens if we assign a higher number to x: >>> x = sys.maxsize >>> x+1 2147483648
  • 7. In fact, we can even go as far as: >>> y = sys.maxsize + sys.maxsize >>> y 4294967294 The only real limit to how big an integer can be is the memory of the machine you're running Python on.  Prefixing Integers What happens when you'd like to pack a numeric value in a different form? You can prefix a sequence of numbers and tell Python to treat them in a different system. More specifically, the prefixes:  0b or 0B - Will turn your integer into Binary  0o or 0O - Will turn your integer into Octal  0x or 0X - Will turn your integer into Hexadecimal
  • 8.  # Decimal value of 5 >>> x = 5 >>> x 5  # Binary value of 1 >>> x = 0b001 >>> x 1  # Octal value of 5 >>> x = 0o5 >>> x 5  # Hexadecimal value of 10 >>> x = 0x10 >>> x 16
  • 9. FLOATING POINT DATA TYPE - FLOAT  The float type in Python designates a floating-point number. float values are specified with a decimal point. Optionally, the character e or E followed by a positive or negative integer may be appended to specify scientific notation Ex.1 >>> 4.2 4.2 >>> type(4.2) <class 'float'> Ex.2 >>> 4. 4.0 Ex.3 >>> .2 0.2 Ex.4>>> .4e7 4000000.0 >>> type(.4e7) <class 'float'> Ex.5>>> 4.2e-4
  • 10. COMPLEX NUMBERS  Complex numbers are specified as <real part>+<imaginary part>j. Ex. >>> 2+3j (2+3j) >>> type(2+3j) <class 'complex'>
  • 11. STRINGS  Strings are sequences of character data. The string type in Python is called str.  String literals may be delimited using either single or double quotes. All the characters between the opening delimiter and matching closing delimiter are part of the string: Ex.>>> print("I am a string.") I am a string. >>> type("I am a string.") <class 'str'> Ex.>>> print('I am too.') I am too. >>> type('I am too.') <class 'str'>
  • 12.  A string in Python can contain as many characters as you wish. The only limit is your machine’s memory resources. A string can also be empty: Ex. >>> '' ''  What if you want to include a quote character as part of the string itself? Your first impulse might be to try something like this: Ex.>>> print('This string contains a single quote (') character.') SyntaxError: invalid syntax Ex. >>> mystring = "This is not my first String" >>> print (mystring); This is not my first String
  • 13.  to join two or more strings. Ex.>>> print ("Hello" + "World"); HelloWorld Ex. >>> s1 = "Name Python " >>> s2 = "had been adapted " >>> s3 = "from Monty Python" >>> print (s1 + s2 + s3) Name Python had been adapted from Monty Python
  • 14.  use input() function Ex.>>> n = input("Number of times you want the text to repeat: ") Number of times you want the text to repeat: >>> print ("Text"*n); TextTextTextTextText  Check existence of a character or a sub- string in a string Ex.>>> "won" in "India won the match" True
  • 15. PYTHON LIST DATA TYPE  List is an ordered sequence of items. It is one of the most used datatype in Python and is very flexible. All the items in a list do not need to be of the same type.  Declaring a list is pretty straight forward. Items separated by commas are enclosed within brackets [ ]. Ex. a = [1, 2.2, 'python'] We can use the slicing operator [ ] to extract an item or a range of items from a list. The index starts from 0 in Python.
  • 16.
  • 17. 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.  Tuples are used to write-protect data and are usually faster than lists as they cannot change dynamically.  It is defined within parentheses () where items are separated by commas. Ex. t = (5,'program', 1+3j)
  • 18.  We can use the slicing operator [] to extract items but we cannot change its value.
  • 19. PYTHON SET DATA TYPE  Set is an unordered collection of unique items. Set is defined by values separated by comma inside braces { }. Items in a set are not ordered.  A set is created by placing all the items (elements) inside curly braces {}, separated by comma, or by using the built- in set() function.  It can have any number of items and they may be of different types (integer, float, tuple, string etc.). But a set cannot have mutable
  • 20.
  • 21.
  • 22. PYTHON DICTIONARY DATA TYPE  Python dictionary is an unordered collection of items. Each item of a dictionary has a key/value pair.  It is generally used when we have a huge amount of data. Dictionaries are optimized for retrieving data. We must know the key to retrieve the value.  In Python, dictionaries are defined within braces {} with each item being a pair in the form key:value. Key and value can be of any type.
  • 23.