Sitemap
Yen Wang

Yen Wang

Curious mind. Interested in both creative and exploitative sides. More about me | https://www.yenwang.dev/

Python — Basic Review before diving deeper 09

Want to recall the memory of Python easily?

5 min readMay 1, 2023

--

Press enter or click to view image in full size

This is the note taken when I learned Python “again”, hope it helps you too.
There are additional links in the article for you to understand further information.

BTW. I just start my journey with break-the-ice-with-python ☃️🔥
💠My solutions are here

Quick tip |
Find ⚡ for each topic

☘️Directory

🔹Error Handling

🔹Common types of exceptions

🔹Genertators & yields

❤️Good Resources

Bro code | Python full course
ZeroToMastery | Pyhton
Codes in Github

⚡Error Handling

More in GeeksforGeeks | Exception Handling
Error handling in W3Schools

When you encounter errors, you should try to Catch Specific exception.

🔸Those above can be classified as two types:

🔹Syntax errors

🔹Logical errors (Exceptions)

🔸Know there before diving deeper:

🔹Errors = problems in a program then it will stop the execution

🔹Catch Exceptions —

  • try block lets you test a block of code for errors
  • except block lets you handle the error.
  • finally block lets you execute code, regardless of the result of the try- and except blocks.

🔹Syntax —

More in W3Schools | Try Except

  • Catch Specific exception
Press enter or click to view image in full size
  • Normal Catch Exception
Press enter or click to view image in full size
  • try with else clause
Press enter or click to view image in full size
  • finally keyword
Press enter or click to view image in full size
  • raise keyword
Press enter or click to view image in full size

⚡Common types of Exceptions

🔹SyntaxError

🔹TypeError

🔹NameError

🔹IndexError

🔹ValueError

🔹AttributeError

🔹IOError

🔹KeyboardInterrupt

🔹ZeroDivisionError

🔹ImportError

Get Yen Wang’s stories in your inbox

Join Medium for free to get updates from this writer.

🔹ModuleNotFoundError

🔸Syntax Error

Press enter or click to view image in full size

🔸Logical Errors(Exception)

Press enter or click to view image in full size
Press enter or click to view image in full size

Let’s see other errors.

🔸TypeError

Press enter or click to view image in full size
Press enter or click to view image in full size
Press enter or click to view image in full size

🔸NameError

Press enter or click to view image in full size
Press enter or click to view image in full size

🔸IndexError

Example from pythonForBeginners

Wrong index number which is out of range.

Press enter or click to view image in full size
Press enter or click to view image in full size

🔸ValueError

More in Educative.io

Press enter or click to view image in full size
Press enter or click to view image in full size

🔸AttributeError

More in GeeksforGeeks

Press enter or click to view image in full size
Press enter or click to view image in full size
Press enter or click to view image in full size
Press enter or click to view image in full size

🔸IOError

More in pythonForBeginners

Press enter or click to view image in full size

🔸KeyboardInterrupt

More in EDUCBA

Press enter or click to view image in full size
Press enter or click to view image in full size

🔸EOF Error

More in GeeksforGeeks

It happens when input hits the end of the file.

Press enter or click to view image in full size

🔸ZeroDivisionError

More in learnShareIt

Literally, error occurs when the variable is divided by 0.

Press enter or click to view image in full size
Press enter or click to view image in full size

🔸TypeError

Press enter or click to view image in full size
Press enter or click to view image in full size

🔸ImportError

More in Educba

Press enter or click to view image in full size
Press enter or click to view image in full size

🔸ModuleNotFoundError

Press enter or click to view image in full size
Press enter or click to view image in full size

⚡Generators & Yield

More in realPython

🔸Yield

More in realPython
More in GeeksforGeeks

🔹yield will create a generator function

🔸First Example

Press enter or click to view image in full size

⚡Exercise 13 — Fibonacci Numbers

More about Fibonacci Numbers

Press enter or click to view image in full size
Press enter or click to view image in full size

--

--

Yen Wang
Yen Wang

Written by Yen Wang

Curious mind. Interested in both creative and exploitative sides. More about me | https://www.yenwang.dev/