SlideShare a Scribd company logo
1 of 12
Python Built-in Functions
and Use cases
Srajan Mor
Integers
Purpose:
Digital computer can only process data that
has been expressed in binary format. That is
to say 0 or 1, which can be expressed
electronically as On/Off.
For Information technology applications, the
amount of information being processed is an
important design consideration.
The term bit-length is a technical shorthand
for this measure.
bit_length() method in python tell us the
Number of bits necessary to represent an
integer in binary number.
.bit_length()
Use Cases
Integers
Purpose:
Not only real numbers, Python can also
handle complex numbers and its associated
functions.
Complex numbers have their uses in many
applications related to mathematics and
python provides useful tools to handle and
manipulate them.
Complex numbers are expressed as
combination of real and imaginary part.
Complex number = a + bi
Where ‘a’ is the real part and ‘bi’ is the
imaginary part.
Since integers are real numbers only, they
will always return 0 when using .imag().
.real() and .imag()
Use Cases
Integers
Purpose:
Whenever we are dealing with complex
numbers we can use this function.
This function basically removes the
parenthesis from an integer.
.conjugate()
Use Cases
.numerator()
.denominator()
Purpose:
These function return the numerator and
denominator from an integer.
Since integers are without any decimals, so
the denominator will always be 1.
Strings
Purpose:
At some point, we may need to beak a large
string into smaller chunks or strings. This is
opposite of concatenation which merges or
combines string into one.
To do this, we use the split function. It breaks
the given string by the specified separator
and then returns the output in form of a list.
We need to specify a delimiter as the
separator. If we do not define a delimiter,
then python will split the string assuming
whitespace as a separator.
We can also define how many times we
need python to split the string. By default
there is no limit.
.split()
Use Cases
Strings
Purpose:
This function returns the capitalized version
of a string. We need to note that it only
capitalizes the first letter of the string.
.capitalize()
Use Cases
.lower() and .upper()
Purpose:
.lower() function returns the entire string in a
lower case.
.upper() function returns the entire string in
upper case.
Strings
Purpose:
This method formats the specified value and
inserts them inside the string’s placeholder.
A placeholder is defined using curly brackets:
{}. Placeholder tell the format method the
location where we need to insert a specific
value.
We can have multiple placeholder in a string
in which we can have multiple values.
This method is particularly useful when we
need to pass something inside a string which
is changing or is calculated.
.format()
Use Cases
Float
Purpose:
This function returns a pair of integer whose
ratio is exactly equal to the original float and
with a positive denominator. Note that is
returns the result in tuple.
.as_integer_ratio()
Use Cases
.hex() and .fromhex()
Purpose:
.hex() function returns the hexadecimal
representation of a floating point number.
.fromhex() creates a floating point number
from a hexadecimal string.
Float
Purpose:
This function checks whether the value
stored is an integer of not. Returns true if it
is.
.is_integer()
Use Cases
.imag() and .real()
Purpose:
Complex numbers are expressed as
combination of real and imaginary part.
Complex number = a + bi
Where ‘a’ is the real part and ‘bi’ is the
imaginary part.
Since floats are real numbers only, they will
always return 0 when using .imag().
.
Lists
Purpose:
This function adds a single item to the end of
the list. Accordingly the length of the string
increases by 1.
.append()
Use Cases
.copy()
Purpose:
A list can be copied by using the ‘=‘
operator. But the problem with this is,
whenever we change the old list the new list
will also change.
To remedy this we can use the fuction
.copy() to just clone the old list. We can save
this cloned list as a new list and work on it.
Lists
Purpose:
This function is different from .append() as
by use of this function we can add more
than one element to our list.
Basically we can add an iterable objects.
.extend()
Use Cases
.index()
Purpose:
This function finds the given element in the
list and returns its position.
Note: If the same element is present more
than once, this function returns the index of
the first occurrence of the element.
Note: Index in python starts from 0, not 1.
We need to provide the element of which we
want to find the index.
Lists
Purpose:
This function can used to sort list of integers,
floats, strings and others.
The sorting is done in ascending,
descending or user defined order.
.sort()
Use Cases
.pop()
Purpose:
This function removes the item at the given
index from the list and returns the removed
item.
By default if we do not specify the item, then
the function will remove the last items on list.
It does not work when the index is out of
bounds or out of range.

