SlideShare a Scribd company logo
Python Basics
Python data types
• Numeric types: int, float, complex
• Text type: str
• Boolean type: bool
Data Types
• Numeric Data Types
• String Data Type
Data Types
• Boolean Data Type
Python Operators
• Operators are symbols or special characters that perform specific operations on
values or variables in Python.
• Arithmetic operators(*, +, -, /, //, %, **)
• Assignment operators(=, +=, -=)
• Comparison operators()
• Logical operators()
• Membership operators()
• Identity operators()
Arithmetic operators
• Arithmetic operators are used for performing mathematical calculations.
Arithmetic Operators
• Code
Comparison operators
• Comparison operators are used to compare values and determine the relationship
between them.
Comparison operators
• Code
Logical operators
• Logical operators are used to combine and manipulate logical values (True or
False).
Logical Operators
• Code
Assignment operators
• Assignment operators are used to assign values to variables.
Assignment Operators
• Code
Identity Operators and Membership Operators
Identity operators are used to compare the identity of objects.
is - True if the operands are identical.
is not - True if the operands are not identical.
Membership operators are used to test if a value is a member of a sequence or not.
in - True if value is found in the sequence.
not in - True if value is not found in the sequence.
Identity Operators
• Code
Membership Operators
• Code
Python Data Structures
• Python provides various data structures that allow you to organize and store data
efficiently.
• Sequential Data Structures:
Lists
Tuples
Strings
• Mapping Data Structure:
Dictionaries
• Set Data Structures:
Sets
Data Structures
List operations
• List Creation Code
• Accessing List Elements:
• Modifying List Elements:
List operations
• List Slicing:
• List Length:
• Adding Elements to a List:
List operations
• Removing Elements from a List:
• Checking if an Element Exists in a List:
• Sorting a List:
Tuple Operations
• Tuple Creation:
• Accessing Tuple Elements:
• Modifying Tuple Elements (Immutable):
Tuple Operations
• Tuple Length:
• Tuple Concatenation:
• Tuple Repetition:
Tuple Operations
• Tuple Slicing:
• Checking if an Element Exists in a Tuple:
String Operation
• String Creation:
• String Concatenation:
• Accessing String Characters:
String Operation
• String Length:
• String Slicing:
• Changing Case:
String Operation
• String Formatting:
• Checking Substring Existence:
• String Splitting:
Dictionary Operation
• Dictionary Creation:
• Accessing Dictionary Elements:
• Modifying Dictionary Elements:
Dictionary Operation
• Adding Elements to a Dictionary:
• Removing Elements from a Dictionary:
• Checking if a Key Exists in a Dictionary:
Dictionary Operation
• Dictionary Length:
• Getting Dictionary Keys and Values:
Loops
• for loop is used to iterate over a sequence or collection of elements. It allows you
to perform a set of statements or actions repeatedly for each item in the
sequence.
• Code:
• Output:
while loop
• A while loop is used to repeatedly execute a block of code as long as a specific
condition is True.
• Code:
• Output:
Nested loops
• Nested loops involve using one loop inside another loop. The outer loop controls
the iteration of the inner loop. For each iteration of the outer loop, the inner loop
runs completely.
• Code:
• Output:
Conditional Statements
• if statement is used to execute a block of code if a specific condition is True.
• Code:
• Output:
if-else
• if-else statement allows you to execute one block of code if the condition is True,
and a different block of code if the condition is False.
• Code:
• Output:
Nested if
• Nested if statements are if statements within other if statements. They allow you
to have multiple levels of conditions and code blocks.
• Code:
• Output:
control statement
Break Statement
• The `break` statement is used to exit or terminate a loop prematurely.
• Code:
• Output:
Continue
• The `continue` statement allows you to skip certain iterations and move to the
next iteration of the loop.
• Code:
• Output:
Pass
• The `pass` statement is a placeholder statement that does nothing. It is used when
you need a statement syntactically, but you don't want it to do anything.
• Code:
• Output:
Functions
• Functions are blocks of reusable code that perform a specific task. They help in
organizing code, improving reusability, and promoting modularity.
• Example:
• Output:
`def` keyword
• The `def` keyword is used to define a function in Python. It indicates the start of a
function definition and is followed by the function name and a block of code that
is executed when the function is called.
• Example:
• Output:
Lambda expressions
• Lambda expressions, also known as anonymous functions, are small, inline
functions without a name. They are defined using the `lambda` keyword and are
commonly used when a function is required for a short duration.
• Example:
• Output:
`map` function
• The `map` function applies a given function to each item in an iterable (such as a
list) and returns a new iterable with the results.
• Example:
• Output:
`filter` function
• The `filter` function creates a new iterable that includes only the items from an
iterable that satisfy a given condition.
• Example:
• Output:

More Related Content

Similar to Python Basics.pptx

Pa1 session 2
Pa1 session 2 Pa1 session 2
Pa1 session 2
aiclub_slides
 
Python first day
Python first dayPython first day
Python first day
MARISSTELLA2
 
Python first day
Python first dayPython first day
Python first day
farkhand
 
17575602.ppt
17575602.ppt17575602.ppt
17575602.ppt
TejaValmiki
 
Python for katana
Python for katanaPython for katana
Python for katana
kedar nath
 
Python-Magnitia-ToC.pdf
Python-Magnitia-ToC.pdfPython-Magnitia-ToC.pdf
Python-Magnitia-ToC.pdf
AnanthReddy38
 
Python indroduction
Python indroductionPython indroduction
Python indroduction
FEG
 
MODULE-2.pptx
MODULE-2.pptxMODULE-2.pptx
MODULE-2.pptx
ASRPANDEY
 
Python_basics.pptx
Python_basics.pptxPython_basics.pptx
Python_basics.pptx
RichardGuerra19
 
Programming course slides c++ (Prof Mansoor Bhatti)
Programming course slides c++ (Prof Mansoor Bhatti)Programming course slides c++ (Prof Mansoor Bhatti)
Programming course slides c++ (Prof Mansoor Bhatti)Syed Arslan Rizvi
 
Functions, List and String methods
Functions, List and String methodsFunctions, List and String methods
Functions, List and String methods
PranavSB
 
Javascript
JavascriptJavascript
Javascript
Sunil Thakur
 
Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptx
rohithprabhas1
 
python presentation.pptx
python presentation.pptxpython presentation.pptx
python presentation.pptx
NightTune44
 
Unit-I-PPT-1.ppt
Unit-I-PPT-1.pptUnit-I-PPT-1.ppt
Unit-I-PPT-1.ppt
Chinmaya M. N
 
Module 3,4.pptx
Module 3,4.pptxModule 3,4.pptx
Module 3,4.pptx
SandeepR95
 
Python programming
Python programmingPython programming
Python programming
sirikeshava
 
Learning core java
Learning core javaLearning core java
Learning core java
Abhay Bharti
 
Charles Sharp: Java 8 Streams
Charles Sharp: Java 8 StreamsCharles Sharp: Java 8 Streams
Charles Sharp: Java 8 Streams
jessitron
 
Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1
Jamshid Hashimi
 

Similar to Python Basics.pptx (20)

Pa1 session 2
Pa1 session 2 Pa1 session 2
Pa1 session 2
 
Python first day
Python first dayPython first day
Python first day
 
Python first day
Python first dayPython first day
Python first day
 
17575602.ppt
17575602.ppt17575602.ppt
17575602.ppt
 
Python for katana
Python for katanaPython for katana
Python for katana
 
Python-Magnitia-ToC.pdf
Python-Magnitia-ToC.pdfPython-Magnitia-ToC.pdf
Python-Magnitia-ToC.pdf
 
Python indroduction
Python indroductionPython indroduction
Python indroduction
 
MODULE-2.pptx
MODULE-2.pptxMODULE-2.pptx
MODULE-2.pptx
 
Python_basics.pptx
Python_basics.pptxPython_basics.pptx
Python_basics.pptx
 
Programming course slides c++ (Prof Mansoor Bhatti)
Programming course slides c++ (Prof Mansoor Bhatti)Programming course slides c++ (Prof Mansoor Bhatti)
Programming course slides c++ (Prof Mansoor Bhatti)
 
Functions, List and String methods
Functions, List and String methodsFunctions, List and String methods
Functions, List and String methods
 
Javascript
JavascriptJavascript
Javascript
 
Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptx
 
python presentation.pptx
python presentation.pptxpython presentation.pptx
python presentation.pptx
 
Unit-I-PPT-1.ppt
Unit-I-PPT-1.pptUnit-I-PPT-1.ppt
Unit-I-PPT-1.ppt
 
Module 3,4.pptx
Module 3,4.pptxModule 3,4.pptx
Module 3,4.pptx
 
Python programming
Python programmingPython programming
Python programming
 
Learning core java
Learning core javaLearning core java
Learning core java
 
Charles Sharp: Java 8 Streams
Charles Sharp: Java 8 StreamsCharles Sharp: Java 8 Streams
Charles Sharp: Java 8 Streams
 
Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1
 

More from 16115yogendraSingh

A bug reconnaissance tool is typically software or a system used by cybersecu...
A bug reconnaissance tool is typically software or a system used by cybersecu...A bug reconnaissance tool is typically software or a system used by cybersecu...
A bug reconnaissance tool is typically software or a system used by cybersecu...
16115yogendraSingh
 
Presentation on Pandas in _ detail .pptx
Presentation on Pandas in _ detail .pptxPresentation on Pandas in _ detail .pptx
Presentation on Pandas in _ detail .pptx
16115yogendraSingh
 
multipleaccesstechniques-201110153309.pptx
multipleaccesstechniques-201110153309.pptxmultipleaccesstechniques-201110153309.pptx
multipleaccesstechniques-201110153309.pptx
16115yogendraSingh
 
loopoptimization-180418113642.pdf
loopoptimization-180418113642.pdfloopoptimization-180418113642.pdf
loopoptimization-180418113642.pdf
16115yogendraSingh
 
pptseminar.pptx
pptseminar.pptxpptseminar.pptx
pptseminar.pptx
16115yogendraSingh
 
51095137-Semantic-WEB.ppt
51095137-Semantic-WEB.ppt51095137-Semantic-WEB.ppt
51095137-Semantic-WEB.ppt
16115yogendraSingh
 
Chapter 8 Deriving and Reclassifying Fields.pptx
Chapter 8 Deriving and Reclassifying Fields.pptxChapter 8 Deriving and Reclassifying Fields.pptx
Chapter 8 Deriving and Reclassifying Fields.pptx
16115yogendraSingh
 

More from 16115yogendraSingh (7)

A bug reconnaissance tool is typically software or a system used by cybersecu...
A bug reconnaissance tool is typically software or a system used by cybersecu...A bug reconnaissance tool is typically software or a system used by cybersecu...
A bug reconnaissance tool is typically software or a system used by cybersecu...
 
Presentation on Pandas in _ detail .pptx
Presentation on Pandas in _ detail .pptxPresentation on Pandas in _ detail .pptx
Presentation on Pandas in _ detail .pptx
 
multipleaccesstechniques-201110153309.pptx
multipleaccesstechniques-201110153309.pptxmultipleaccesstechniques-201110153309.pptx
multipleaccesstechniques-201110153309.pptx
 
loopoptimization-180418113642.pdf
loopoptimization-180418113642.pdfloopoptimization-180418113642.pdf
loopoptimization-180418113642.pdf
 
pptseminar.pptx
pptseminar.pptxpptseminar.pptx
pptseminar.pptx
 
51095137-Semantic-WEB.ppt
51095137-Semantic-WEB.ppt51095137-Semantic-WEB.ppt
51095137-Semantic-WEB.ppt
 
Chapter 8 Deriving and Reclassifying Fields.pptx
Chapter 8 Deriving and Reclassifying Fields.pptxChapter 8 Deriving and Reclassifying Fields.pptx
Chapter 8 Deriving and Reclassifying Fields.pptx
 

Recently uploaded

Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
Kamal Acharya
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
MuhammadTufail242431
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 

Recently uploaded (20)

Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 

Python Basics.pptx