Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Aniruddh-0701 committed Jul 22, 2021
1 parent 6b1438e commit 7fbaa9a
Show file tree
Hide file tree
Showing 12 changed files with 15,274 additions and 109 deletions.
22 changes: 15 additions & 7 deletions .ipynb_checkpoints/DS_Lists-checkpoint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 1,
"metadata": {},
"outputs": [
{
Expand All @@ -304,7 +304,7 @@
"[10, 15, 20, 25, 35, 30]"
]
},
"execution_count": 15,
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -532,7 +532,7 @@
],
"source": [
"l1 = ['Hi', 'Python', 'how', 'String', 'Data', 'Sorting Strings']\n",
"l1.sort()\n",
"l1.sort() #lexicographic sorting (as per unicode values)\n",
"print(l1)\n",
"l1.sort(key = len, reverse = True)\n",
"print(l1)"
Expand All @@ -553,23 +553,31 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[10, 20, 50, 0, -10, -1, 100]\n"
]
},
{
"data": {
"text/plain": [
"[-10, -1, 0, 10, 20, 50, 100]"
]
},
"execution_count": 17,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"l2 = [10, 20, 50, 0, -10, -1, 100]\n",
"l2 = sorted(l2)\n",
"l1 = [10, 20, 50, 0, -10, -1, 100]\n",
"l2 = sorted(l1)\n",
"print(l1)\n",
"l2"
]
},
Expand Down
252 changes: 252 additions & 0 deletions .ipynb_checkpoints/Errors_and_Exception_Handling-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "199a314e-264d-40a7-9acc-cf6e1843dba7",
"metadata": {},
"source": [
"# Errors and Exception"
]
},
{
"cell_type": "markdown",
"id": "e6044ca7-f38b-492b-b869-23f5409ac9e1",
"metadata": {},
"source": [
"## Error:\n",
"\n",
"Errors are the problems in a program due to which the program will stop the execution.\n",
"\n",
"[Some Common Errors](https://www.thecrazyprogrammer.com/2014/08/types-of-errors-in-programming.html)\n",
"\n",
"1. Syntax Errors\n",
"2. Run-time Errors\n",
"3. Logical Errors\n",
"4. Latent Errors"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "35bf50f2-6901-4407-a684-415f7ba3f569",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ArithmeticError\n",
"AssertionError\n",
"AttributeError\n",
"BlockingIOError\n",
"BrokenPipeError\n",
"BufferError\n",
"ChildProcessError\n",
"ConnectionAbortedError\n",
"ConnectionError\n",
"ConnectionRefusedError\n",
"ConnectionResetError\n",
"EOFError\n",
"EnvironmentError\n",
"FileExistsError\n",
"FileNotFoundError\n",
"FloatingPointError\n",
"IOError\n",
"ImportError\n",
"IndentationError\n",
"IndexError\n",
"InterruptedError\n",
"IsADirectoryError\n",
"KeyError\n",
"LookupError\n",
"MemoryError\n",
"ModuleNotFoundError\n",
"NameError\n",
"NotADirectoryError\n",
"NotImplementedError\n",
"OSError\n",
"OverflowError\n",
"PermissionError\n",
"ProcessLookupError\n",
"RecursionError\n",
"ReferenceError\n",
"RuntimeError\n",
"SyntaxError\n",
"SystemError\n",
"TabError\n",
"TimeoutError\n",
"TypeError\n",
"UnboundLocalError\n",
"UnicodeDecodeError\n",
"UnicodeEncodeError\n",
"UnicodeError\n",
"UnicodeTranslateError\n",
"ValueError\n",
"WindowsError\n",
"ZeroDivisionError\n",
"ArithmeticError\n",
"AssertionError\n",
"AttributeError\n",
"BlockingIOError\n",
"BrokenPipeError\n",
"BufferError\n",
"ChildProcessError\n",
"ConnectionAbortedError\n",
"ConnectionError\n",
"ConnectionRefusedError\n",
"ConnectionResetError\n",
"EOFError\n",
"EnvironmentError\n",
"FileExistsError\n",
"FileNotFoundError\n",
"FloatingPointError\n",
"IOError\n",
"ImportError\n",
"IndentationError\n",
"IndexError\n",
"InterruptedError\n",
"IsADirectoryError\n",
"KeyError\n",
"LookupError\n",
"MemoryError\n",
"ModuleNotFoundError\n",
"NameError\n",
"NotADirectoryError\n",
"NotImplementedError\n",
"OSError\n",
"OverflowError\n",
"PermissionError\n",
"ProcessLookupError\n",
"RecursionError\n",
"ReferenceError\n",
"RuntimeError\n",
"SyntaxError\n",
"SystemError\n",
"TabError\n",
"TimeoutError\n",
"TypeError\n",
"UnboundLocalError\n",
"UnicodeDecodeError\n",
"UnicodeEncodeError\n",
"UnicodeError\n",
"UnicodeTranslateError\n",
"ValueError\n",
"WindowsError\n",
"ZeroDivisionError\n"
]
}
],
"source": [
"# list of Errors and exceptions\n",
"for i in dir(__builtins__) + dir(__builtin__):\n",
" if \"Error\" in i:\n",
" print(i)"
]
},
{
"cell_type": "markdown",
"id": "de9d7e7b-70f5-444f-88b5-a1f77d213d76",
"metadata": {},
"source": [
"## Exception:\n",
"\n",
"Exceptions are raised when the some internal events occur which changes the normal flow of the program."
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "2b604b7f-9acf-4196-9ce3-45214b38adc8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"BaseException\n",
"Exception\n",
"BaseException\n",
"Exception\n"
]
}
],
"source": [
"# list of Errors and exceptions\n",
"for i in dir(__builtins__) + dir(__builtin__):\n",
" if \"Exception\" in i:\n",
" print(i)"
]
},
{
"cell_type": "markdown",
"id": "4e8439e0-145b-46a5-9f3f-4624aa99b605",
"metadata": {},
"source": [
"## Traceback\n",
"The script used below is present [here](Errors_and_Exception.py)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "5e69d208-e867-431e-a8b1-58669ad3a798",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"In a\n",
"In b\n"
]
},
{
"ename": "ZeroDivisionError",
"evalue": "division by zero",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mZeroDivisionError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-11-cabfeb6b5ae6>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 8\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[1;36m42\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 9\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 10\u001b[1;33m \u001b[0ma\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;32m<ipython-input-11-cabfeb6b5ae6>\u001b[0m in \u001b[0;36ma\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0ma\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"In a\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[0mb\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Back in a\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32m<ipython-input-11-cabfeb6b5ae6>\u001b[0m in \u001b[0;36mb\u001b[1;34m()\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"In b\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 8\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[1;36m42\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 9\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[0ma\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mZeroDivisionError\u001b[0m: division by zero"
]
}
],
"source": [
"def a():\n",
" print(\"In a\")\n",
" b()\n",
" print(\"Back in a\")\n",
"\n",
"def b():\n",
" print(\"In b\")\n",
" return 42/0\n",
"\n",
"a() "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
12 changes: 12 additions & 0 deletions .ipynb_checkpoints/Errors_and_exception-checkpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def a():
print("In a")
b()
print("Back in a")

def b():
val = 52
print("In b")
val
return val

a()
Loading

0 comments on commit 7fbaa9a

Please sign in to comment.