SlideShare a Scribd company logo
1 of 10
Anggota Kelompok : || Dosen : Dr. Fariz Darari
Aynun
Nissa
Setiawan
Nadhira
Rafik
Rifanti
Putri
Tallisha
Annisa
Nur
Fitriana
PYTHON ERROR
HANDLING
[1906399202] [1906399253][1906293234] [1906399101]
Type Error
Syntax Error
Value Error
Name Error
Indentation Error
Key Error
Index Error
#DebugOtakError
Newbie + Copy-
Paste
Space
Tab
This error primarily occurs because there are space or
tab errors in your code.
Some of the causes of the error are:
• You are using both spaces and tabs in your code.
• You have placed some indent wrong..
• You forgot to indent the compound statements such
as ‘if’, ‘for’, ‘while’ etc.
• You forgot to indent user-defined functions or
classes.
INDENTATION ERROR
TYPE ERROR
TypeError is thrown when an operation or function is applied
to an object of an inappropriate type.
Because the plus operator (+) expected two numeric
parameters, Python throws a TypeError, telling us that one of
our parameters was of the incorrect type.
VALUE ERROR
To encounter a ValueError in Python means that is a problem with the content
of the object you tried to assign the value to.
Imagine you have a dog and you try to put it in a fish tank. This would be an
example of a type error, because animals of type ‘dog’ certainly are not the
same as animals of type ‘fish’.
On the other hand, imagine we tried to put a Great Dane into a Chihuahua’s
kennel. This would be a problem with the value of the dog, because although
they are both of type ‘dog’, a Chihuahua’s kennel would not be able to accept
a dog the size of a Great Dane.
SYNTAX ERROR
• Basic type of error in Python
• Syntax Error arise when the Python
parser is unable to understand the
code
• Most syntax errors are incorrect
identation, typos, or incorrect
arguments
Because the inconsistent quotes, so Python throws
a SyntaxError
INDEX ERROR
• Index Error raised whenever attempting
to access an index that is outside the
bounds of a list
• If you try to access an item in a list
that doesn’t exist, you will get list
index out of range
• Python doesn’t want to access an item
that doesn’t exist.
Why Name Error Arise
Name Error is raised when you tried to use a variable,
method or function that is not initialized.
It also arise when you want to access local variable from
global
It can also happen because you forgot to use an appropriate
import statement before using additional functionality
NAME ERROR
KEY ERROR
Key Error is raised when
you try to access a key
that isn’t in a dictionary
Key Error also raised in
other places in Python’s
Standard Library, such
as in the zipfile module,
if an item is not found
in a ZIP archive
COMMON CASE
RARE CASE
RESOURCES
 http://cs.carleton.edu/cs_comps/1213/pylearn/final_results/encyclopedia/valueError.html#:~:targetText=Val
ueErrors%20in%20Python,confused%20with%20types%20in%20Python.
 https://teamtreehouse.com/community/in-python-whats-the-difference-between-a-type-error-and-a-value-
error
 https://www.tutorialsteacher.com/python/error-types-in-
python#:~:targetText=Python%20%2D%20Error%20Types,usually%20along%20with%20the%20reason.
 https://en.wikibooks.org/wiki/Python_Programming/Errors
 https://realpython.com/python-keyerror/

More Related Content

Similar to Python error handling

Similar to Python error handling (20)

Presentation 1 for school (1).pptx
Presentation 1 for school (1).pptxPresentation 1 for school (1).pptx
Presentation 1 for school (1).pptx
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
Exceptions in python
Exceptions in pythonExceptions in python
Exceptions in python
 
Exceptions in python
Exceptions in pythonExceptions in python
Exceptions in python
 
Python 01.pptx
Python 01.pptxPython 01.pptx
Python 01.pptx
 
Python1
Python1Python1
Python1
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python Programming 1.pptx
Python Programming 1.pptxPython Programming 1.pptx
Python Programming 1.pptx
 
bhaskars.pptx
bhaskars.pptxbhaskars.pptx
bhaskars.pptx
 
Perl5 meta programming
Perl5 meta programmingPerl5 meta programming
Perl5 meta programming
 