More Related Content

What's hot

What's hot (20)

Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in Python
 
Python strings presentation
Python strings presentationPython strings presentation
Python strings presentation
 
Python programming : Strings
Python programming : StringsPython programming : Strings
Python programming : Strings
 
C Structures and Unions
C Structures and UnionsC Structures and Unions
C Structures and Unions
 
String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Introduction to Python
Introduction to Python  Introduction to Python
Introduction to Python
 
Python Flow Control
Python Flow ControlPython Flow Control
Python Flow Control
 
Python strings
Python stringsPython strings
Python strings
 
Pointers
PointersPointers
Pointers
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointers
 
Python list
Python listPython list
Python list
 
Dynamic memory allocation in c++
Dynamic memory allocation in c++Dynamic memory allocation in c++
Dynamic memory allocation in c++
 
Function in c
Function in cFunction in c
Function in c
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in python
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Vector class in C++
Vector class in C++Vector class in C++
Vector class in C++
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
 

Similar to Python Built-in Functions and Use cases

Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptxrohithprabhas1
 
INTRODUCTION TO PYTHON PROGRMMING AND FUNCTIONS
INTRODUCTION TO PYTHON PROGRMMING AND FUNCTIONSINTRODUCTION TO PYTHON PROGRMMING AND FUNCTIONS
INTRODUCTION TO PYTHON PROGRMMING AND FUNCTIONSKalaivaniD12
 
Python workshop
Python workshopPython workshop
Python workshopJibin Sabu
 
Programming in C sesion 2
Programming in C sesion 2Programming in C sesion 2
Programming in C sesion 2Prerna Sharma
 
Python-02| Input, Output & Import
Python-02| Input, Output & ImportPython-02| Input, Output & Import
Python-02| Input, Output & ImportMohd Sajjad
 
ppt notes python language operators and data
ppt notes python language operators and datappt notes python language operators and data
ppt notes python language operators and dataSukhpreetSingh519414
 
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxpriestmanmable
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answerskavinilavuG
 
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdfCOMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdfrajkumar2792005
 
Python - Module 1.ppt
Python - Module 1.pptPython - Module 1.ppt
Python - Module 1.pptjaba kumar
 
Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning ParrotAI
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answersRojaPriya
 
Python_Unit_1.pdf
Python_Unit_1.pdfPython_Unit_1.pdf
Python_Unit_1.pdfalaparthi
 
function in python programming languges .pptx
function in python programming languges .pptxfunction in python programming languges .pptx
function in python programming languges .pptxrundalomary12
 

Similar to Python Built-in Functions and Use cases (20)

Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptx
 
INTRODUCTION TO PYTHON PROGRMMING AND FUNCTIONS
INTRODUCTION TO PYTHON PROGRMMING AND FUNCTIONSINTRODUCTION TO PYTHON PROGRMMING AND FUNCTIONS
INTRODUCTION TO PYTHON PROGRMMING AND FUNCTIONS
 
functions- best.pdf
functions- best.pdffunctions- best.pdf
functions- best.pdf
 
Python workshop
Python workshopPython workshop
Python workshop
 
Functions-.pdf
Functions-.pdfFunctions-.pdf
Functions-.pdf
 
Programming in C sesion 2
Programming in C sesion 2Programming in C sesion 2
Programming in C sesion 2
 
Python-02| Input, Output & Import
Python-02| Input, Output & ImportPython-02| Input, Output & Import
Python-02| Input, Output & Import
 
Python Objects
Python ObjectsPython Objects
Python Objects
 
Chapter - 2.pptx
Chapter - 2.pptxChapter - 2.pptx
Chapter - 2.pptx
 
ppt notes python language operators and data
ppt notes python language operators and datappt notes python language operators and data
ppt notes python language operators and data
 
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
 
Python-Functions.pptx
Python-Functions.pptxPython-Functions.pptx
Python-Functions.pptx
 
ACM init()- Day 4
ACM init()- Day 4ACM init()- Day 4
ACM init()- Day 4
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdfCOMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
 
Python - Module 1.ppt
Python - Module 1.pptPython - Module 1.ppt
Python - Module 1.ppt
 
Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Python_Unit_1.pdf
Python_Unit_1.pdfPython_Unit_1.pdf
Python_Unit_1.pdf
 