modul-python-part1.pptx
modul-python-part1.pptxmodul-python-part1.pptx
modul-python-part1.pptx
 
Python programming
Python programmingPython programming
Python programming
 
Python intro
Python introPython intro
Python intro
 
bhaskars.pptx
bhaskars.pptxbhaskars.pptx
bhaskars.pptx
 
Python Intro
Python IntroPython Intro
Python Intro
 
How to use Salesforce Workbench like a Pro
How to use Salesforce Workbench like a ProHow to use Salesforce Workbench like a Pro
How to use Salesforce Workbench like a Pro
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
 
web programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Malothweb programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Maloth
 
Type Annotations in Python: Whats, Whys and Wows!
Type Annotations in Python: Whats, Whys and Wows!Type Annotations in Python: Whats, Whys and Wows!
Type Annotations in Python: Whats, Whys and Wows!
 

Recently uploaded

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 

Recently uploaded (20)

Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 

Python error handling

  • 1. Anggota Kelompok : || Dosen : Dr. Fariz Darari Aynun Nissa Setiawan Nadhira Rafik Rifanti Putri Tallisha Annisa Nur Fitriana PYTHON ERROR HANDLING [1906399202] [1906399253][1906293234] [1906399101]
  • 2. Type Error Syntax Error Value Error Name Error Indentation Error Key Error Index Error #DebugOtakError
  • 3. Newbie + Copy- Paste Space Tab This error primarily occurs because there are space or tab errors in your code. Some of the causes of the error are: • You are using both spaces and tabs in your code. • You have placed some indent wrong.. • You forgot to indent the compound statements such as ‘if’, ‘for’, ‘while’ etc. • You forgot to indent user-defined functions or classes. INDENTATION ERROR
  • 4. TYPE ERROR TypeError is thrown when an operation or function is applied to an object of an inappropriate type. Because the plus operator (+) expected two numeric parameters, Python throws a TypeError, telling us that one of our parameters was of the incorrect type.
  • 5. VALUE ERROR To encounter a ValueError in Python means that is a problem with the content of the object you tried to assign the value to. Imagine you have a dog and you try to put it in a fish tank. This would be an example of a type error, because animals of type ‘dog’ certainly are not the same as animals of type ‘fish’. On the other hand, imagine we tried to put a Great Dane into a Chihuahua’s kennel. This would be a problem with the value of the dog, because although they are both of type ‘dog’, a Chihuahua’s kennel would not be able to accept a dog the size of a Great Dane.
  • 6. SYNTAX ERROR • Basic type of error in Python • Syntax Error arise when the Python parser is unable to understand the code • Most syntax errors are incorrect identation, typos, or incorrect arguments Because the inconsistent quotes, so Python throws a SyntaxError
  • 7. INDEX ERROR • Index Error raised whenever attempting to access an index that is outside the bounds of a list • If you try to access an item in a list that doesn’t exist, you will get list index out of range • Python doesn’t want to access an item that doesn’t exist.
  • 8. Why Name Error Arise Name Error is raised when you tried to use a variable, method or function that is not initialized. It also arise when you want to access local variable from global It can also happen because you forgot to use an appropriate import statement before using additional functionality NAME ERROR
  • 9. KEY ERROR Key Error is raised when you try to access a key that isn’t in a dictionary Key Error also raised in other places in Python’s Standard Library, such as in the zipfile module, if an item is not found in a ZIP archive COMMON CASE RARE CASE
  • 10. RESOURCES  http://cs.carleton.edu/cs_comps/1213/pylearn/final_results/encyclopedia/valueError.html#:~:targetText=Val ueErrors%20in%20Python,confused%20with%20types%20in%20Python.  https://teamtreehouse.com/community/in-python-whats-the-difference-between-a-type-error-and-a-value- error  https://www.tutorialsteacher.com/python/error-types-in- python#:~:targetText=Python%20%2D%20Error%20Types,usually%20along%20with%20the%20reason.  https://en.wikibooks.org/wiki/Python_Programming/Errors  https://realpython.com/python-keyerror/