function in python programming languges .pptx
function in python programming languges .pptxfunction in python programming languges .pptx
function in python programming languges .pptx
 

Recently uploaded

KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 

Recently uploaded (20)

KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 

Python Built-in Functions and Use cases

  • 1. Python Built-in Functions and Use cases Srajan Mor
  • 2. Integers Purpose: Digital computer can only process data that has been expressed in binary format. That is to say 0 or 1, which can be expressed electronically as On/Off. For Information technology applications, the amount of information being processed is an important design consideration. The term bit-length is a technical shorthand for this measure. bit_length() method in python tell us the Number of bits necessary to represent an integer in binary number. .bit_length() Use Cases
  • 3. Integers Purpose: Not only real numbers, Python can also handle complex numbers and its associated functions. Complex numbers have their uses in many applications related to mathematics and python provides useful tools to handle and manipulate them. Complex numbers are expressed as combination of real and imaginary part. Complex number = a + bi Where ‘a’ is the real part and ‘bi’ is the imaginary part. Since integers are real numbers only, they will always return 0 when using .imag(). .real() and .imag() Use Cases
  • 4. Integers Purpose: Whenever we are dealing with complex numbers we can use this function. This function basically removes the parenthesis from an integer. .conjugate() Use Cases .numerator() .denominator() Purpose: These function return the numerator and denominator from an integer. Since integers are without any decimals, so the denominator will always be 1.
  • 5. Strings Purpose: At some point, we may need to beak a large string into smaller chunks or strings. This is opposite of concatenation which merges or combines string into one. To do this, we use the split function. It breaks the given string by the specified separator and then returns the output in form of a list. We need to specify a delimiter as the separator. If we do not define a delimiter, then python will split the string assuming whitespace as a separator. We can also define how many times we need python to split the string. By default there is no limit. .split() Use Cases
  • 6. Strings Purpose: This function returns the capitalized version of a string. We need to note that it only capitalizes the first letter of the string. .capitalize() Use Cases .lower() and .upper() Purpose: .lower() function returns the entire string in a lower case. .upper() function returns the entire string in upper case.
  • 7. Strings Purpose: This method formats the specified value and inserts them inside the string’s placeholder. A placeholder is defined using curly brackets: {}. Placeholder tell the format method the location where we need to insert a specific value. We can have multiple placeholder in a string in which we can have multiple values. This method is particularly useful when we need to pass something inside a string which is changing or is calculated. .format() Use Cases
  • 8. Float Purpose: This function returns a pair of integer whose ratio is exactly equal to the original float and with a positive denominator. Note that is returns the result in tuple. .as_integer_ratio() Use Cases .hex() and .fromhex() Purpose: .hex() function returns the hexadecimal representation of a floating point number. .fromhex() creates a floating point number from a hexadecimal string.
  • 9. Float Purpose: This function checks whether the value stored is an integer of not. Returns true if it is. .is_integer() Use Cases .imag() and .real() Purpose: Complex numbers are expressed as combination of real and imaginary part. Complex number = a + bi Where ‘a’ is the real part and ‘bi’ is the imaginary part. Since floats are real numbers only, they will always return 0 when using .imag(). .
  • 10. Lists Purpose: This function adds a single item to the end of the list. Accordingly the length of the string increases by 1. .append() Use Cases .copy() Purpose: A list can be copied by using the ‘=‘ operator. But the problem with this is, whenever we change the old list the new list will also change. To remedy this we can use the fuction .copy() to just clone the old list. We can save this cloned list as a new list and work on it.
  • 11. Lists Purpose: This function is different from .append() as by use of this function we can add more than one element to our list. Basically we can add an iterable objects. .extend() Use Cases .index() Purpose: This function finds the given element in the list and returns its position. Note: If the same element is present more than once, this function returns the index of the first occurrence of the element. Note: Index in python starts from 0, not 1. We need to provide the element of which we want to find the index.
  • 12. Lists Purpose: This function can used to sort list of integers, floats, strings and others. The sorting is done in ascending, descending or user defined order. .sort() Use Cases .pop() Purpose: This function removes the item at the given index from the list and returns the removed item. By default if we do not specify the item, then the function will remove the last items on list. It does not work when the index is out of bounds or out of range.