├── .gitattributes ├── .gitignore ├── 00-Python Object and Data Structure Basics ├── .ipynb_checkpoints │ ├── 001-Numbers-checkpoint.ipynb │ ├── 01-Dynamic typing and type()-checkpoint.ipynb │ ├── 02-Strings-checkpoint.ipynb │ ├── 03-Print Formatting with Strings-checkpoint.ipynb │ ├── 04-Lists-checkpoint.ipynb │ ├── 05-Dictionaries-checkpoint.ipynb │ ├── 06-Tuples-checkpoint.ipynb │ ├── 07-Sets and Booleans-checkpoint.ipynb │ ├── 08-Files-checkpoint.ipynb │ ├── 09-Objects and Data Structures Assessment Test-checkpoint.ipynb │ ├── 10-Objects and Data Structures Assessment Test-Solution-checkpoint.ipynb │ └── Untitled-checkpoint.ipynb ├── 00-Numbers.ipynb ├── 01-Dynamic typing and type().ipynb ├── 02-Strings.ipynb ├── 03-Print Formatting with Strings.ipynb ├── 04-Lists.ipynb ├── 05-Dictionaries.ipynb ├── 06-Tuples.ipynb ├── 07-Sets and Booleans.ipynb └── advance │ ├── 01-Advanced Numbers.ipynb │ ├── 02-Advanced Strings.ipynb │ ├── 03-Advanced Sets.ipynb │ ├── 04-Advanced Dictionaries.ipynb │ └── 05-Advanced Lists.ipynb ├── 01-Python Comparison Operators ├── .ipynb_checkpoints │ ├── 01-Comparison Operators-checkpoint.ipynb │ └── 02-Chained Comparison Operators-checkpoint.ipynb ├── 01-Comparison Operators.ipynb └── 02-Chained Comparison Operators.ipynb ├── 02-Python Statements ├── .ipynb_checkpoints │ ├── 01-Introduction to Python Statements-checkpoint.ipynb │ ├── 02-if, elif, and else Statements-checkpoint.ipynb │ ├── 03-for Loops-checkpoint.ipynb │ ├── 04-while Loops-checkpoint.ipynb │ ├── 05-Useful-Operators-checkpoint.ipynb │ ├── 05-range()-checkpoint.ipynb │ ├── 06-List Comprehensions-checkpoint.ipynb │ ├── 07-Statements Assessment Test-checkpoint.ipynb │ ├── 08-Statements Assessment Test - Solutions-checkpoint.ipynb │ ├── 09-Guessing Game Challenge-checkpoint.ipynb │ └── 10-Guessing Game Challenge - Solution-checkpoint.ipynb ├── 01-Introduction to Python Statements.ipynb ├── 02-if, elif, and else Statements.ipynb ├── 03-for Loops.ipynb ├── 04-while Loops.ipynb ├── 05-Useful-Operators.ipynb ├── 06-List Comprehensions.ipynb └── __pycache__ │ └── veh.cpython-39.pyc ├── 03-Methods and Functions ├── 01-Methods.ipynb ├── 02-Functions.ipynb ├── 04-Lambda-Expressions-Map-and-Filter.ipynb ├── 05-Nested Statements and Scope.ipynb ├── 06-args and kwargs.ipynb ├── 07-advance_functions.ipynb ├── assignments_function.docx ├── basic_app_calc.py ├── task_manager.py └── tasks.txt ├── 03.01-useful_functions ├── 01-Map.ipynb ├── 02-Reduce.ipynb ├── 03-Filter.ipynb ├── 04-Zip.ipynb ├── 05-Enumerate.ipynb ├── 06-all() and any().ipynb ├── 07-Complex.ipynb └── 08-Iterators and Generators.ipynb ├── 04-Object Oriented Programming ├── 01-Object Oriented Programming.ipynb ├── 02-Inheritance.ipynb ├── 03-encapsulation.ipynb ├── 04-Polymorphism.ipynb ├── 05-Abstraction.ipynb ├── OperatorOverloading.ipynb ├── magicmethods.ipynb ├── oops_image.png ├── solution_task_01.py ├── solution_task_02.py └── tasks.txt ├── 05-Modules and Packages ├── 00-Modules_and_Packages │ ├── MyMainPackage │ │ ├── SubPackage │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-310.pyc │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── __init__.cpython-39.pyc │ │ │ │ ├── mysubscript.cpython-310.pyc │ │ │ │ ├── mysubscript.cpython-36.pyc │ │ │ │ └── mysubscript.cpython-39.pyc │ │ │ └── mysubscript.py │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-310.pyc │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── __init__.cpython-39.pyc │ │ │ ├── some_main_script.cpython-310.pyc │ │ │ ├── some_main_script.cpython-36.pyc │ │ │ └── some_main_script.cpython-39.pyc │ │ └── some_main_script.py │ ├── mymodule.py │ └── myprogram.py ├── 01_modules │ ├── Explanation.txt │ ├── __pycache__ │ │ ├── one.cpython-310.pyc │ │ ├── one.cpython-311.pyc │ │ ├── one.cpython-312.pyc │ │ └── one.cpython-39.pyc │ ├── one.py │ └── two.py ├── Useful_Info_Notebook.ipynb └── structure.txt ├── 06-Errors and Exception Handling ├── 01-Errors and Exceptions Handling.ipynb ├── solution_task_01.py └── task.txt ├── 07-Streamlit ├── calculator.py ├── cheat_sheet.py ├── countdown_timer.py ├── flames.py ├── logomark_website.png ├── main.py ├── multipage_streamlit_application │ ├── __pycache__ │ │ └── pages.cpython-310.pyc │ ├── app.py │ └── pages.py └── rock_paper_scissors │ ├── __pycache__ │ └── game.cpython-310.pyc │ ├── app.py │ └── game.py ├── 08-File_folder_Date ├── 01- File-Handling.ipynb ├── 02-Folder-Handling.ipynb ├── 03-Datetime-Module.ipynb ├── dummy_folder │ └── new_directory │ │ └── dummy.txt ├── example.txt ├── output.txt ├── scenario.txt ├── solution_task_01.py ├── task.txt └── test.txt ├── 09-Numpy ├── cheatsheet.txt └── numpy.ipynb ├── 10-Pandas ├── data │ ├── Iris.csv │ ├── nyc_weather.csv │ ├── online_store_sales.csv │ ├── retail_store_sales.xlsx │ ├── temp │ │ ├── new_csv_file.csv │ │ ├── new_csv_file_no_index.csv │ │ ├── new_excel_file.xlsx │ │ ├── new_excel_file_noIndex.xlsx │ │ ├── new_iris.csv │ │ ├── new_iris_no_index.csv │ │ └── updated_weather_data.xlsx │ └── weather_data.xlsx ├── image │ ├── 00_pandas.jpg │ ├── 01_table_dataframe.PNG │ ├── 02_io_readwrite.PNG │ ├── 03_reduction.PNG │ ├── 04_iris_setosa.jpg │ ├── 05_iris_versicolor.jpg │ ├── 06_iris_virginica.jpg │ ├── 07_subset_columns.PNG │ └── 08_newcolumn.PNG └── pandas_basic.ipynb ├── 11-SQL ├── project │ └── architecutre.md ├── sql │ ├── Cloning in SQL.docx │ ├── DML,DCL, Table create,delete,drop...docx │ ├── IN and Between.docx │ ├── Mysql - DataType.docx │ ├── SQL - clauses.docx │ ├── Stored Procedure.docx │ ├── null,like,min,update.docx │ └── sql joins.docx ├── sqlite │ ├── database.db │ └── sqlite.ipynb └── superstore.xlsx ├── 13-Threading ├── image.png └── threading.ipynb ├── 14-Unit testing ├── 02-Unit Testing.ipynb ├── __pycache__ │ └── cap.cpython-312.pyc ├── cap.py ├── simple1.py ├── test.py └── test_cap.py ├── 15-Decorator ├── Generators.ipynb ├── Iterators.ipynb ├── decorator.ipynb └── large_file.txt ├── 16-Counters,OS,Regex ├── 00-Collections-Module.ipynb ├── 01-Opening-and-Reading-Files-Folders.ipynb ├── 02-Overview-of-Regular-Expressions.ipynb └── subfolder │ └── practice.txt ├── 17-Flask ├── 01_path_query_parameter.py ├── __pycache__ │ ├── package.cpython-38.pyc │ ├── package.cpython-39.pyc │ └── package_1.cpython-38.pyc ├── app.py ├── basic_app.py ├── flask.ipynb ├── form │ ├── form.py │ ├── static │ │ └── hello.js │ └── templates │ │ ├── result.html │ │ └── student.html ├── form_args_get │ ├── app.py │ └── templates │ │ └── index.html ├── form_args_post │ ├── app.py │ └── templates │ │ └── form.html ├── jinja_tem │ └── templates │ │ ├── base.html │ │ └── child.html ├── swagger_sample │ └── app.py └── web_api │ ├── images │ ├── .ipynb_checkpoints │ │ ├── methods-checkpoint.png │ │ └── status_code_1-checkpoint.png │ ├── anatomy_url.PNG │ ├── methods.png │ ├── status_code_1.png │ └── status_code_2.png │ └── web_api.ipynb ├── Flask_application └── crudapp │ ├── __pycache__ │ ├── create_db.cpython-310.pyc │ └── create_db.cpython-39.pyc │ ├── app.py │ ├── create_db.py │ ├── db_web.db │ └── templates │ ├── add_user.html │ ├── edit_user.html │ ├── index.html │ └── layout.html ├── Flowchart.pdf ├── Installing Anaconda on windows.docx ├── Pesudocode.docx ├── README.md ├── Section-1.pptx ├── beginners_python_cheat_sheet.pdf ├── cheatsheet.pdf ├── cheatsheet_01.pdf ├── console_application ├── __pycache__ │ ├── theater_info.cpython-310.pyc │ ├── theater_info.cpython-38.pyc │ ├── theater_info.cpython-39.pyc │ ├── user_info.cpython-310.pyc │ ├── user_info.cpython-38.pyc │ └── user_info.cpython-39.pyc ├── beginners_python_cheat_sheet.pdf ├── main.py ├── project requirements.txt ├── theater_info.py └── user_info.py ├── db_web.db ├── mongodb ├── basic_app │ └── app.py ├── basic_crud │ └── crud_app.py ├── crud_app │ ├── app.py │ ├── static │ │ ├── script.js │ │ └── styles.css │ └── templates │ │ └── index.html ├── insert_data.txt ├── mongodb.ipynb ├── objectId.jpg └── sqlvsmongodb.PNG ├── programming questions.txt ├── resources.txt ├── resume_template.docx ├── sample.ipynb └── topic_wise_questions.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | environment 2 | *pyc -------------------------------------------------------------------------------- /00-Python Object and Data Structure Basics/.ipynb_checkpoints/01-Dynamic typing and type()-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## Dynamic Typing\n", 8 | "\n", 9 | "Python uses *dynamic typing*, meaning you can reassign variables to different data types. This makes Python very flexible in assigning data types; it differs from other languages that are *statically typed*." 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 1, 15 | "metadata": { 16 | "collapsed": true 17 | }, 18 | "outputs": [], 19 | "source": [ 20 | "my_dogs = 2" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": 2, 26 | "metadata": {}, 27 | "outputs": [ 28 | { 29 | "data": { 30 | "text/plain": [ 31 | "2" 32 | ] 33 | }, 34 | "execution_count": 2, 35 | "metadata": {}, 36 | "output_type": "execute_result" 37 | } 38 | ], 39 | "source": [ 40 | "my_dogs" 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": 3, 46 | "metadata": { 47 | "collapsed": true 48 | }, 49 | "outputs": [], 50 | "source": [ 51 | "my_dogs = ['Sammy', 'Frankie']" 52 | ] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "execution_count": 4, 57 | "metadata": {}, 58 | "outputs": [ 59 | { 60 | "data": { 61 | "text/plain": [ 62 | "['Sammy', 'Frankie']" 63 | ] 64 | }, 65 | "execution_count": 4, 66 | "metadata": {}, 67 | "output_type": "execute_result" 68 | } 69 | ], 70 | "source": [ 71 | "my_dogs" 72 | ] 73 | }, 74 | { 75 | "cell_type": "markdown", 76 | "metadata": {}, 77 | "source": [ 78 | "### Pros and Cons of Dynamic Typing\n", 79 | "#### Pros of Dynamic Typing\n", 80 | "* very easy to work with\n", 81 | "* faster development time\n", 82 | "\n", 83 | "#### Cons of Dynamic Typing\n", 84 | "* may result in unexpected bugs!\n", 85 | "* you need to be aware of `type()`" 86 | ] 87 | }, 88 | { 89 | "cell_type": "markdown", 90 | "metadata": {}, 91 | "source": [ 92 | "## Determining variable type with `type()`\n", 93 | "You can check what type of object is assigned to a variable using Python's built-in `type()` function. Common data types include:\n", 94 | "* **int** (for integer)\n", 95 | "* **float**\n", 96 | "* **str** (for string)\n", 97 | "* **list**\n", 98 | "* **tuple**\n", 99 | "* **dict** (for dictionary)\n", 100 | "* **set**\n", 101 | "* **bool** (for Boolean True/False)" 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "execution_count": 16, 107 | "metadata": {}, 108 | "outputs": [ 109 | { 110 | "data": { 111 | "text/plain": [ 112 | "int" 113 | ] 114 | }, 115 | "execution_count": 16, 116 | "metadata": {}, 117 | "output_type": "execute_result" 118 | } 119 | ], 120 | "source": [ 121 | "type(a)" 122 | ] 123 | }, 124 | { 125 | "cell_type": "code", 126 | "execution_count": 17, 127 | "metadata": { 128 | "collapsed": true 129 | }, 130 | "outputs": [], 131 | "source": [ 132 | "a = (1,2)" 133 | ] 134 | }, 135 | { 136 | "cell_type": "code", 137 | "execution_count": 18, 138 | "metadata": {}, 139 | "outputs": [ 140 | { 141 | "data": { 142 | "text/plain": [ 143 | "tuple" 144 | ] 145 | }, 146 | "execution_count": 18, 147 | "metadata": {}, 148 | "output_type": "execute_result" 149 | } 150 | ], 151 | "source": [ 152 | "type(a)" 153 | ] 154 | } 155 | ], 156 | "metadata": { 157 | "kernelspec": { 158 | "display_name": "Python 3", 159 | "language": "python", 160 | "name": "python3" 161 | }, 162 | "language_info": { 163 | "codemirror_mode": { 164 | "name": "ipython", 165 | "version": 3 166 | }, 167 | "file_extension": ".py", 168 | "mimetype": "text/x-python", 169 | "name": "python", 170 | "nbconvert_exporter": "python", 171 | "pygments_lexer": "ipython3", 172 | "version": "3.8.3" 173 | } 174 | }, 175 | "nbformat": 4, 176 | "nbformat_minor": 2 177 | } 178 | -------------------------------------------------------------------------------- /00-Python Object and Data Structure Basics/.ipynb_checkpoints/Untitled-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [], 3 | "metadata": {}, 4 | "nbformat": 4, 5 | "nbformat_minor": 5 6 | } 7 | -------------------------------------------------------------------------------- /00-Python Object and Data Structure Basics/01-Dynamic typing and type().ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## Dynamic Typing\n", 8 | "\n", 9 | "Python uses *dynamic typing*, meaning you can reassign variables to different data types. This makes Python very flexible in assigning data types; it differs from other languages that are *statically typed*." 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 1, 15 | "metadata": { 16 | "collapsed": true 17 | }, 18 | "outputs": [], 19 | "source": [ 20 | "value = 2 #32bit #assign\n", 21 | "value = 2.3 #646bit #reassign\n" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": 2, 27 | "metadata": {}, 28 | "outputs": [ 29 | { 30 | "data": { 31 | "text/plain": [ 32 | "2" 33 | ] 34 | }, 35 | "execution_count": 2, 36 | "metadata": {}, 37 | "output_type": "execute_result" 38 | } 39 | ], 40 | "source": [ 41 | "print(value)" 42 | ] 43 | }, 44 | { 45 | "cell_type": "markdown", 46 | "metadata": {}, 47 | "source": [ 48 | "### Pros and Cons of Dynamic Typing\n", 49 | "#### Pros of Dynamic Typing\n", 50 | "* very easy to work with\n", 51 | "* faster development time\n", 52 | "\n", 53 | "#### Cons of Dynamic Typing\n", 54 | "* may result in unexpected bugs!\n", 55 | "* you need to be aware of `type()`" 56 | ] 57 | }, 58 | { 59 | "cell_type": "markdown", 60 | "metadata": {}, 61 | "source": [ 62 | "## Determining variable type with `type()`\n", 63 | "You can check what type of object is assigned to a variable using Python's built-in `type()` function. Common data types include:\n", 64 | "* **int** (for integer)\n", 65 | "* **float**\n", 66 | "* **str** (for string)\n", 67 | "* **list**\n", 68 | "* **tuple**\n", 69 | "* **dict** (for dictionary)\n", 70 | "* **set**\n", 71 | "* **bool** (for Boolean True/False)" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 1, 77 | "metadata": {}, 78 | "outputs": [ 79 | { 80 | "name": "stdout", 81 | "output_type": "stream", 82 | "text": [ 83 | "\n" 84 | ] 85 | } 86 | ], 87 | "source": [ 88 | "a = 5\n", 89 | "print(type(a)) " 90 | ] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "execution_count": 8, 95 | "metadata": {}, 96 | "outputs": [ 97 | { 98 | "name": "stdout", 99 | "output_type": "stream", 100 | "text": [ 101 | "\n" 102 | ] 103 | } 104 | ], 105 | "source": [ 106 | "a = 5.8\n", 107 | "print(type(a))" 108 | ] 109 | }, 110 | { 111 | "cell_type": "code", 112 | "execution_count": 5, 113 | "metadata": { 114 | "collapsed": true 115 | }, 116 | "outputs": [], 117 | "source": [ 118 | "a = (1,2)\n", 119 | "print(type(a))" 120 | ] 121 | } 122 | ], 123 | "metadata": { 124 | "kernelspec": { 125 | "display_name": "Python 3.9.7 ('base')", 126 | "language": "python", 127 | "name": "python3" 128 | }, 129 | "language_info": { 130 | "codemirror_mode": { 131 | "name": "ipython", 132 | "version": 3 133 | }, 134 | "file_extension": ".py", 135 | "mimetype": "text/x-python", 136 | "name": "python", 137 | "nbconvert_exporter": "python", 138 | "pygments_lexer": "ipython3", 139 | "version": "3.9.7" 140 | }, 141 | "vscode": { 142 | "interpreter": { 143 | "hash": "adbf8baac3fd83462ba4d3cf155237b9080954f140b6d8291bc95ec68b06c358" 144 | } 145 | } 146 | }, 147 | "nbformat": 4, 148 | "nbformat_minor": 2 149 | } 150 | -------------------------------------------------------------------------------- /00-Python Object and Data Structure Basics/advance/04-Advanced Dictionaries.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Advanced Dictionaries" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "## Dictionary Comprehensions\n", 15 | "\n", 16 | "Just like List Comprehensions, Dictionary Data Types also support their own version of comprehension for quick creation. It is not as commonly used as List Comprehensions, but the syntax is:" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 2, 22 | "metadata": {}, 23 | "outputs": [ 24 | { 25 | "data": { 26 | "text/plain": [ 27 | "{0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81}" 28 | ] 29 | }, 30 | "execution_count": 2, 31 | "metadata": {}, 32 | "output_type": "execute_result" 33 | } 34 | ], 35 | "source": [ 36 | "{x:x**2 for x in range(10)}" 37 | ] 38 | }, 39 | { 40 | "cell_type": "markdown", 41 | "metadata": {}, 42 | "source": [ 43 | "One of the reasons it is not as common is the difficulty in structuring key names that are not based off the values." 44 | ] 45 | }, 46 | { 47 | "cell_type": "markdown", 48 | "metadata": {}, 49 | "source": [ 50 | "## Iteration over keys, values, and items\n", 51 | "Dictionaries can be iterated over using the keys(), values() and items() methods. For example:" 52 | ] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "execution_count": 3, 57 | "metadata": {}, 58 | "outputs": [], 59 | "source": [ 60 | "d = {'k1':1,'k2':2}" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": 4, 66 | "metadata": {}, 67 | "outputs": [ 68 | { 69 | "name": "stdout", 70 | "output_type": "stream", 71 | "text": [ 72 | "k1\n", 73 | "k2\n" 74 | ] 75 | } 76 | ], 77 | "source": [ 78 | "for k in d.keys():\n", 79 | " print(k)" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": 5, 85 | "metadata": {}, 86 | "outputs": [ 87 | { 88 | "name": "stdout", 89 | "output_type": "stream", 90 | "text": [ 91 | "1\n", 92 | "2\n" 93 | ] 94 | } 95 | ], 96 | "source": [ 97 | "for v in d.values():\n", 98 | " print(v)" 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": 6, 104 | "metadata": {}, 105 | "outputs": [ 106 | { 107 | "name": "stdout", 108 | "output_type": "stream", 109 | "text": [ 110 | "('k1', 1)\n", 111 | "('k2', 2)\n" 112 | ] 113 | } 114 | ], 115 | "source": [ 116 | "for item in d.items():\n", 117 | " print(item)" 118 | ] 119 | } 120 | ], 121 | "metadata": { 122 | "kernelspec": { 123 | "display_name": "Python 3.9.0 64-bit", 124 | "language": "python", 125 | "name": "python3" 126 | }, 127 | "language_info": { 128 | "codemirror_mode": { 129 | "name": "ipython", 130 | "version": 3 131 | }, 132 | "file_extension": ".py", 133 | "mimetype": "text/x-python", 134 | "name": "python", 135 | "nbconvert_exporter": "python", 136 | "pygments_lexer": "ipython3", 137 | "version": "3.10.9" 138 | }, 139 | "vscode": { 140 | "interpreter": { 141 | "hash": "898a32a18de38b8e8f8a4f70c1b651867488d5b078cf19a2942249b7e062bc27" 142 | } 143 | } 144 | }, 145 | "nbformat": 4, 146 | "nbformat_minor": 1 147 | } 148 | -------------------------------------------------------------------------------- /01-Python Comparison Operators/.ipynb_checkpoints/02-Chained Comparison Operators-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Chained Comparison Operators\n", 8 | "\n", 9 | "An interesting feature of Python is the ability to *chain* multiple comparisons to perform a more complex test. You can use these chained comparisons as shorthand for larger Boolean Expressions.\n", 10 | "\n", 11 | "two other important statements in Python: **and** and **or**.\n", 12 | "\n" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 1, 18 | "metadata": {}, 19 | "outputs": [ 20 | { 21 | "data": { 22 | "text/plain": [ 23 | "True" 24 | ] 25 | }, 26 | "execution_count": 1, 27 | "metadata": {}, 28 | "output_type": "execute_result" 29 | } 30 | ], 31 | "source": [ 32 | "1 < 2 < 3" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "metadata": {}, 38 | "source": [ 39 | "The above statement checks if 1 was less than 2 **and** if 2 was less than 3. We could have written this using an **and** statement in Python:" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 2, 45 | "metadata": {}, 46 | "outputs": [ 47 | { 48 | "data": { 49 | "text/plain": [ 50 | "True" 51 | ] 52 | }, 53 | "execution_count": 2, 54 | "metadata": {}, 55 | "output_type": "execute_result" 56 | } 57 | ], 58 | "source": [ 59 | "1<2 and 2<3" 60 | ] 61 | }, 62 | { 63 | "cell_type": "markdown", 64 | "metadata": {}, 65 | "source": [ 66 | "The **and** is used to make sure two checks have to be true in order for the total check to be true." 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": 3, 72 | "metadata": {}, 73 | "outputs": [ 74 | { 75 | "data": { 76 | "text/plain": [ 77 | "True" 78 | ] 79 | }, 80 | "execution_count": 3, 81 | "metadata": {}, 82 | "output_type": "execute_result" 83 | } 84 | ], 85 | "source": [ 86 | "1 < 3 > 2" 87 | ] 88 | }, 89 | { 90 | "cell_type": "markdown", 91 | "metadata": {}, 92 | "source": [ 93 | "The above checks if 3 is larger than both of the other numbers, so you could use **and** to rewrite it as:" 94 | ] 95 | }, 96 | { 97 | "cell_type": "code", 98 | "execution_count": 4, 99 | "metadata": {}, 100 | "outputs": [ 101 | { 102 | "data": { 103 | "text/plain": [ 104 | "True" 105 | ] 106 | }, 107 | "execution_count": 4, 108 | "metadata": {}, 109 | "output_type": "execute_result" 110 | } 111 | ], 112 | "source": [ 113 | "1<3 and 3>2" 114 | ] 115 | }, 116 | { 117 | "cell_type": "markdown", 118 | "metadata": {}, 119 | "source": [ 120 | "It's important to note that Python is checking both instances of the comparisons. We can also use **or** to write comparisons in Python. For example:" 121 | ] 122 | }, 123 | { 124 | "cell_type": "code", 125 | "execution_count": 5, 126 | "metadata": {}, 127 | "outputs": [ 128 | { 129 | "data": { 130 | "text/plain": [ 131 | "True" 132 | ] 133 | }, 134 | "execution_count": 5, 135 | "metadata": {}, 136 | "output_type": "execute_result" 137 | } 138 | ], 139 | "source": [ 140 | "1==2 or 2<3" 141 | ] 142 | }, 143 | { 144 | "cell_type": "markdown", 145 | "metadata": {}, 146 | "source": [ 147 | "Note how it was true; this is because with the **or** operator, we only need one *or* the other to be true." 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": 6, 153 | "metadata": {}, 154 | "outputs": [ 155 | { 156 | "data": { 157 | "text/plain": [ 158 | "True" 159 | ] 160 | }, 161 | "execution_count": 6, 162 | "metadata": {}, 163 | "output_type": "execute_result" 164 | } 165 | ], 166 | "source": [ 167 | "1==1 or 100==1" 168 | ] 169 | } 170 | ], 171 | "metadata": { 172 | "kernelspec": { 173 | "display_name": "Python 3", 174 | "language": "python", 175 | "name": "python3" 176 | }, 177 | "language_info": { 178 | "codemirror_mode": { 179 | "name": "ipython", 180 | "version": 3 181 | }, 182 | "file_extension": ".py", 183 | "mimetype": "text/x-python", 184 | "name": "python", 185 | "nbconvert_exporter": "python", 186 | "pygments_lexer": "ipython3", 187 | "version": "3.8.3" 188 | } 189 | }, 190 | "nbformat": 4, 191 | "nbformat_minor": 1 192 | } 193 | -------------------------------------------------------------------------------- /02-Python Statements/.ipynb_checkpoints/01-Introduction to Python Statements-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "slideshow": { 7 | "slide_type": "slide" 8 | } 9 | }, 10 | "source": [ 11 | "# Introduction to Python Statements\n", 12 | "\n", 13 | "In this lecture we will be doing a quick overview of Python Statements. This lecture will emphasize differences between Python and other languages such as C++. \n", 14 | "\n", 15 | "There are two reasons we take this approach for learning the context of Python Statements:\n", 16 | "\n", 17 | " 1.) If you are coming from a different language this will rapidly accelerate your understanding of Python.\n", 18 | " 2.) Learning about statements will allow you to be able to read other languages more easily in the future." 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "metadata": { 24 | "slideshow": { 25 | "slide_type": "slide" 26 | } 27 | }, 28 | "source": [ 29 | "## Python vs Other Languages\n", 30 | "\n", 31 | "Let's create a simple statement that says:\n", 32 | "\"If a is greater than b, assign 2 to a and 4 to b\"\n", 33 | "\n", 34 | "Take a look at these two if statements (we will learn about building out if statements soon).\n", 35 | "\n", 36 | "**Version 1 (Other Languages)**\n", 37 | "\n", 38 | " if (a>b){\n", 39 | " a = 2;\n", 40 | " b = 4;\n", 41 | " }\n", 42 | " \n", 43 | "**Version 2 (Python)** \n", 44 | "\n", 45 | " if a>b:\n", 46 | " a = 2\n", 47 | " b = 4" 48 | ] 49 | }, 50 | { 51 | "cell_type": "markdown", 52 | "metadata": {}, 53 | "source": [ 54 | "You'll notice that Python is less cluttered and much more readable than the first version. How does Python manage this?\n", 55 | "\n", 56 | "Let's walk through the main differences:\n", 57 | "\n", 58 | "Python gets rid of () and {} by incorporating two main factors: a *colon* and *whitespace*. The statement is ended with a colon, and whitespace is used (indentation) to describe what takes place in case of the statement.\n", 59 | "\n", 60 | "Another major difference is the lack of semicolons in Python. Semicolons are used to denote statement endings in many other languages, but in Python, the end of a line is the same as the end of a statement.\n", 61 | "\n", 62 | "Lastly, to end this brief overview of differences, let's take a closer look at indentation syntax in Python vs other languages:\n", 63 | "\n", 64 | "## Indentation\n", 65 | "\n", 66 | "Here is some pseudo-code to indicate the use of whitespace and indentation in Python:\n", 67 | "\n", 68 | "**Other Languages**\n", 69 | "\n", 70 | " if (x)\n", 71 | " if(y)\n", 72 | " code-statement;\n", 73 | " else\n", 74 | " another-code-statement;\n", 75 | " \n", 76 | "**Python**\n", 77 | " \n", 78 | " if x:\n", 79 | " if y:\n", 80 | " code-statement\n", 81 | " else:\n", 82 | " another-code-statement" 83 | ] 84 | }, 85 | { 86 | "cell_type": "markdown", 87 | "metadata": {}, 88 | "source": [ 89 | "Note how Python is so heavily driven by code indentation and whitespace. This means that code readability is a core part of the design of the Python language.\n", 90 | "\n", 91 | "Now let's start diving deeper by coding these sort of statements in Python!" 92 | ] 93 | } 94 | ], 95 | "metadata": { 96 | "kernelspec": { 97 | "display_name": "Python 3", 98 | "language": "python", 99 | "name": "python3" 100 | }, 101 | "language_info": { 102 | "codemirror_mode": { 103 | "name": "ipython", 104 | "version": 3 105 | }, 106 | "file_extension": ".py", 107 | "mimetype": "text/x-python", 108 | "name": "python", 109 | "nbconvert_exporter": "python", 110 | "pygments_lexer": "ipython3", 111 | "version": "3.8.3" 112 | } 113 | }, 114 | "nbformat": 4, 115 | "nbformat_minor": 1 116 | } 117 | -------------------------------------------------------------------------------- /02-Python Statements/.ipynb_checkpoints/05-range()-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# range()\n", 8 | "\n", 9 | "In this short lecture we will be discussing the range function. We haven't developed a very deep level of knowledge of functions yet, but we can understand the basics of this simple (but extremely useful!) function.\n", 10 | "\n", 11 | "range() allows us to generate a list of numbers ranging from a starting point *up to but not including* an ending point. We can also specify step size. Let's walk through a few examples:" 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": 1, 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "text/plain": [ 22 | "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]" 23 | ] 24 | }, 25 | "execution_count": 1, 26 | "metadata": {}, 27 | "output_type": "execute_result" 28 | } 29 | ], 30 | "source": [ 31 | "list(range(0,10))" 32 | ] 33 | }, 34 | { 35 | "cell_type": "markdown", 36 | "metadata": {}, 37 | "source": [ 38 | "To see the output of range() as a list, we *cast* it as a list as shown above. This is rarely done, as normally range is used in for loops." 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": 6, 44 | "metadata": {}, 45 | "outputs": [ 46 | { 47 | "data": { 48 | "text/plain": [ 49 | "range" 50 | ] 51 | }, 52 | "execution_count": 6, 53 | "metadata": {}, 54 | "output_type": "execute_result" 55 | } 56 | ], 57 | "source": [ 58 | "# Range objects\n", 59 | "x =range(0,10)\n", 60 | "type(x)" 61 | ] 62 | }, 63 | { 64 | "cell_type": "markdown", 65 | "metadata": {}, 66 | "source": [ 67 | "range objects behave like *generators* - they don't produce every value all at once, but deliver them one at a time as needed. Behind the scenes this saves on overhead since you're not storing every value, and it improves the performance of your code! We will learn more about generators later on in the course." 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": 3, 73 | "metadata": {}, 74 | "outputs": [], 75 | "source": [ 76 | "start = 0 #Default\n", 77 | "stop = 20 \n", 78 | "x = range(start,stop)" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": 4, 84 | "metadata": {}, 85 | "outputs": [ 86 | { 87 | "data": { 88 | "text/plain": [ 89 | "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]" 90 | ] 91 | }, 92 | "execution_count": 4, 93 | "metadata": {}, 94 | "output_type": "execute_result" 95 | } 96 | ], 97 | "source": [ 98 | "list(x)" 99 | ] 100 | }, 101 | { 102 | "cell_type": "markdown", 103 | "metadata": {}, 104 | "source": [ 105 | "Great! Notice how it went *up to* 20, but doesn't actually produce 20. Just like in indexing. What about step size? We can specify that as a third argument:" 106 | ] 107 | }, 108 | { 109 | "cell_type": "code", 110 | "execution_count": 5, 111 | "metadata": {}, 112 | "outputs": [ 113 | { 114 | "data": { 115 | "text/plain": [ 116 | "[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]" 117 | ] 118 | }, 119 | "execution_count": 5, 120 | "metadata": {}, 121 | "output_type": "execute_result" 122 | } 123 | ], 124 | "source": [ 125 | "x = range(start,stop,2)\n", 126 | "\n", 127 | "#Show\n", 128 | "list(x)" 129 | ] 130 | }, 131 | { 132 | "cell_type": "markdown", 133 | "metadata": { 134 | "collapsed": true 135 | }, 136 | "source": [ 137 | "You should now have a good understanding of how to use range() in Python." 138 | ] 139 | } 140 | ], 141 | "metadata": { 142 | "kernelspec": { 143 | "display_name": "Python 3", 144 | "language": "python", 145 | "name": "python3" 146 | }, 147 | "language_info": { 148 | "codemirror_mode": { 149 | "name": "ipython", 150 | "version": 3 151 | }, 152 | "file_extension": ".py", 153 | "mimetype": "text/x-python", 154 | "name": "python", 155 | "nbconvert_exporter": "python", 156 | "pygments_lexer": "ipython3", 157 | "version": "3.6.2" 158 | } 159 | }, 160 | "nbformat": 4, 161 | "nbformat_minor": 1 162 | } 163 | -------------------------------------------------------------------------------- /02-Python Statements/.ipynb_checkpoints/06-List Comprehensions-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# List Comprehensions\n", 10 | "\n", 11 | "In addition to sequence operations and list methods, Python includes a more advanced operation called a list comprehension.\n", 12 | "\n", 13 | "List comprehensions allow us to build out lists using a different notation. \n", 14 | "## Example 1" 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": 1, 20 | "metadata": { 21 | "collapsed": true 22 | }, 23 | "outputs": [], 24 | "source": [ 25 | "# Grab every letter in string\n", 26 | "lst = [x for x in 'word']" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "metadata": {}, 33 | "outputs": [ 34 | { 35 | "data": { 36 | "text/plain": [ 37 | "['w', 'o', 'r', 'd']" 38 | ] 39 | }, 40 | "execution_count": 2, 41 | "metadata": {}, 42 | "output_type": "execute_result" 43 | } 44 | ], 45 | "source": [ 46 | "# Check\n", 47 | "lst" 48 | ] 49 | }, 50 | { 51 | "cell_type": "markdown", 52 | "metadata": {}, 53 | "source": [ 54 | "\n", 55 | "\n", 56 | "## Example 2\n", 57 | "\n", 58 | "mathematical notation : x^2 : x in { 0,1,2...10 } " 59 | ] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "execution_count": 3, 64 | "metadata": { 65 | "collapsed": true 66 | }, 67 | "outputs": [], 68 | "source": [ 69 | "# Square numbers in range and turn into list\n", 70 | "lst = [x**2 for x in range(0,11)]" 71 | ] 72 | }, 73 | { 74 | "cell_type": "code", 75 | "execution_count": 4, 76 | "metadata": {}, 77 | "outputs": [ 78 | { 79 | "data": { 80 | "text/plain": [ 81 | "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100]" 82 | ] 83 | }, 84 | "execution_count": 4, 85 | "metadata": {}, 86 | "output_type": "execute_result" 87 | } 88 | ], 89 | "source": [ 90 | "lst" 91 | ] 92 | }, 93 | { 94 | "cell_type": "markdown", 95 | "metadata": {}, 96 | "source": [ 97 | "## Example 3\n", 98 | "add in if statements:" 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": 5, 104 | "metadata": { 105 | "collapsed": true 106 | }, 107 | "outputs": [], 108 | "source": [ 109 | "# Check for even numbers in a range\n", 110 | "lst = [x for x in range(11) if x % 2 == 0]" 111 | ] 112 | }, 113 | { 114 | "cell_type": "code", 115 | "execution_count": 6, 116 | "metadata": {}, 117 | "outputs": [ 118 | { 119 | "data": { 120 | "text/plain": [ 121 | "[0, 2, 4, 6, 8, 10]" 122 | ] 123 | }, 124 | "execution_count": 6, 125 | "metadata": {}, 126 | "output_type": "execute_result" 127 | } 128 | ], 129 | "source": [ 130 | "lst" 131 | ] 132 | }, 133 | { 134 | "cell_type": "markdown", 135 | "metadata": {}, 136 | "source": [ 137 | "## Example 4\n", 138 | "complicated arithmetic:" 139 | ] 140 | }, 141 | { 142 | "cell_type": "code", 143 | "execution_count": 7, 144 | "metadata": {}, 145 | "outputs": [ 146 | { 147 | "data": { 148 | "text/plain": [ 149 | "[32.0, 50.0, 68.18, 94.1]" 150 | ] 151 | }, 152 | "execution_count": 7, 153 | "metadata": {}, 154 | "output_type": "execute_result" 155 | } 156 | ], 157 | "source": [ 158 | "# Convert Celsius to Fahrenheit\n", 159 | "celsius = [0,10,20.1,34.5]\n", 160 | "\n", 161 | "fahrenheit = [((9/5)*temp + 32) for temp in celsius ]\n", 162 | "\n", 163 | "fahrenheit" 164 | ] 165 | }, 166 | { 167 | "cell_type": "markdown", 168 | "metadata": {}, 169 | "source": [ 170 | "## Example 5\n", 171 | "We can also perform nested list comprehensions" 172 | ] 173 | }, 174 | { 175 | "cell_type": "code", 176 | "execution_count": 8, 177 | "metadata": {}, 178 | "outputs": [ 179 | { 180 | "data": { 181 | "text/plain": [ 182 | "[0, 1, 16, 81, 256, 625, 1296, 2401, 4096, 6561, 10000]" 183 | ] 184 | }, 185 | "execution_count": 8, 186 | "metadata": {}, 187 | "output_type": "execute_result" 188 | } 189 | ], 190 | "source": [ 191 | "lst = [ x**2 for x in [x**2 for x in range(11)]]\n", 192 | "lst" 193 | ] 194 | } 195 | ], 196 | "metadata": { 197 | "kernelspec": { 198 | "display_name": "Python 3", 199 | "language": "python", 200 | "name": "python3" 201 | }, 202 | "language_info": { 203 | "codemirror_mode": { 204 | "name": "ipython", 205 | "version": 3 206 | }, 207 | "file_extension": ".py", 208 | "mimetype": "text/x-python", 209 | "name": "python", 210 | "nbconvert_exporter": "python", 211 | "pygments_lexer": "ipython3", 212 | "version": "3.8.3" 213 | } 214 | }, 215 | "nbformat": 4, 216 | "nbformat_minor": 1 217 | } 218 | -------------------------------------------------------------------------------- /02-Python Statements/.ipynb_checkpoints/07-Statements Assessment Test-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "___\n", 8 | "\n", 9 | "\n", 10 | "___\n", 11 | "
Content Copyright by Pierian Data
" 12 | ] 13 | }, 14 | { 15 | "cell_type": "markdown", 16 | "metadata": { 17 | "collapsed": true 18 | }, 19 | "source": [ 20 | "# Statements Assessment Test\n", 21 | "Let's test your knowledge!" 22 | ] 23 | }, 24 | { 25 | "cell_type": "markdown", 26 | "metadata": {}, 27 | "source": [ 28 | "_____\n", 29 | "**Use for, .split(), and if to create a Statement that will print out words that start with 's':**" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": null, 35 | "metadata": { 36 | "collapsed": true 37 | }, 38 | "outputs": [], 39 | "source": [ 40 | "st = 'Print only the words that start with s in this sentence'" 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": { 47 | "collapsed": true 48 | }, 49 | "outputs": [], 50 | "source": [ 51 | "#Code here" 52 | ] 53 | }, 54 | { 55 | "cell_type": "markdown", 56 | "metadata": {}, 57 | "source": [ 58 | "______\n", 59 | "**Use range() to print all the even numbers from 0 to 10.**" 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": null, 65 | "metadata": { 66 | "collapsed": true 67 | }, 68 | "outputs": [], 69 | "source": [ 70 | "#Code Here" 71 | ] 72 | }, 73 | { 74 | "cell_type": "markdown", 75 | "metadata": {}, 76 | "source": [ 77 | "___\n", 78 | "**Use a List Comprehension to create a list of all numbers between 1 and 50 that are divisible by 3.**" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": null, 84 | "metadata": { 85 | "collapsed": true 86 | }, 87 | "outputs": [], 88 | "source": [ 89 | "#Code in this cell\n", 90 | "[]" 91 | ] 92 | }, 93 | { 94 | "cell_type": "markdown", 95 | "metadata": {}, 96 | "source": [ 97 | "_____\n", 98 | "**Go through the string below and if the length of a word is even print \"even!\"**" 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": null, 104 | "metadata": { 105 | "collapsed": true 106 | }, 107 | "outputs": [], 108 | "source": [ 109 | "st = 'Print every word in this sentence that has an even number of letters'" 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": null, 115 | "metadata": { 116 | "collapsed": true 117 | }, 118 | "outputs": [], 119 | "source": [ 120 | "#Code in this cell" 121 | ] 122 | }, 123 | { 124 | "cell_type": "markdown", 125 | "metadata": {}, 126 | "source": [ 127 | "____\n", 128 | "**Write a program that prints the integers from 1 to 100. But for multiples of three print \"Fizz\" instead of the number, and for the multiples of five print \"Buzz\". For numbers which are multiples of both three and five print \"FizzBuzz\".**" 129 | ] 130 | }, 131 | { 132 | "cell_type": "code", 133 | "execution_count": null, 134 | "metadata": { 135 | "collapsed": true 136 | }, 137 | "outputs": [], 138 | "source": [ 139 | "#Code in this cell" 140 | ] 141 | }, 142 | { 143 | "cell_type": "markdown", 144 | "metadata": {}, 145 | "source": [ 146 | "____\n", 147 | "**Use List Comprehension to create a list of the first letters of every word in the string below:**" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": null, 153 | "metadata": { 154 | "collapsed": true 155 | }, 156 | "outputs": [], 157 | "source": [ 158 | "st = 'Create a list of the first letters of every word in this string'" 159 | ] 160 | }, 161 | { 162 | "cell_type": "code", 163 | "execution_count": null, 164 | "metadata": { 165 | "collapsed": true 166 | }, 167 | "outputs": [], 168 | "source": [ 169 | "#Code in this cell" 170 | ] 171 | }, 172 | { 173 | "cell_type": "markdown", 174 | "metadata": {}, 175 | "source": [ 176 | "### Great Job!" 177 | ] 178 | } 179 | ], 180 | "metadata": { 181 | "kernelspec": { 182 | "display_name": "Python 3", 183 | "language": "python", 184 | "name": "python3" 185 | }, 186 | "language_info": { 187 | "codemirror_mode": { 188 | "name": "ipython", 189 | "version": 3 190 | }, 191 | "file_extension": ".py", 192 | "mimetype": "text/x-python", 193 | "name": "python", 194 | "nbconvert_exporter": "python", 195 | "pygments_lexer": "ipython3", 196 | "version": "3.6.6" 197 | } 198 | }, 199 | "nbformat": 4, 200 | "nbformat_minor": 1 201 | } 202 | -------------------------------------------------------------------------------- /02-Python Statements/.ipynb_checkpoints/09-Guessing Game Challenge-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Guessing Game Challenge\n", 8 | "\n", 9 | "Let's use `while` loops to create a guessing game.\n", 10 | "\n", 11 | "The Challenge:\n", 12 | "\n", 13 | "Write a program that picks a random integer from 1 to 100, and has players guess the number. The rules are:\n", 14 | "\n", 15 | "1. If a player's guess is less than 1 or greater than 100, say \"OUT OF BOUNDS\"\n", 16 | "2. On a player's first turn, if their guess is\n", 17 | " * within 10 of the number, return \"WARM!\"\n", 18 | " * further than 10 away from the number, return \"COLD!\"\n", 19 | "3. On all subsequent turns, if a guess is \n", 20 | " * closer to the number than the previous guess return \"WARMER!\"\n", 21 | " * farther from the number than the previous guess, return \"COLDER!\"\n", 22 | "4. When the player's guess equals the number, tell them they've guessed correctly *and* how many guesses it took!\n", 23 | "\n", 24 | "You can try this from scratch, or follow the steps outlined below. A separate Solution notebook has been provided. Good luck!\n" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": {}, 30 | "source": [ 31 | "#### First, pick a random integer from 1 to 100 using the random module and assign it to a variable\n", 32 | "\n", 33 | "Note: `random.randint(a,b)` returns a random integer in range `[a, b]`, including both end points." 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": null, 39 | "metadata": { 40 | "collapsed": true 41 | }, 42 | "outputs": [], 43 | "source": [] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "metadata": {}, 48 | "source": [ 49 | "#### Next, print an introduction to the game and explain the rules" 50 | ] 51 | }, 52 | { 53 | "cell_type": "code", 54 | "execution_count": null, 55 | "metadata": { 56 | "collapsed": true 57 | }, 58 | "outputs": [], 59 | "source": [] 60 | }, 61 | { 62 | "cell_type": "markdown", 63 | "metadata": {}, 64 | "source": [ 65 | "#### Create a list to store guesses\n", 66 | "\n", 67 | "Hint: zero is a good placeholder value. It's useful because it evaluates to \"False\"" 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": null, 73 | "metadata": { 74 | "collapsed": true 75 | }, 76 | "outputs": [], 77 | "source": [] 78 | }, 79 | { 80 | "cell_type": "markdown", 81 | "metadata": {}, 82 | "source": [ 83 | "#### Write a `while` loop that asks for a valid guess. Test it a few times to make sure it works." 84 | ] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "execution_count": null, 89 | "metadata": { 90 | "collapsed": true 91 | }, 92 | "outputs": [], 93 | "source": [ 94 | "while True:\n", 95 | " \n", 96 | " pass" 97 | ] 98 | }, 99 | { 100 | "cell_type": "markdown", 101 | "metadata": {}, 102 | "source": [ 103 | "#### Write a `while` loop that compares the player's guess to our number. If the player guesses correctly, break from the loop. Otherwise, tell the player if they're warmer or colder, and continue asking for guesses.\n", 104 | "\n", 105 | "Some hints:\n", 106 | "* it may help to sketch out all possible combinations on paper first!\n", 107 | "* you can use the `abs()` function to find the positive difference between two numbers\n", 108 | "* if you append all new guesses to the list, then the previous guess is given as `guesses[-2]`" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": null, 114 | "metadata": { 115 | "collapsed": true 116 | }, 117 | "outputs": [], 118 | "source": [ 119 | "while True:\n", 120 | "\n", 121 | " # we can copy the code from above to take an input\n", 122 | "\n", 123 | " pass" 124 | ] 125 | }, 126 | { 127 | "cell_type": "markdown", 128 | "metadata": {}, 129 | "source": [ 130 | "That's it! You've just programmed your first game!\n", 131 | "\n", 132 | "In the next section we'll learn how to turn some of these repetitive actions into *functions* that can be called whenever we need them." 133 | ] 134 | }, 135 | { 136 | "cell_type": "markdown", 137 | "metadata": {}, 138 | "source": [ 139 | "### Good Job!" 140 | ] 141 | } 142 | ], 143 | "metadata": { 144 | "kernelspec": { 145 | "display_name": "Python 3", 146 | "language": "python", 147 | "name": "python3" 148 | }, 149 | "language_info": { 150 | "codemirror_mode": { 151 | "name": "ipython", 152 | "version": 3 153 | }, 154 | "file_extension": ".py", 155 | "mimetype": "text/x-python", 156 | "name": "python", 157 | "nbconvert_exporter": "python", 158 | "pygments_lexer": "ipython3", 159 | "version": "3.8.3" 160 | } 161 | }, 162 | "nbformat": 4, 163 | "nbformat_minor": 2 164 | } 165 | -------------------------------------------------------------------------------- /02-Python Statements/01-Introduction to Python Statements.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "slideshow": { 7 | "slide_type": "slide" 8 | } 9 | }, 10 | "source": [ 11 | "# Introduction to Python Statements\n", 12 | "\n", 13 | "In this lecture we will be doing a quick overview of Python Statements. This lecture will emphasize differences between Python and other languages such as C++. \n", 14 | "\n", 15 | "There are two reasons we take this approach for learning the context of Python Statements:\n", 16 | "\n", 17 | " 1.) If you are coming from a different language this will rapidly accelerate your understanding of Python.\n", 18 | " 2.) Learning about statements will allow you to be able to read other languages more easily in the future." 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "metadata": { 24 | "slideshow": { 25 | "slide_type": "slide" 26 | } 27 | }, 28 | "source": [ 29 | "## Python vs Other Languages\n", 30 | "\n", 31 | "Let's create a simple statement that says:\n", 32 | "\"If a is greater than b, assign 2 to a and 4 to b\"\n", 33 | "\n", 34 | "Take a look at these two if statements (we will learn about building out if statements soon).\n", 35 | "\n", 36 | "**Version 1 (Other Languages)**\n", 37 | "\n", 38 | " if (a>b){\n", 39 | " a = 2;\n", 40 | " b = 4;\n", 41 | " }\n", 42 | " \n", 43 | "**Version 2 (Python)** \n", 44 | "\n", 45 | " if a>b:\n", 46 | " a = 2\n", 47 | " b = 4" 48 | ] 49 | }, 50 | { 51 | "cell_type": "markdown", 52 | "metadata": {}, 53 | "source": [ 54 | "You'll notice that Python is less cluttered and much more readable than the first version. How does Python manage this?\n", 55 | "\n", 56 | "Let's walk through the main differences:\n", 57 | "\n", 58 | "Python gets rid of () and {} by incorporating two main factors: a *colon* and *whitespace*. The statement is ended with a colon, and whitespace is used (indentation) to describe what takes place in case of the statement.\n", 59 | "\n", 60 | "Another major difference is the lack of semicolons in Python. Semicolons are used to denote statement endings in many other languages, but in Python, the end of a line is the same as the end of a statement.\n", 61 | "\n", 62 | "Lastly, to end this brief overview of differences, let's take a closer look at indentation syntax in Python vs other languages:\n", 63 | "\n", 64 | "## Indentation\n", 65 | "\n", 66 | "Here is some pseudo-code to indicate the use of whitespace and indentation in Python:\n", 67 | "\n", 68 | "**Other Languages**\n", 69 | "\n", 70 | " if (x)\n", 71 | " if(y)\n", 72 | " code-statement;\n", 73 | " else\n", 74 | " another-code-statement;\n", 75 | " \n", 76 | "**Python**\n", 77 | " \n", 78 | " if x:\n", 79 | " if y:\n", 80 | " code-statement\n", 81 | " else:\n", 82 | " another-code-statement" 83 | ] 84 | }, 85 | { 86 | "cell_type": "markdown", 87 | "metadata": {}, 88 | "source": [ 89 | "Note how Python is so heavily driven by code indentation and whitespace. This means that code readability is a core part of the design of the Python language.\n", 90 | "\n", 91 | "Now let's start diving deeper by coding these sort of statements in Python!" 92 | ] 93 | }, 94 | { 95 | "cell_type": "code", 96 | "execution_count": null, 97 | "metadata": {}, 98 | "outputs": [], 99 | "source": [] 100 | } 101 | ], 102 | "metadata": { 103 | "kernelspec": { 104 | "display_name": "base", 105 | "language": "python", 106 | "name": "python3" 107 | }, 108 | "language_info": { 109 | "codemirror_mode": { 110 | "name": "ipython", 111 | "version": 3 112 | }, 113 | "file_extension": ".py", 114 | "mimetype": "text/x-python", 115 | "name": "python", 116 | "nbconvert_exporter": "python", 117 | "pygments_lexer": "ipython3", 118 | "version": "3.9.7" 119 | }, 120 | "vscode": { 121 | "interpreter": { 122 | "hash": "adbf8baac3fd83462ba4d3cf155237b9080954f140b6d8291bc95ec68b06c358" 123 | } 124 | } 125 | }, 126 | "nbformat": 4, 127 | "nbformat_minor": 1 128 | } 129 | -------------------------------------------------------------------------------- /02-Python Statements/__pycache__/veh.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/02-Python Statements/__pycache__/veh.cpython-39.pyc -------------------------------------------------------------------------------- /03-Methods and Functions/01-Methods.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Methods\n", 8 | "\n", 9 | "Methods are essentially functions built into objects.\n", 10 | "\n", 11 | "Methods perform specific actions on an object and can also take arguments, just like a function. \n", 12 | "\n", 13 | "Methods are in the form:\n", 14 | "\n", 15 | " object.method(arg1,arg2,etc...)\n", 16 | " \n" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 1, 22 | "metadata": { 23 | "collapsed": true 24 | }, 25 | "outputs": [], 26 | "source": [ 27 | "# Create a simple list\n", 28 | "lst = [1,2,3,4,5] " 29 | ] 30 | }, 31 | { 32 | "cell_type": "markdown", 33 | "metadata": {}, 34 | "source": [ 35 | "The methods for a list are:\n", 36 | "\n", 37 | "* append\n", 38 | "* count\n", 39 | "* extend\n", 40 | "* insert\n", 41 | "* pop\n", 42 | "* remove\n", 43 | "* reverse\n", 44 | "* sort\n", 45 | "\n" 46 | ] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "metadata": {}, 51 | "source": [ 52 | "append() allows us to add elements to the end of a list:" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": 2, 58 | "metadata": { 59 | "collapsed": true 60 | }, 61 | "outputs": [], 62 | "source": [ 63 | "lst.append(6) " 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 4, 69 | "metadata": {}, 70 | "outputs": [ 71 | { 72 | "name": "stdout", 73 | "output_type": "stream", 74 | "text": [ 75 | "[1, 2, 3, 4, 5, 6]\n" 76 | ] 77 | } 78 | ], 79 | "source": [ 80 | "print(lst)" 81 | ] 82 | }, 83 | { 84 | "cell_type": "markdown", 85 | "metadata": {}, 86 | "source": [ 87 | "The count() method will count the number of occurrences of an element in a list." 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": 4, 93 | "metadata": {}, 94 | "outputs": [ 95 | { 96 | "data": { 97 | "text/plain": [ 98 | "1" 99 | ] 100 | }, 101 | "execution_count": 4, 102 | "metadata": {}, 103 | "output_type": "execute_result" 104 | } 105 | ], 106 | "source": [ 107 | "# Check how many times 2 shows up in the list\n", 108 | "lst.count(2)" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "metadata": {}, 114 | "source": [ 115 | "to get more help about the method use the help() function: " 116 | ] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": 5, 121 | "metadata": {}, 122 | "outputs": [ 123 | { 124 | "name": "stdout", 125 | "output_type": "stream", 126 | "text": [ 127 | "Help on built-in function count:\n", 128 | "\n", 129 | "count(value, /) method of builtins.list instance\n", 130 | " Return number of occurrences of value.\n", 131 | "\n" 132 | ] 133 | } 134 | ], 135 | "source": [ 136 | "help(lst.count) " 137 | ] 138 | }, 139 | { 140 | "cell_type": "code", 141 | "execution_count": 6, 142 | "metadata": {}, 143 | "outputs": [ 144 | { 145 | "name": "stdout", 146 | "output_type": "stream", 147 | "text": [ 148 | "sum of numbers : 4\n", 149 | "sub of numbers : 0\n", 150 | "mul of numbers : 4\n", 151 | "div of numbers : 1\n" 152 | ] 153 | } 154 | ], 155 | "source": [ 156 | "def cal(num1, num2):\n", 157 | " print(\"sum of numbers :\" , num1+num2)\n", 158 | " print(\"sub of numbers :\" , num1-num2)\n", 159 | " print(\"mul of numbers :\" , num1*num2)\n", 160 | " print(\"div of numbers :\" , num1//num2)\n", 161 | " \n", 162 | "a = int(input(\"Enter number one\"))\n", 163 | "b = 2\n", 164 | "cal(a,b)\n" 165 | ] 166 | } 167 | ], 168 | "metadata": { 169 | "kernelspec": { 170 | "display_name": "base", 171 | "language": "python", 172 | "name": "python3" 173 | }, 174 | "language_info": { 175 | "codemirror_mode": { 176 | "name": "ipython", 177 | "version": 3 178 | }, 179 | "file_extension": ".py", 180 | "mimetype": "text/x-python", 181 | "name": "python", 182 | "nbconvert_exporter": "python", 183 | "pygments_lexer": "ipython3", 184 | "version": "3.10.9" 185 | }, 186 | "vscode": { 187 | "interpreter": { 188 | "hash": "adbf8baac3fd83462ba4d3cf155237b9080954f140b6d8291bc95ec68b06c358" 189 | } 190 | } 191 | }, 192 | "nbformat": 4, 193 | "nbformat_minor": 1 194 | } 195 | -------------------------------------------------------------------------------- /03-Methods and Functions/assignments_function.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/03-Methods and Functions/assignments_function.docx -------------------------------------------------------------------------------- /03-Methods and Functions/basic_app_calc.py: -------------------------------------------------------------------------------- 1 | def display_menu(): 2 | print("Simple Calculator") 3 | print("=================") 4 | print("1. Add") 5 | print("2. Subtract") 6 | print("3. Multiply") 7 | print("4. Divide") 8 | print("5. Quit") 9 | 10 | def add(a, b): 11 | return a + b 12 | 13 | def subtract(a, b): 14 | return a - b 15 | 16 | def multiply(a, b): 17 | return a * b 18 | 19 | def divide(a, b): 20 | if b == 0: 21 | return "Error! Division by zero." 22 | else: 23 | return a / b 24 | 25 | def get_numbers(): 26 | a = float(input("Enter the first number: ")) 27 | b = float(input("Enter the second number: ")) 28 | return a, b 29 | 30 | def main(): 31 | while True: 32 | display_menu() 33 | choice = input("Choose an option (1-5): ") 34 | 35 | if choice == '1': 36 | a, b = get_numbers() 37 | result = add(a, b) 38 | print(f"The result is: {result}") 39 | 40 | elif choice == '2': 41 | a, b = get_numbers() 42 | result = subtract(a, b) 43 | print(f"The result is: {result}") 44 | 45 | elif choice == '3': 46 | a, b = get_numbers() 47 | result = multiply(a, b) 48 | print(f"The result is: {result}") 49 | 50 | elif choice == '4': 51 | a, b = get_numbers() 52 | result = divide(a, b) 53 | print(f"The result is: {result}") 54 | 55 | elif choice == '5': 56 | print("Exiting the calculator. Goodbye!") 57 | break 58 | 59 | else: 60 | print("Invalid choice. Please choose a valid option.") 61 | 62 | if __name__ == "__main__": 63 | main() 64 | 65 | 66 | """ 67 | How it works: 68 | display_menu(): Prints the options available to the user. 69 | 70 | add(a, b): Returns the sum of a and b. 71 | 72 | subtract(a, b): Returns the difference between a and b. 73 | 74 | multiply(a, b): Returns the product of a and b. 75 | 76 | divide(a, b): Returns the quotient of a divided by b, with a check to prevent division by zero. 77 | 78 | get_numbers(): Prompts the user to input two numbers and returns them. 79 | 80 | main(): The main function that runs an infinite loop to keep the application running until the user decides to quit by choosing option 5. It calls the appropriate function based on the user's choice. 81 | """ 82 | 83 | """ 84 | 85 | The line if __name__ == "__main__": is a common Python idiom used to ensure that certain code is only executed when the script is run directly, and not when it is imported as a module in another script. 86 | 87 | 88 | Understanding __name__ and __main__ 89 | __name__: This is a special built-in variable in Python. 90 | When a Python script is run, the interpreter sets the __name__ variable to "__main__". 91 | If the script is being imported into another module, __name__ is set to the name of the script/module. 92 | """ 93 | -------------------------------------------------------------------------------- /03-Methods and Functions/task_manager.py: -------------------------------------------------------------------------------- 1 | def display_menu(): 2 | print("\nTask Manager") 3 | print("============") 4 | print("1. View Tasks") 5 | print("2. Add Task") 6 | print("3. Mark Task as Done") 7 | print("4. Remove Task") 8 | print("5. Exit") 9 | 10 | def view_tasks(tasks): 11 | if not tasks: 12 | print("No tasks available.") 13 | else: 14 | print("\nTasks:") 15 | for task_id, task_details in tasks.items(): 16 | print(task_details) 17 | print(task_id) 18 | status = "Done" if task_details['done'] else "Not Done" 19 | print(f"{task_id}. {task_details['description']} ({status})") 20 | 21 | def add_task(tasks, task_id_counter): 22 | description = input("Enter the new task: ") 23 | tasks[task_id_counter] = {'description': description, 'done': False} 24 | print("Task added.") 25 | return task_id_counter + 1 26 | 27 | def mark_task_done(tasks): 28 | view_tasks(tasks) 29 | task_id = int(input("Enter the task ID to mark as done: ")) 30 | if task_id in tasks: 31 | tasks[task_id]['done'] = True 32 | print("Task marked as done.") 33 | else: 34 | print("Invalid task ID.") 35 | 36 | def remove_task(tasks): 37 | view_tasks(tasks) 38 | task_id = int(input("Enter the task ID to remove: ")) 39 | if task_id in tasks: 40 | removed_task = tasks.pop(task_id) 41 | print(f"Task '{removed_task['description']}' removed.") 42 | else: 43 | print("Invalid task ID.") 44 | 45 | def main(): 46 | tasks = {} 47 | task_id_counter = 1 48 | 49 | while True: 50 | display_menu() 51 | choice = input("Choose an option (1-5): ") 52 | 53 | if choice == '1': 54 | view_tasks(tasks) 55 | 56 | elif choice == '2': 57 | task_id_counter = add_task(tasks, task_id_counter) 58 | 59 | elif choice == '3': 60 | mark_task_done(tasks) 61 | 62 | elif choice == '4': 63 | remove_task(tasks) 64 | 65 | elif choice == '5': 66 | print("Exiting the task manager.") 67 | break 68 | 69 | else: 70 | print("Invalid choice. Please choose a valid option.") 71 | 72 | if __name__ == "__main__": 73 | main() 74 | 75 | 76 | """ 77 | Explanation: 78 | 79 | Tasks Dictionary: The tasks are stored in a dictionary where each key is a unique task ID (integer), and the value is another dictionary with task details (description and done status). 80 | 81 | view_tasks(tasks): Displays tasks with their IDs and statuses. 82 | 83 | add_task(tasks, task_id_counter): Adds a new task to the dictionary with a unique task ID. The task_id_counter is incremented after each addition to ensure unique IDs. 84 | 85 | mark_task_done(tasks): Marks a specified task as done by changing its done status to True. 86 | 87 | remove_task(tasks): Removes a task from the dictionary using its ID. 88 | 89 | main(): The main loop that manages user interactions and task operations. 90 | 91 | 92 | """ -------------------------------------------------------------------------------- /03-Methods and Functions/tasks.txt: -------------------------------------------------------------------------------- 1 | # Application 01: 2 | 3 | Steps to Create the Contact Manager Application 4 | 5 | 6 | 1. Define the menu: Display the options available to the user. 7 | 8 | 2. Define functions for each operation: 9 | View contacts 10 | Add a new contact 11 | Search for a contact 12 | Delete a contact 13 | 14 | 3. Implement the main loop: Continuously prompt the user to choose an option and perform the corresponding action until they choose to exit. 15 | 16 | 17 | Expected functios: 18 | display_menu(): Prints the main menu. 19 | view_contacts(contacts): Displays all contacts. 20 | add_contact(contacts): Prompts the user to enter a name and phone number, then adds the contact to the dictionary. 21 | search_contact(contacts): Searches for a contact by name and displays the phone number if found. 22 | delete_contact(contacts): Deletes a contact by name if it exists in the dictionary. 23 | main(): Runs the main loop, displaying the menu and handling user input to perform the appropriate actions. 24 | 25 | ------------------------------------------------------------------------------------------------------------------------------------------------------------ 26 | 27 | 28 | # Application 02: 29 | 30 | Note-Taking Application: 31 | 32 | 1. Define the menu: Display the options available to the user. 33 | 34 | 2. Define functions for each operation: 35 | View notes 36 | Add a new note 37 | Search for a note by title 38 | Delete a note 39 | 40 | 3. Implement the main loop: Continuously prompt the user to choose an option and perform the corresponding action until they choose to exit. 41 | 42 | Expected functios: 43 | display_menu(): Prints the main menu. 44 | view_notes(notes): Displays all notes with their titles and contents. 45 | add_note(notes): Prompts the user to enter a note title and content, then adds the note to the dictionary. 46 | search_note(notes): Searches for a note by its title and displays the content if found. 47 | delete_note(notes): Deletes a note by its title if it exists in the dictionary. 48 | main(): Runs the main loop, displaying the menu and handling user input to perform the appropriate actions. 49 | 50 | 51 | ------------------------------------------------------------------------------------------------------------------------------------------------------------ 52 | 53 | 54 | Application 03: 55 | 56 | Personal Budget Tracker: 57 | Define the Menu: Display the options available to the user. 58 | 59 | Define Functions for Each Operation: 60 | 61 | View all transactions 62 | Add a new transaction 63 | Edit an existing transaction 64 | Delete a transaction 65 | View the total balance 66 | 67 | Implement the Main Loop: Continuously prompt the user to choose an option and perform the corresponding action until they choose to exit. 68 | 69 | Expected Functions: 70 | display_menu(): Prints the main menu. 71 | view_transactions(transactions): Displays all transactions with their categories, amounts, and descriptions. 72 | add_transaction(transactions): Prompts the user to enter a transaction category, amount, and description, then adds the transaction to the list. 73 | edit_transaction(transactions): Allows the user to modify an existing transaction’s details based on its index or title. 74 | delete_transaction(transactions): Deletes a transaction by its index or title if it exists in the list. 75 | view_balance(transactions): Calculates and displays the total balance, which is the sum of all transactions. 76 | main(): Runs the main loop, displaying the menu and handling user input to perform the appropriate actions. 77 | -------------------------------------------------------------------------------- /03.01-useful_functions/01-Map.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# map()\n", 8 | "\n", 9 | "map() is a built-in Python function that takes in two or more arguments: a function and one or more iterables, in the form:\n", 10 | "\n", 11 | " map(function, iterable, ...)\n", 12 | " \n", 13 | "map() returns an *iterator* - that is, map() returns a special object that yields one result at a time as needed.\n", 14 | "\n" 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": 5, 20 | "metadata": { 21 | "collapsed": true 22 | }, 23 | "outputs": [ 24 | { 25 | "data": { 26 | "text/plain": [ 27 | "[40, 100]" 28 | ] 29 | }, 30 | "execution_count": 5, 31 | "metadata": {}, 32 | "output_type": "execute_result" 33 | } 34 | ], 35 | "source": [ 36 | "def fahrenheit(celsius):\n", 37 | " return (9/5)*celsius + 32\n", 38 | " \n", 39 | "temps = [0, 22.5, 40, 100]" 40 | ] 41 | }, 42 | { 43 | "cell_type": "markdown", 44 | "metadata": {}, 45 | "source": [ 46 | "Now let's see map() in action:" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": 2, 52 | "metadata": {}, 53 | "outputs": [ 54 | { 55 | "data": { 56 | "text/plain": [ 57 | "[32.0, 72.5, 104.0, 212.0]" 58 | ] 59 | }, 60 | "execution_count": 2, 61 | "metadata": {}, 62 | "output_type": "execute_result" 63 | } 64 | ], 65 | "source": [ 66 | "F_temps = map(fahrenheit, temps)\n", 67 | "\n", 68 | "#Show\n", 69 | "list(F_temps)" 70 | ] 71 | }, 72 | { 73 | "cell_type": "markdown", 74 | "metadata": {}, 75 | "source": [ 76 | "In the example above, map() applies the fahrenheit function to every item in temps. However, we don't have to define our functions beforehand; we can use a lambda expression instead:" 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "execution_count": 3, 82 | "metadata": {}, 83 | "outputs": [ 84 | { 85 | "data": { 86 | "text/plain": [ 87 | "[32.0, 72.5, 104.0, 212.0]" 88 | ] 89 | }, 90 | "execution_count": 3, 91 | "metadata": {}, 92 | "output_type": "execute_result" 93 | } 94 | ], 95 | "source": [ 96 | "list(map(lambda x: (9/5)*x + 32, temps))" 97 | ] 98 | }, 99 | { 100 | "cell_type": "markdown", 101 | "metadata": {}, 102 | "source": [ 103 | "Using map with lambda expressions is much more common since the entire purpose of map() is to save effort on having to create manual for loops." 104 | ] 105 | }, 106 | { 107 | "cell_type": "markdown", 108 | "metadata": {}, 109 | "source": [ 110 | "### map() with multiple iterables\n", 111 | "map() can accept more than one iterable. The iterables should be the same length - in the event that they are not, map() will stop as soon as the shortest iterable is exhausted.\n", 112 | "\n", 113 | "\n", 114 | "For instance, if our function is trying to add two values **x** and **y**, we can pass a list of **x** values and another list of **y** values to map(). The function (or lambda) will be fed the 0th index from each list, and then the 1st index, and so on until the n-th index is reached.\n", 115 | "\n", 116 | "Let's see this in action with two and then three lists:" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": 4, 122 | "metadata": {}, 123 | "outputs": [ 124 | { 125 | "data": { 126 | "text/plain": [ 127 | "[6, 8, 10, 12]" 128 | ] 129 | }, 130 | "execution_count": 4, 131 | "metadata": {}, 132 | "output_type": "execute_result" 133 | } 134 | ], 135 | "source": [ 136 | "a = [1,2,3,4]\n", 137 | "b = [5,6,7,8]\n", 138 | "c = [9,10,11,12]\n", 139 | "\n", 140 | "list(map(lambda x,y:x+y,a,b))" 141 | ] 142 | }, 143 | { 144 | "cell_type": "code", 145 | "execution_count": 5, 146 | "metadata": {}, 147 | "outputs": [ 148 | { 149 | "data": { 150 | "text/plain": [ 151 | "[15, 18, 21, 24]" 152 | ] 153 | }, 154 | "execution_count": 5, 155 | "metadata": {}, 156 | "output_type": "execute_result" 157 | } 158 | ], 159 | "source": [ 160 | "# Now all three lists\n", 161 | "list(map(lambda x,y,z:x+y+z,a,b,c))" 162 | ] 163 | }, 164 | { 165 | "cell_type": "markdown", 166 | "metadata": {}, 167 | "source": [ 168 | "We can see in the example above that the parameter **x** gets its values from the list **a**, while **y** gets its values from **b** and **z** from list **c**. Go ahead and play with your own example to make sure you fully understand mapping to more than one iterable.\n" 169 | ] 170 | } 171 | ], 172 | "metadata": { 173 | "kernelspec": { 174 | "display_name": "base", 175 | "language": "python", 176 | "name": "python3" 177 | }, 178 | "language_info": { 179 | "codemirror_mode": { 180 | "name": "ipython", 181 | "version": 3 182 | }, 183 | "file_extension": ".py", 184 | "mimetype": "text/x-python", 185 | "name": "python", 186 | "nbconvert_exporter": "python", 187 | "pygments_lexer": "ipython3", 188 | "version": "3.9.7" 189 | }, 190 | "vscode": { 191 | "interpreter": { 192 | "hash": "adbf8baac3fd83462ba4d3cf155237b9080954f140b6d8291bc95ec68b06c358" 193 | } 194 | } 195 | }, 196 | "nbformat": 4, 197 | "nbformat_minor": 1 198 | } 199 | -------------------------------------------------------------------------------- /03.01-useful_functions/03-Filter.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# filter\n", 8 | "\n", 9 | "The function filter(function, list) offers a convenient way to filter out all the elements of an iterable, for which the function returns True. \n", 10 | "\n", 11 | "The function filter(function,list) needs a function as its first argument. The function needs to return a Boolean value (either True or False). This function will be applied to every element of the iterable. Only if the function returns True will the element of the iterable be included in the result.\n", 12 | "\n", 13 | "Like map(), filter() returns an *iterator* - that is, filter yields one result at a time as needed. \n", 14 | "\n", 15 | " examples:" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": 1, 21 | "metadata": { 22 | "collapsed": true 23 | }, 24 | "outputs": [], 25 | "source": [ 26 | "#First let's make a function\n", 27 | "def even_check(num):\n", 28 | " if num%2 ==0:\n", 29 | " return True" 30 | ] 31 | }, 32 | { 33 | "cell_type": "markdown", 34 | "metadata": {}, 35 | "source": [ 36 | "Now let's filter a list of numbers. Note: putting the function into filter without any parentheses might feel strange, but keep in mind that functions are objects as well." 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 2, 42 | "metadata": {}, 43 | "outputs": [ 44 | { 45 | "data": { 46 | "text/plain": [ 47 | "[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]" 48 | ] 49 | }, 50 | "execution_count": 2, 51 | "metadata": {}, 52 | "output_type": "execute_result" 53 | } 54 | ], 55 | "source": [ 56 | "lst =range(20)\n", 57 | "\n", 58 | "list(filter(even_check,lst))" 59 | ] 60 | }, 61 | { 62 | "cell_type": "markdown", 63 | "metadata": {}, 64 | "source": [ 65 | "filter() is more commonly used with lambda functions, because we usually use filter for a quick job where we don't want to write an entire function. Let's repeat the example above using a lambda expression:" 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": 3, 71 | "metadata": {}, 72 | "outputs": [ 73 | { 74 | "data": { 75 | "text/plain": [ 76 | "[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]" 77 | ] 78 | }, 79 | "execution_count": 3, 80 | "metadata": {}, 81 | "output_type": "execute_result" 82 | } 83 | ], 84 | "source": [ 85 | "list(filter(lambda x: x%2==0,lst))" 86 | ] 87 | } 88 | ], 89 | "metadata": { 90 | "kernelspec": { 91 | "display_name": "Python 3.9.0 64-bit", 92 | "language": "python", 93 | "name": "python3" 94 | }, 95 | "language_info": { 96 | "codemirror_mode": { 97 | "name": "ipython", 98 | "version": 3 99 | }, 100 | "file_extension": ".py", 101 | "mimetype": "text/x-python", 102 | "name": "python", 103 | "nbconvert_exporter": "python", 104 | "pygments_lexer": "ipython3", 105 | "version": "3.9.0" 106 | }, 107 | "vscode": { 108 | "interpreter": { 109 | "hash": "898a32a18de38b8e8f8a4f70c1b651867488d5b078cf19a2942249b7e062bc27" 110 | } 111 | } 112 | }, 113 | "nbformat": 4, 114 | "nbformat_minor": 1 115 | } 116 | -------------------------------------------------------------------------------- /03.01-useful_functions/05-Enumerate.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# enumerate()\n", 8 | "Enumerate allows you to keep a count as you iterate through an object. It does this by returning a tuple in the form (count,element). The function itself is equivalent to:\n", 9 | "\n", 10 | " def enumerate(sequence, start=0):\n", 11 | " n = start\n", 12 | " for elem in sequence:\n", 13 | " yield n, elem\n", 14 | " n += 1\n", 15 | "\n", 16 | "## Example" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 1, 22 | "metadata": {}, 23 | "outputs": [ 24 | { 25 | "name": "stdout", 26 | "output_type": "stream", 27 | "text": [ 28 | "0\n", 29 | "a\n", 30 | "1\n", 31 | "b\n", 32 | "2\n", 33 | "c\n" 34 | ] 35 | } 36 | ], 37 | "source": [ 38 | "lst = ['a','b','c']\n", 39 | "\n", 40 | "for number,item in enumerate(lst):\n", 41 | " print(number)\n", 42 | " print(item)" 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "metadata": {}, 48 | "source": [ 49 | "enumerate() becomes particularly useful when you have a case where you need to have some sort of tracker. For example:" 50 | ] 51 | }, 52 | { 53 | "cell_type": "code", 54 | "execution_count": 2, 55 | "metadata": {}, 56 | "outputs": [ 57 | { 58 | "name": "stdout", 59 | "output_type": "stream", 60 | "text": [ 61 | "a\n", 62 | "b\n" 63 | ] 64 | } 65 | ], 66 | "source": [ 67 | "for count,item in enumerate(lst):\n", 68 | " if count >= 2:\n", 69 | " break\n", 70 | " else:\n", 71 | " print(item)" 72 | ] 73 | }, 74 | { 75 | "cell_type": "markdown", 76 | "metadata": {}, 77 | "source": [ 78 | "enumerate() takes an optional \"start\" argument to override the default value of zero:" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": 3, 84 | "metadata": {}, 85 | "outputs": [ 86 | { 87 | "data": { 88 | "text/plain": [ 89 | "[(3, 'March'), (4, 'April'), (5, 'May'), (6, 'June')]" 90 | ] 91 | }, 92 | "execution_count": 3, 93 | "metadata": {}, 94 | "output_type": "execute_result" 95 | } 96 | ], 97 | "source": [ 98 | "months = ['March','April','May','June']\n", 99 | "\n", 100 | "list(enumerate(months,start=3))" 101 | ] 102 | } 103 | ], 104 | "metadata": { 105 | "kernelspec": { 106 | "display_name": "Python 3", 107 | "language": "python", 108 | "name": "python3" 109 | }, 110 | "language_info": { 111 | "codemirror_mode": { 112 | "name": "ipython", 113 | "version": 3 114 | }, 115 | "file_extension": ".py", 116 | "mimetype": "text/x-python", 117 | "name": "python", 118 | "nbconvert_exporter": "python", 119 | "pygments_lexer": "ipython3", 120 | "version": "3.6.6" 121 | } 122 | }, 123 | "nbformat": 4, 124 | "nbformat_minor": 1 125 | } 126 | -------------------------------------------------------------------------------- /03.01-useful_functions/06-all() and any().ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# all() and any()" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "all() and any() are built-in functions in Python that allow us to conveniently check for boolean matching in an iterable. all() will return True if all elements in an iterable are True. It is the same as this function code:\n", 15 | "\n", 16 | " def all(iterable):\n", 17 | " for element in iterable:\n", 18 | " if not element:\n", 19 | " return False\n", 20 | " return True\n", 21 | " \n", 22 | "any() will return True if any of the elements in the iterable are True. It is equivalent to the following function code:\n", 23 | "\n", 24 | " def any(iterable):\n", 25 | " for element in iterable:\n", 26 | " if element:\n", 27 | " return True\n", 28 | " return False\n", 29 | " " 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": 1, 35 | "metadata": { 36 | "collapsed": true 37 | }, 38 | "outputs": [], 39 | "source": [ 40 | "lst = [True,True,False,True]" 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": 2, 46 | "metadata": {}, 47 | "outputs": [ 48 | { 49 | "data": { 50 | "text/plain": [ 51 | "False" 52 | ] 53 | }, 54 | "execution_count": 2, 55 | "metadata": {}, 56 | "output_type": "execute_result" 57 | } 58 | ], 59 | "source": [ 60 | "all(lst)" 61 | ] 62 | }, 63 | { 64 | "cell_type": "markdown", 65 | "metadata": {}, 66 | "source": [ 67 | "Returns False because not all elements are True." 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": 3, 73 | "metadata": {}, 74 | "outputs": [ 75 | { 76 | "data": { 77 | "text/plain": [ 78 | "True" 79 | ] 80 | }, 81 | "execution_count": 3, 82 | "metadata": {}, 83 | "output_type": "execute_result" 84 | } 85 | ], 86 | "source": [ 87 | "any(lst)" 88 | ] 89 | }, 90 | { 91 | "cell_type": "markdown", 92 | "metadata": {}, 93 | "source": [ 94 | "Returns True because at least one of the elements in the list is True" 95 | ] 96 | } 97 | ], 98 | "metadata": { 99 | "kernelspec": { 100 | "display_name": "Python 3", 101 | "language": "python", 102 | "name": "python3" 103 | }, 104 | "language_info": { 105 | "codemirror_mode": { 106 | "name": "ipython", 107 | "version": 3 108 | }, 109 | "file_extension": ".py", 110 | "mimetype": "text/x-python", 111 | "name": "python", 112 | "nbconvert_exporter": "python", 113 | "pygments_lexer": "ipython3", 114 | "version": "3.6.6" 115 | } 116 | }, 117 | "nbformat": 4, 118 | "nbformat_minor": 1 119 | } 120 | -------------------------------------------------------------------------------- /03.01-useful_functions/07-Complex.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# complex()\n", 8 | "\n", 9 | "complex() returns a complex number with the value real + imag*1j or converts a string or number to a complex number. \n", 10 | "\n", 11 | "If the first parameter is a string, it will be interpreted as a complex number and the function must be called without a second parameter. The second parameter can never be a string. Each argument may be any numeric type (including complex). If imag is omitted, it defaults to zero and the constructor serves as a numeric conversion like int and float. If both arguments are omitted, returns 0j.\n", 12 | "\n", 13 | "If you are doing math or engineering that requires complex numbers (such as dynamics, control systems, or impedance of a circuit) this is a useful tool to have in Python.\n", 14 | "\n", 15 | "Let's see some examples:" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": 1, 21 | "metadata": {}, 22 | "outputs": [ 23 | { 24 | "data": { 25 | "text/plain": [ 26 | "(2+3j)" 27 | ] 28 | }, 29 | "execution_count": 1, 30 | "metadata": {}, 31 | "output_type": "execute_result" 32 | } 33 | ], 34 | "source": [ 35 | "# Create 2+3j\n", 36 | "complex(2,3)" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 2, 42 | "metadata": {}, 43 | "outputs": [ 44 | { 45 | "data": { 46 | "text/plain": [ 47 | "(10+1j)" 48 | ] 49 | }, 50 | "execution_count": 2, 51 | "metadata": {}, 52 | "output_type": "execute_result" 53 | } 54 | ], 55 | "source": [ 56 | "complex(10,1)" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "We can also pass strings:" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 3, 69 | "metadata": {}, 70 | "outputs": [ 71 | { 72 | "data": { 73 | "text/plain": [ 74 | "(12+2j)" 75 | ] 76 | }, 77 | "execution_count": 3, 78 | "metadata": {}, 79 | "output_type": "execute_result" 80 | } 81 | ], 82 | "source": [ 83 | "complex('12+2j')" 84 | ] 85 | }, 86 | { 87 | "cell_type": "markdown", 88 | "metadata": {}, 89 | "source": [ 90 | "That's really all there is to this useful function. Keep it in mind if you are ever dealing with complex numbers in Python!" 91 | ] 92 | } 93 | ], 94 | "metadata": { 95 | "kernelspec": { 96 | "display_name": "Python 3", 97 | "language": "python", 98 | "name": "python3" 99 | }, 100 | "language_info": { 101 | "codemirror_mode": { 102 | "name": "ipython", 103 | "version": 3 104 | }, 105 | "file_extension": ".py", 106 | "mimetype": "text/x-python", 107 | "name": "python", 108 | "nbconvert_exporter": "python", 109 | "pygments_lexer": "ipython3", 110 | "version": "3.6.6" 111 | } 112 | }, 113 | "nbformat": 4, 114 | "nbformat_minor": 1 115 | } 116 | -------------------------------------------------------------------------------- /04-Object Oriented Programming/magicmethods.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "#### Magic Methods\n", 8 | "Magic methods in Python, also known as dunder methods (double underscore methods), are special methods that start and end with double underscores. These methods enable you to define the behavior of objects for built-in operations, such as arithmetic operations, comparisons, and more." 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "metadata": {}, 14 | "source": [ 15 | "##### Magic Methods\n", 16 | "Magic methods are predefined methods in Python that you can override to change the behavior of your objects. Some common magic methods include:\n", 17 | "\n" 18 | ] 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": 1, 23 | "metadata": {}, 24 | "outputs": [ 25 | { 26 | "data": { 27 | "text/plain": [ 28 | "\"\\n__init__': Initializes a new instance of a class.\\n__str__: Returns a string representation of an object.\\n__repr__: Returns an official string representation of an object.\\n__len__: Returns the length of an object.\\n__getitem__: Gets an item from a container.\\n__setitem__: Sets an item in a container.\\n\"" 29 | ] 30 | }, 31 | "execution_count": 1, 32 | "metadata": {}, 33 | "output_type": "execute_result" 34 | } 35 | ], 36 | "source": [ 37 | "'''\n", 38 | "__init__': Initializes a new instance of a class.\n", 39 | "__str__: Returns a string representation of an object.\n", 40 | "__repr__: Returns an official string representation of an object.\n", 41 | "__len__: Returns the length of an object.\n", 42 | "__getitem__: Gets an item from a container.\n", 43 | "__setitem__: Sets an item in a container.\n", 44 | "'''" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": 2, 50 | "metadata": {}, 51 | "outputs": [ 52 | { 53 | "data": { 54 | "text/plain": [ 55 | "['__class__',\n", 56 | " '__delattr__',\n", 57 | " '__dict__',\n", 58 | " '__dir__',\n", 59 | " '__doc__',\n", 60 | " '__eq__',\n", 61 | " '__format__',\n", 62 | " '__ge__',\n", 63 | " '__getattribute__',\n", 64 | " '__getstate__',\n", 65 | " '__gt__',\n", 66 | " '__hash__',\n", 67 | " '__init__',\n", 68 | " '__init_subclass__',\n", 69 | " '__le__',\n", 70 | " '__lt__',\n", 71 | " '__module__',\n", 72 | " '__ne__',\n", 73 | " '__new__',\n", 74 | " '__reduce__',\n", 75 | " '__reduce_ex__',\n", 76 | " '__repr__',\n", 77 | " '__setattr__',\n", 78 | " '__sizeof__',\n", 79 | " '__str__',\n", 80 | " '__subclasshook__',\n", 81 | " '__weakref__']" 82 | ] 83 | }, 84 | "execution_count": 2, 85 | "metadata": {}, 86 | "output_type": "execute_result" 87 | } 88 | ], 89 | "source": [ 90 | "class Person:\n", 91 | " pass\n", 92 | "\n", 93 | "person=Person()\n", 94 | "dir(person)" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "execution_count": 3, 100 | "metadata": {}, 101 | "outputs": [ 102 | { 103 | "name": "stdout", 104 | "output_type": "stream", 105 | "text": [ 106 | "<__main__.Person object at 0x0000029E5D059940>\n" 107 | ] 108 | } 109 | ], 110 | "source": [ 111 | "print(person)" 112 | ] 113 | }, 114 | { 115 | "cell_type": "code", 116 | "execution_count": 4, 117 | "metadata": {}, 118 | "outputs": [ 119 | { 120 | "name": "stdout", 121 | "output_type": "stream", 122 | "text": [ 123 | "<__main__.Person object at 0x0000029E5D31D4C0>\n" 124 | ] 125 | } 126 | ], 127 | "source": [ 128 | "## Basics MEthods\n", 129 | "class Person:\n", 130 | " def __init__(self,name,age):\n", 131 | " self.name=name\n", 132 | " self.age=age\n", 133 | "person=Person(\"KRish\",34)\n", 134 | "print(person)" 135 | ] 136 | }, 137 | { 138 | "cell_type": "code", 139 | "execution_count": 6, 140 | "metadata": {}, 141 | "outputs": [ 142 | { 143 | "name": "stdout", 144 | "output_type": "stream", 145 | "text": [ 146 | "KRish,34 years old\n", 147 | "Person(name=KRish,age=34)\n" 148 | ] 149 | } 150 | ], 151 | "source": [ 152 | "## Basics MEthods\n", 153 | "class Person:\n", 154 | " def __init__(self,name,age):\n", 155 | " self.name=name\n", 156 | " self.age=age\n", 157 | " \n", 158 | " def __str__(self):\n", 159 | " return f\"{self.name},{self.age} years old\"\n", 160 | " \n", 161 | " def __repr__(self):\n", 162 | " return f\"Person(name={self.name},age={self.age})\"\n", 163 | " \n", 164 | "person=Person(\"KRish\",34)\n", 165 | "print(person)\n", 166 | "print(repr(person))" 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": null, 172 | "metadata": {}, 173 | "outputs": [], 174 | "source": [] 175 | } 176 | ], 177 | "metadata": { 178 | "kernelspec": { 179 | "display_name": "Python 3", 180 | "language": "python", 181 | "name": "python3" 182 | }, 183 | "language_info": { 184 | "codemirror_mode": { 185 | "name": "ipython", 186 | "version": 3 187 | }, 188 | "file_extension": ".py", 189 | "mimetype": "text/x-python", 190 | "name": "python", 191 | "nbconvert_exporter": "python", 192 | "pygments_lexer": "ipython3", 193 | "version": "3.12.0" 194 | } 195 | }, 196 | "nbformat": 4, 197 | "nbformat_minor": 2 198 | } 199 | -------------------------------------------------------------------------------- /04-Object Oriented Programming/oops_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/04-Object Oriented Programming/oops_image.png -------------------------------------------------------------------------------- /04-Object Oriented Programming/solution_task_01.py: -------------------------------------------------------------------------------- 1 | class Book: 2 | def __init__(self, title, author, ISBN, year, available_copies): 3 | self.title = title 4 | self.author = author 5 | self.ISBN = ISBN 6 | self.year = year 7 | self.available_copies = available_copies 8 | 9 | def __str__(self): 10 | return f"{self.title} by {self.author} (ISBN: {self.ISBN}, Year: {self.year}, Available copies: {self.available_copies})" 11 | 12 | class Member: 13 | def __init__(self, name, member_id, contact_info): 14 | self.name = name 15 | self.member_id = member_id 16 | self.contact_info = contact_info 17 | self.borrowed_books = [] 18 | 19 | def borrow_book(self, book): 20 | if book.available_copies > 0: 21 | book.available_copies -= 1 22 | self.borrowed_books.append(book) 23 | else: 24 | print("This book is currently unavailable.") 25 | 26 | def return_book(self, book): 27 | if book in self.borrowed_books: 28 | book.available_copies += 1 29 | self.borrowed_books.remove(book) 30 | else: 31 | print("This book was not borrowed by the member.") 32 | 33 | def __str__(self): 34 | return f"Member: {self.name}, ID: {self.member_id}, Contact: {self.contact_info}" 35 | 36 | class Library: 37 | def __init__(self): 38 | self.books = [] 39 | self.members = [] 40 | 41 | def add_book(self, book): 42 | self.books.append(book) 43 | 44 | def remove_book(self, ISBN): 45 | self.books = [book for book in self.books if book.ISBN != ISBN] 46 | 47 | def search_book(self, **kwargs): 48 | for book in self.books: 49 | if all(getattr(book, key) == value for key, value in kwargs.items()): 50 | return book 51 | return None 52 | 53 | def add_member(self, member): 54 | self.members.append(member) 55 | 56 | def remove_member(self, member_id): 57 | self.members = [member for member in self.members if member.member_id != member_id] 58 | 59 | def borrow_book(self, member_id, ISBN): 60 | member = next((m for m in self.members if m.member_id == member_id), None) 61 | book = self.search_book(ISBN=ISBN) 62 | if member and book: 63 | member.borrow_book(book) 64 | 65 | def return_book(self, member_id, ISBN): 66 | member = next((m for m in self.members if m.member_id == member_id), None) 67 | book = self.search_book(ISBN=ISBN) 68 | if member and book: 69 | member.return_book(book) 70 | 71 | def list_books(self): 72 | for book in self.books: 73 | print(book) 74 | 75 | def list_members(self): 76 | for member in self.members: 77 | print(member) 78 | 79 | # Example usage 80 | library = Library() 81 | 82 | # Adding books 83 | book1 = Book("1984", "George Orwell", "1234567890", 1949, 5) 84 | library.add_book(book1) 85 | book2 = Book("To Kill a Mockingbird", "Harper Lee", "0987654321", 1960, 3) 86 | library.add_book(book2) 87 | 88 | # Adding members 89 | member1 = Member("Alice", "1", "alice@example.com") 90 | library.add_member(member1) 91 | member2 = Member("Bob", "2", "bob@example.com") 92 | library.add_member(member2) 93 | 94 | # Borrowing and returning books 95 | library.borrow_book("1", "1234567890") 96 | library.return_book("1", "1234567890") 97 | 98 | # Listing all books and members 99 | library.list_books() 100 | library.list_members() 101 | 102 | 103 | """ 104 | 105 | Explanation: 106 | Book Class: Represents a book in the library. It includes details like title, author, ISBN, year of publication, and available copies. Methods include those for basic book management. 107 | Member Class: Represents a library member. It includes details like name, member ID, and contact information. Methods allow a member to borrow and return books. 108 | Library Class: Manages the collection of books and members. Methods handle adding/removing books and members, as well as borrowing and returning books. 109 | 110 | 111 | """ -------------------------------------------------------------------------------- /04-Object Oriented Programming/tasks.txt: -------------------------------------------------------------------------------- 1 | Task 01 : Library Management System 2 | 3 | Objective: 4 | Develop a simple console-based application to manage a library's collection of books, 5 | including functionalities for adding, removing, updating, and searching for books, 6 | as well as managing library members and their borrowed books. 7 | 8 | Key Features: 9 | Book Management: 10 | 11 | Add a new book. 12 | Remove a book. 13 | Update book details. 14 | Search for books by title, author, or ISBN. 15 | 16 | Member Management: 17 | 18 | Add a new member. 19 | Remove a member. 20 | Update member details. 21 | 22 | Borrow and Return Books: 23 | 24 | Borrow a book. 25 | Return a book. 26 | Check borrowed books for a member 27 | 28 | 29 | Classes and Relationships: 30 | Book Class: 31 | 32 | Attributes: title, author, ISBN, year, available_copies. 33 | Methods: add_book(), remove_book(), update_book(), search_book(). 34 | 35 | Member Class: 36 | 37 | Attributes: name, member_id, contact_info, borrowed_books. 38 | Methods: add_member(), remove_member(), update_member(), view_borrowed_books(). 39 | 40 | Library Class: 41 | 42 | Attributes: books, members. 43 | Methods: borrow_book(), return_book(), list_books(), list_members(). 44 | 45 | 46 | 47 | Task 02: Banking System 48 | 49 | Objective: 50 | Create a console-based banking system to manage different types of accounts (savings, checking, and fixed deposit), allowing operations like deposit, withdrawal, and checking balance. 51 | 52 | Key Features: 53 | 54 | Account Management: 55 | 56 | Create different types of accounts (Savings, Checking, Fixed Deposit). 57 | Deposit money. 58 | Withdraw money. 59 | Check balance. 60 | Calculate interest (for Savings and Fixed Deposit accounts). 61 | 62 | Transaction Management: 63 | 64 | Maintain transaction history. 65 | Generate account statements. 66 | 67 | Classes and Relationships: 68 | 69 | Account (Abstract Base Class): 70 | 71 | Attributes: account_number, account_holder, balance. 72 | Methods: deposit(), withdraw(), get_balance(), add_transaction(). 73 | 74 | SavingsAccount (Inherits from Account): 75 | 76 | Additional Attributes: interest_rate. 77 | Methods: calculate_interest(). 78 | 79 | CheckingAccount (Inherits from Account): 80 | 81 | Additional Attributes: overdraft_limit. 82 | Methods: withdraw() (override). 83 | 84 | FixedDepositAccount (Inherits from Account): 85 | 86 | Additional Attributes: maturity_date, interest_rate. 87 | Methods: calculate_interest(). 88 | 89 | Transaction: 90 | 91 | Attributes: transaction_type, amount, date, balance_after_transaction. 92 | 93 | Bank: 94 | 95 | Attributes: accounts. 96 | Methods: create_account(), get_account(), list_accounts(). -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__init__.py -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/mysubscript.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/mysubscript.cpython-310.pyc -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/mysubscript.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/mysubscript.cpython-36.pyc -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/mysubscript.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/mysubscript.cpython-39.pyc -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/mysubscript.py: -------------------------------------------------------------------------------- 1 | def sub_report(): 2 | print("Hey Im a function inside mysubscript") -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__init__.py -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/some_main_script.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/some_main_script.cpython-310.pyc -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/some_main_script.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/some_main_script.cpython-36.pyc -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/some_main_script.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/some_main_script.cpython-39.pyc -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/MyMainPackage/some_main_script.py: -------------------------------------------------------------------------------- 1 | def report_main(): 2 | print("Hey I am in some_main_script in main package.") -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/mymodule.py: -------------------------------------------------------------------------------- 1 | def my_func(): 2 | print("Hey I am in mymodule.py") -------------------------------------------------------------------------------- /05-Modules and Packages/00-Modules_and_Packages/myprogram.py: -------------------------------------------------------------------------------- 1 | from MyMainPackage.some_main_script import report_main 2 | report_main() 3 | 4 | 5 | from MyMainPackage import some_main_script 6 | some_main_script.report_main() 7 | 8 | from MyMainPackage.SubPackage import mysubscript 9 | mysubscript.sub_report() 10 | 11 | 12 | from MyMainPackage.SubPackage.mysubscript import sub_report 13 | sub_report() 14 | 15 | 16 | from MyMainPackage.SubPackage.mysubscript import * 17 | sub_report() 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /05-Modules and Packages/01_modules/Explanation.txt: -------------------------------------------------------------------------------- 1 | Sometimes when you are importing from a module, you would like to know whether 2 | a modules function is being used as an import, or if you are using the original 3 | .py file of that module. In this case we can use the: 4 | 5 | if __name__ == "__main__": 6 | 7 | line to determine this. For example: 8 | 9 | When your script is run by passing it as a command to the Python interpreter: 10 | 11 | python myscript.py 12 | 13 | all of the code that is at indentation level 0 gets executed. Functions and 14 | classes that are defined are, well, defined, but none of their code gets ran. 15 | Unlike other languages, there's no main() function that gets run automatically 16 | - the main() function is implicitly all the code at the top level. 17 | 18 | In this case, the top-level code is an if block. __name__ is a built-in variable 19 | which evaluate to the name of the current module. However, if a module is being 20 | run directly (as in myscript.py above), then __name__ instead is set to the 21 | string "__main__". Thus, you can test whether your script is being run directly 22 | or being imported by something else by testing 23 | 24 | if __name__ == "__main__": 25 | ... 26 | 27 | If that code is being imported into another module, the various function and 28 | class definitions will be imported, but the main() code won't get run. As a 29 | basic example, consider the following two scripts: 30 | 31 | # file one.py 32 | def func(): 33 | print("func() in one.py") 34 | 35 | print("top-level in one.py") 36 | 37 | if __name__ == "__main__": 38 | print("one.py is being run directly") 39 | else: 40 | print("one.py is being imported into another module") 41 | 42 | and then: 43 | 44 | # file two.py 45 | import one 46 | 47 | print("top-level in two.py") 48 | one.func() 49 | 50 | if __name__ == "__main__": 51 | print("two.py is being run directly") 52 | else: 53 | print("two.py is being imported into another module") 54 | 55 | Now, if you invoke the interpreter as 56 | 57 | python one.py 58 | 59 | The output will be 60 | 61 | top-level in one.py 62 | 63 | one.py is being run directly 64 | If you run two.py instead: 65 | 66 | python two.py 67 | 68 | You get 69 | 70 | top-level in one.py 71 | one.py is being imported into another module 72 | top-level in two.py 73 | func() in one.py 74 | two.py is being run directly 75 | 76 | Thus, when module one gets loaded, its __name__ equals "one" instead of __main__. 77 | -------------------------------------------------------------------------------- /05-Modules and Packages/01_modules/__pycache__/one.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/01_modules/__pycache__/one.cpython-310.pyc -------------------------------------------------------------------------------- /05-Modules and Packages/01_modules/__pycache__/one.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/01_modules/__pycache__/one.cpython-311.pyc -------------------------------------------------------------------------------- /05-Modules and Packages/01_modules/__pycache__/one.cpython-312.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/01_modules/__pycache__/one.cpython-312.pyc -------------------------------------------------------------------------------- /05-Modules and Packages/01_modules/__pycache__/one.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/05-Modules and Packages/01_modules/__pycache__/one.cpython-39.pyc -------------------------------------------------------------------------------- /05-Modules and Packages/01_modules/one.py: -------------------------------------------------------------------------------- 1 | def func(): 2 | print("func() ran in one.py") 3 | 4 | print("top-level print inside of one.py") 5 | 6 | if __name__ == "__main__": 7 | print("one.py is being run directly") 8 | else: 9 | print("one.py is being imported into another module") 10 | -------------------------------------------------------------------------------- /05-Modules and Packages/01_modules/two.py: -------------------------------------------------------------------------------- 1 | import one 2 | 3 | # print("top-level in two.py") 4 | 5 | one.func() 6 | 7 | if __name__ == "__main__": 8 | print("two.py is being run directly") 9 | else: 10 | print("two.py is being imported into another module") 11 | -------------------------------------------------------------------------------- /05-Modules and Packages/structure.txt: -------------------------------------------------------------------------------- 1 | 00-Modules_and_Packages 2 | f- MyMainPacakage 3 | f- SubPacakge 4 | __init__.py 5 | mysubscript.py 6 | __init__.py 7 | some_main_script.py 8 | mymodule.py 9 | myprogram.py -------------------------------------------------------------------------------- /06-Errors and Exception Handling/solution_task_01.py: -------------------------------------------------------------------------------- 1 | # Define custom exceptions for specific error conditions 2 | class MovieAlreadyRentedError(Exception): 3 | def __init__(self, movie_title): 4 | self.movie_title = movie_title 5 | self.message = f"Movie '{movie_title}' is already rented out." 6 | super().__init__(self.message) 7 | 8 | class MovieNotFoundError(Exception): 9 | def __init__(self, movie_title): 10 | self.movie_title = movie_title 11 | self.message = f"Movie '{movie_title}' not found in the store." 12 | super().__init__(self.message) 13 | 14 | class ExceededMaxMoviesError(Exception): 15 | def __init__(self, max_movies_per_user): 16 | self.max_movies_per_user = max_movies_per_user 17 | self.message = f"Maximum movies ({max_movies_per_user}) already rented by the user." 18 | super().__init__(self.message) 19 | 20 | # Define a class representing the movie rental store 21 | class RentalStore: 22 | def __init__(self, max_movies_per_user=2): 23 | self.movies = [] # List to store movie objects 24 | self.max_movies_per_user = max_movies_per_user # Maximum number of movies a user can rent 25 | 26 | # Method to add a movie to the store 27 | def add_movie(self, movie): 28 | self.movies.append(movie) 29 | 30 | # Method to remove a movie from the store 31 | def remove_movie(self, title): 32 | for movie in self.movies: 33 | if movie.title == title: 34 | self.movies.remove(movie) 35 | return 36 | raise MovieNotFoundError(title) 37 | 38 | # Method to list all available movies in the store 39 | def list_movies(self): 40 | for movie in self.movies: 41 | print(movie.title) 42 | 43 | # Method to rent a movie 44 | def rent_movie(self, title): 45 | for movie in self.movies: 46 | if movie.title == title: 47 | if movie.rented: 48 | raise MovieAlreadyRentedError(title) 49 | movie.rented = True 50 | return 51 | raise MovieNotFoundError(title) 52 | 53 | # Method to return a rented movie 54 | def return_movie(self, title): 55 | for movie in self.movies: 56 | if movie.title == title: 57 | if not movie.rented: 58 | raise ValueError(f"Movie '{title}' is not currently rented.") 59 | movie.rented = False 60 | return 61 | raise MovieNotFoundError(title) 62 | 63 | # Define a class representing a movie 64 | class Movie: 65 | def __init__(self, title, genre, director, release_year): 66 | self.title = title 67 | self.genre = genre 68 | self.director = director 69 | self.release_year = release_year 70 | self.rented = False # Flag to indicate if the movie is currently rented 71 | 72 | # Function to validate input as a non-empty string 73 | def validate_input(prompt): 74 | while True: 75 | value = input(prompt).strip() 76 | if value: 77 | return value 78 | print("Input cannot be empty.") 79 | 80 | # Function to validate input as a positive integer within a specified range 81 | def validate_integer(prompt, min_value, max_value): 82 | while True: 83 | try: 84 | value = int(input(prompt)) 85 | if min_value <= value <= max_value: 86 | return value 87 | print(f"Input must be between {min_value} and {max_value}.") 88 | except ValueError: 89 | print("Invalid input. Please enter a valid integer.") 90 | 91 | # Example usage 92 | rental_store = RentalStore() 93 | 94 | # Adding movies to the store 95 | movie1 = Movie("Inception", "Sci-Fi", "Christopher Nolan", 2010) 96 | movie2 = Movie("The Dark Knight", "Action", "Christopher Nolan", 2008) 97 | movie3 = Movie("Pulp Fiction", "Crime", "Quentin Tarantino", 1994) 98 | 99 | rental_store.add_movie(movie1) 100 | rental_store.add_movie(movie2) 101 | rental_store.add_movie(movie3) 102 | 103 | # Renting a movie 104 | try: 105 | print("Available movies:") 106 | rental_store.list_movies() 107 | movie_title = validate_input("Enter the title of the movie you want to rent: ") 108 | rental_store.rent_movie(movie_title) 109 | print(f"Successfully rented '{movie_title}'.") 110 | except (MovieAlreadyRentedError, MovieNotFoundError) as e: 111 | print(f"Error: {e}") 112 | 113 | # Returning a movie 114 | try: 115 | print("\nMovies currently rented:") 116 | rental_store.list_movies() 117 | movie_title = validate_input("Enter the title of the movie you want to return: ") 118 | rental_store.return_movie(movie_title) 119 | print(f"Successfully returned '{movie_title}'.") 120 | except (MovieNotFoundError, ValueError) as e: 121 | print(f"Error: {e}") 122 | -------------------------------------------------------------------------------- /06-Errors and Exception Handling/task.txt: -------------------------------------------------------------------------------- 1 | Objective: 2 | Develop a console-based application for managing a movie rental store's collection of movies. 3 | The application should provide functionalities for adding, removing, renting, and returning movies, 4 | as well as handling user interactions and error conditions. 5 | 6 | Key Features: 7 | Movie Management: 8 | 9 | Add a new movie. 10 | Remove a movie. 11 | Rent a movie. 12 | Return a movie. 13 | List all available movies. 14 | 15 | Error and Exception Handling: 16 | 17 | Handle cases where a movie is already rented out. 18 | Handle cases where a movie doesn't exist. 19 | Handle cases where a user tries to rent more movies than allowed. 20 | Validate user inputs for non-empty strings and numerical values. 21 | 22 | Classes and Relationships: 23 | Movie Class: 24 | 25 | Attributes: title, genre, director, release_year, rented. 26 | Methods: __init__(), rent_movie(), return_movie(). 27 | 28 | RentalStore Class: 29 | 30 | Attributes: movies, max_movies_per_user. 31 | Methods: __init__(), add_movie(), remove_movie(), list_movies(), rent_movie(), return_movie(). 32 | 33 | Custom Exceptions: 34 | 35 | MovieAlreadyRentedError: Raised when a user tries to rent an already rented movie. 36 | MovieNotFoundError: Raised when a user tries to rent or return a non-existent movie. 37 | ExceededMaxMoviesError: Raised when a user tries to rent more movies than allowed. 38 | 39 | Input Validation Functions: 40 | 41 | validate_input(): Ensures that user inputs are non-empty strings. 42 | validate_integer(): Ensures that numerical inputs are within specified ranges. 43 | 44 | Steps to Complete the Code: 45 | 1. Define the Movie class with attributes and methods to manage movie rental operations. 46 | 2. Implement the RentalStore class with methods for managing the collection of movies. 47 | 3. Define custom exceptions to handle specific error conditions related to movie rental operations. 48 | 4. Implement input validation functions to validate user inputs. 49 | 5. Create example usage scenarios to demonstrate the functionalities of the movie rental store application. 50 | 6. Test the application by adding, removing, renting, and returning movies, while handling error conditions and validating user inputs. 51 | -------------------------------------------------------------------------------- /07-Streamlit/calculator.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | 3 | def add(a, b): 4 | return a + b 5 | 6 | def subtract(a, b): 7 | return a - b 8 | 9 | def multiply(a, b): 10 | return a * b 11 | 12 | def divide(a, b): 13 | if b != 0: 14 | return a / b 15 | else: 16 | return "Error: Division by zero" 17 | 18 | # Set page title and configure layout 19 | st.set_page_config(page_title="Simple Calculator", layout="centered") 20 | 21 | # Display calculator title 22 | st.title("Simple Calculator") 23 | 24 | # Get user input 25 | num1 = st.number_input("Enter the first number:") 26 | operation = st.selectbox("Select an operation:", ("Addition", "Subtraction", "Multiplication", "Division")) 27 | num2 = st.number_input("Enter the second number:") 28 | 29 | # Perform calculation based on user-selected operation 30 | result = 0 31 | if operation == "Addition": 32 | result = add(num1, num2) 33 | elif operation == "Subtraction": 34 | result = subtract(num1, num2) 35 | elif operation == "Multiplication": 36 | result = multiply(num1, num2) 37 | elif operation == "Division": 38 | result = divide(num1, num2) 39 | 40 | # Display the result 41 | st.write("Result:", result) 42 | 43 | st.balloons() 44 | """ 45 | The code begins by importing the necessary libraries, streamlit. 46 | The mathematical operations (addition, subtraction, multiplication, and division) are defined as separate functions to perform the respective calculations. 47 | The Streamlit page is configured with a title and layout settings. 48 | The calculator's title is displayed using st.title(). 49 | User input is obtained using st.number_input() to enter the first and second numbers. 50 | The operation selection is provided using st.selectbox(), where the user can choose from the available options. 51 | After obtaining the user's input, the code determines which operation was selected and calls the corresponding function to perform the calculation. 52 | The result is stored in the result variable. 53 | Finally, the result is displayed on the page using st.write(). 54 | 55 | """ -------------------------------------------------------------------------------- /07-Streamlit/countdown_timer.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | import time 3 | 4 | # Set page title and configure layout 5 | st.set_page_config(page_title="Countdown Timer", layout="centered") 6 | 7 | # Display application title and description 8 | st.title("Countdown Timer") 9 | st.write("Enter the duration in seconds and click 'Start' to begin the countdown.") 10 | 11 | # Get user input for the duration 12 | duration = st.number_input("Enter the duration in seconds:", min_value=1, step=1) 13 | 14 | # Initialize the countdown variable 15 | countdown = None 16 | 17 | # Function to update the countdown display 18 | def update_countdown(): 19 | global countdown 20 | 21 | if countdown is not None: 22 | st.write("Time remaining:", countdown, "seconds") 23 | 24 | if countdown > 0: 25 | countdown -= 1 26 | time.sleep(1) # Wait for 1 second 27 | update_countdown() 28 | else: 29 | st.write("Countdown completed!") 30 | 31 | # Start the countdown 32 | if st.button("Start"): 33 | countdown = duration 34 | update_countdown() 35 | -------------------------------------------------------------------------------- /07-Streamlit/flames.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | 3 | # Function to calculate the relationship status 4 | def calculate_relationship(name1, name2): 5 | name1 = name1.lower().replace(" ", "") 6 | name2 = name2.lower().replace(" ", "") 7 | 8 | # Removing common characters 9 | for char in name1: 10 | if char in name2: 11 | name1 = name1.replace(char, "", 1) 12 | name2 = name2.replace(char, "", 1) 13 | 14 | # Counting the remaining characters 15 | count = len(name1) + len(name2) 16 | 17 | # Determining the relationship status 18 | status = "" 19 | flames = "FLAMES" 20 | while len(flames) > 1: 21 | index = (count % len(flames)) - 1 22 | if index >= 0: 23 | flames = flames[:index] + flames[index+1:] 24 | else: 25 | flames = flames[:len(flames)-1] 26 | 27 | # Mapping the relationship status to the result 28 | if flames == "F": 29 | status = "Friends" 30 | elif flames == "L": 31 | status = "Lovers" 32 | elif flames == "A": 33 | status = "Affectionate" 34 | elif flames == "M": 35 | status = "Married" 36 | elif flames == "E": 37 | status = "Enemies" 38 | elif flames == "S": 39 | status = "Siblings" 40 | 41 | return status 42 | 43 | # Set page title and configure layout 44 | st.set_page_config(page_title="FLAMES Game", layout="centered") 45 | 46 | # Display application title and description 47 | st.title("FLAMES Game") 48 | st.write("Enter two names and find out the relationship status!") 49 | 50 | # Get user input 51 | name1 = st.text_input("Enter the first name:") 52 | name2 = st.text_input("Enter the second name:") 53 | 54 | # Calculate the relationship status 55 | if st.button("Calculate"): 56 | if name1 == "" or name2 == "": 57 | st.write("Please enter both names.") 58 | else: 59 | result = calculate_relationship(name1, name2) 60 | st.write("Relationship Status:", result) 61 | -------------------------------------------------------------------------------- /07-Streamlit/logomark_website.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/07-Streamlit/logomark_website.png -------------------------------------------------------------------------------- /07-Streamlit/main.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | 3 | def fuc1(): 4 | a = st.number_input('Pick a number',key=1) 5 | b= st.number_input('Pick a number', 0, 10,key=2) 6 | return a+b 7 | 8 | def fuc2(): 9 | a = st.number_input('Pick a number', 0, 10,key=3) 10 | b= st.number_input('Pick a number', 0, 10,key=4) 11 | st.balloons() 12 | return a-b 13 | 14 | with st.sidebar: 15 | value = st.radio('Select one:', ["add", "sub"]) 16 | 17 | if value == "add": 18 | result = fuc1() 19 | st.header(result) 20 | 21 | else: 22 | result = fuc2() 23 | st.header(result) 24 | -------------------------------------------------------------------------------- /07-Streamlit/multipage_streamlit_application/__pycache__/pages.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/07-Streamlit/multipage_streamlit_application/__pycache__/pages.cpython-310.pyc -------------------------------------------------------------------------------- /07-Streamlit/multipage_streamlit_application/app.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | from pages import home, about, contact 3 | 4 | # Set page title and configure layout 5 | st.set_page_config(page_title="Multi-Page App", layout="wide") 6 | 7 | # Create a dictionary to map page names to their respective functions 8 | pages = { 9 | "Home": home, 10 | "About": about, 11 | "Contact": contact 12 | } 13 | 14 | # Sidebar navigation 15 | page_selection = st.sidebar.radio("Navigate", tuple(pages.keys())) 16 | 17 | # Display the selected page content 18 | pages[page_selection]() 19 | -------------------------------------------------------------------------------- /07-Streamlit/multipage_streamlit_application/pages.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | 3 | def home(): 4 | st.title("Home Page") 5 | st.write("Welcome to the Home Page!") 6 | # Add content specific to the home page 7 | 8 | def about(): 9 | st.title("About Page") 10 | st.write("Welcome to the About Page!") 11 | # Add content specific to the about page 12 | 13 | def contact(): 14 | st.title("Contact Page") 15 | st.write("Welcome to the Contact Page!") 16 | # Add content specific to the contact page 17 | -------------------------------------------------------------------------------- /07-Streamlit/rock_paper_scissors/__pycache__/game.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/07-Streamlit/rock_paper_scissors/__pycache__/game.cpython-310.pyc -------------------------------------------------------------------------------- /07-Streamlit/rock_paper_scissors/app.py: -------------------------------------------------------------------------------- 1 | #pip install streamlit 2 | 3 | import streamlit as st 4 | from game import RockPaperScissors 5 | 6 | # Set page title and configure layout 7 | st.set_page_config(page_title="Rock Paper Scissors", layout="centered") 8 | # Display application title and description 9 | st.title("Rock Paper Scissors Game") 10 | st.write("Choose your move and see if you can beat the computer!") 11 | 12 | # Create an instance o f the game 13 | game = RockPaperScissors() 14 | 15 | # Get user input 16 | player_choice = st.selectbox("Select your move:", game.choices) 17 | 18 | # Play the game 19 | if st.button("Play"): 20 | try: 21 | # Call the play method to determine the result and computer's choice 22 | result, computer_choice = game.play(player_choice) 23 | 24 | # Display the player's and computer's choices 25 | st.write("You chose:", player_choice) 26 | st.write("Computer chose:", computer_choice) 27 | 28 | # Display the result and scores 29 | st.write(result) 30 | st.write("Player Score:", game.player_score) 31 | st.write("Computer Score:", game.computer_score) 32 | except ValueError as e: 33 | # Handle invalid choices by displaying an error message 34 | st.write("Error:", str(e)) 35 | -------------------------------------------------------------------------------- /07-Streamlit/rock_paper_scissors/game.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | class RockPaperScissors: 4 | def __init__(self): 5 | self.choices = ["rock", "paper", "scissors"] 6 | self.player_score = 0 7 | self.computer_score = 0 8 | 9 | def play(self, player_choice): 10 | # Randomly select the computer's choice 11 | computer_choice = random.choice(self.choices) 12 | 13 | # Validate the player's choice 14 | if player_choice not in self.choices: 15 | raise ValueError("Invalid choice. Please select 'rock', 'paper', or 'scissors'.") 16 | 17 | # Determine the result based on the choices 18 | if player_choice == computer_choice: 19 | result = "It's a tie!" 20 | elif ( 21 | (player_choice == "rock" and computer_choice == "scissors") or 22 | (player_choice == "paper" and computer_choice == "rock") or 23 | (player_choice == "scissors" and computer_choice == "paper") 24 | ): 25 | # Player wins 26 | self.player_score += 1 27 | result = "You win!" 28 | else: 29 | # Computer wins 30 | self.computer_score += 1 31 | result = "Computer wins!" 32 | 33 | return result, computer_choice 34 | -------------------------------------------------------------------------------- /08-File_folder_Date/dummy_folder/new_directory/dummy.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/08-File_folder_Date/dummy_folder/new_directory/dummy.txt -------------------------------------------------------------------------------- /08-File_folder_Date/example.txt: -------------------------------------------------------------------------------- 1 | The seek() and tell() functions are used in Python to control the current position within a file and to determine the current position, respectively. -------------------------------------------------------------------------------- /08-File_folder_Date/output.txt: -------------------------------------------------------------------------------- 1 | First line. 2 | Second line. 3 | Third line. 4 | -------------------------------------------------------------------------------- /08-File_folder_Date/scenario.txt: -------------------------------------------------------------------------------- 1 | create a console-level application that allows users to manage a simple to-do list. Users can add tasks, view existing tasks, mark tasks as completed, and delete tasks. We'll use file handling techniques to store the tasks in a text file. 2 | 3 | Here's how the application might work: 4 | 5 | When the application starts, it checks if the task file exists. If not, it creates a new file to store tasks. 6 | 7 | The user is presented with a menu of options: 8 | 9 | Add a new task 10 | View existing tasks 11 | Mark a task as completed 12 | Delete a task 13 | Exit the application 14 | 15 | Based on the user's selection, the application performs the corresponding action. 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | import os 69 | 70 | # File path to store tasks 71 | TASK_FILE = 'tasks.txt' 72 | 73 | def create_task_file(): 74 | """Create a new task file if it doesn't exist.""" 75 | if not os.path.exists(TASK_FILE): 76 | with open(TASK_FILE, 'w') as file: 77 | pass # Create an empty file 78 | 79 | def add_task(task): 80 | """Add a new task to the task file.""" 81 | with open(TASK_FILE, 'a') as file: 82 | file.write(task + '\n') 83 | 84 | def view_tasks(): 85 | """View existing tasks.""" 86 | if os.path.exists(TASK_FILE): 87 | with open(TASK_FILE, 'r') as file: 88 | tasks = file.readlines() 89 | if tasks: 90 | print("Tasks:") 91 | for index, task in enumerate(tasks, start=1): 92 | print(f"{index}. {task.strip()}") 93 | else: 94 | print("No tasks.") 95 | else: 96 | print("No tasks.") 97 | 98 | # Define other functions for marking tasks as completed and deleting tasks 99 | 100 | def main(): 101 | """Main function to run the application.""" 102 | create_task_file() 103 | while True: 104 | print("\nMenu:") 105 | print("1. Add a new task") 106 | print("2. View existing tasks") 107 | print("3. Mark a task as completed") 108 | print("4. Delete a task") 109 | print("5. Exit") 110 | 111 | choice = input("Enter your choice: ") 112 | 113 | if choice == '1': 114 | task = input("Enter the task: ") 115 | add_task(task) 116 | print("Task added.") 117 | elif choice == '2': 118 | view_tasks() 119 | # Add other options for marking tasks as completed, deleting tasks, and exiting the application 120 | elif choice == '5': 121 | print("Exiting...") 122 | break 123 | else: 124 | print("Invalid choice. Please try again.") 125 | 126 | if __name__ == "__main__": 127 | main() 128 | -------------------------------------------------------------------------------- /08-File_folder_Date/solution_task_01.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | def create_file(file_name): 4 | try: 5 | with open(file_name, 'w') as file: 6 | print(f"File '{file_name}' created successfully.") 7 | except OSError as e: 8 | print(f"Error: {e}") 9 | 10 | def write_to_file(file_name, content): 11 | try: 12 | with open(file_name, 'w') as file: 13 | file.write(content) 14 | print(f"Content written to '{file_name}' successfully.") 15 | except OSError as e: 16 | print(f"Error: {e}") 17 | 18 | def read_file(file_name): 19 | try: 20 | with open(file_name, 'r') as file: 21 | content = file.read() 22 | print(f"Content of '{file_name}':\n{content}") 23 | except FileNotFoundError as e: 24 | print(f"Error: {e}") 25 | 26 | def append_to_file(file_name, content): 27 | try: 28 | with open(file_name, 'a') as file: 29 | file.write(content) 30 | print(f"Content appended to '{file_name}' successfully.") 31 | except OSError as e: 32 | print(f"Error: {e}") 33 | 34 | def create_folder(folder_name): 35 | try: 36 | os.mkdir(folder_name) 37 | print(f"Folder '{folder_name}' created successfully.") 38 | except FileExistsError: 39 | print(f"Folder '{folder_name}' already exists.") 40 | except OSError as e: 41 | print(f"Error: {e}") 42 | 43 | def list_files_in_folder(folder_name): 44 | try: 45 | files = os.listdir(folder_name) 46 | print(f"Files in folder '{folder_name}':") 47 | for file in files: 48 | print(file) 49 | except FileNotFoundError as e: 50 | print(f"Error: {e}") 51 | 52 | # Example usage 53 | def main(): 54 | while True: 55 | print("\nChoose an option:") 56 | print("1. Create a file") 57 | print("2. Write to a file") 58 | print("3. Read from a file") 59 | print("4. Append to a file") 60 | print("5. Create a folder") 61 | print("6. List files in a folder") 62 | print("7. Exit") 63 | 64 | choice = input("Enter your choice: ") 65 | 66 | if choice == '1': 67 | file_name = input("Enter file name: ") 68 | create_file(file_name) 69 | elif choice == '2': 70 | file_name = input("Enter file name: ") 71 | content = input("Enter content: ") 72 | write_to_file(file_name, content) 73 | elif choice == '3': 74 | file_name = input("Enter file name: ") 75 | read_file(file_name) 76 | elif choice == '4': 77 | file_name = input("Enter file name: ") 78 | content = input("Enter content to append: ") 79 | append_to_file(file_name, content) 80 | elif choice == '5': 81 | folder_name = input("Enter folder name: ") 82 | create_folder(folder_name) 83 | elif choice == '6': 84 | folder_name = input("Enter folder name: ") 85 | list_files_in_folder(folder_name) 86 | elif choice == '7': 87 | print("Exiting program...") 88 | break 89 | else: 90 | print("Invalid choice. Please try again.") 91 | 92 | if __name__ == "__main__": 93 | main() 94 | -------------------------------------------------------------------------------- /08-File_folder_Date/task.txt: -------------------------------------------------------------------------------- 1 | Objective: 2 | Develop a console-based application to handle file and folder operations, 3 | including creating files, writing to files, reading from files, appending to files, 4 | creating folders, and listing files in folders. Implement error handling for various scenarios. 5 | 6 | Key Features: 7 | File Management: 8 | 9 | Create a new file. 10 | Write content to a file. 11 | Read content from a file. 12 | Append content to a file. 13 | 14 | Folder Management: 15 | 16 | Create a new folder. 17 | List files in a folder. 18 | 19 | Error and Exception Handling: 20 | 21 | Handle file not found errors. 22 | Handle file already exists errors. 23 | Handle permission denied errors. 24 | Handle other OS-related errors. 25 | 26 | Classes and Functions: 27 | - No explicit classes are needed for this application. 28 | - Functions for file and folder operations: 29 | - create_file() 30 | - write_to_file() 31 | - read_file() 32 | - append_to_file() 33 | - create_folder() 34 | - list_files_in_folder() 35 | - Input validation functions for user input. 36 | 37 | Steps to Complete the Code: 38 | 1. Define functions for each file and folder operation with error handling. 39 | 2. Implement input validation functions for user input. 40 | 3. Create a main function to provide a menu-driven interface for users to choose operations. 41 | 4. Handle exceptions and display appropriate error messages. 42 | 5. Test the application with various scenarios, including creating files/folders, reading/writing files, and listing files in folders. 43 | -------------------------------------------------------------------------------- /08-File_folder_Date/test.txt: -------------------------------------------------------------------------------- 1 | This method is called on the file object f to close the file once you're done 2 | working with it. It's important to close the file to release system resources and 3 | ensure that all data is written to the file. -------------------------------------------------------------------------------- /09-Numpy/cheatsheet.txt: -------------------------------------------------------------------------------- 1 | https://assets.datacamp.com/blog_assets/Numpy_Python_Cheat_Sheet.pdf -------------------------------------------------------------------------------- /10-Pandas/data/Iris.csv: -------------------------------------------------------------------------------- 1 | Id,SepalLengthCm,SepalWidthCm,PetalLengthCm,PetalWidthCm,Species 2 | 1,5.1,3.5,1.4,0.2,Iris-setosa 3 | 2,4.9,3.0,1.4,0.2,Iris-setosa 4 | 3,4.7,3.2,1.3,0.2,Iris-setosa 5 | 4,4.6,3.1,1.5,0.2,Iris-setosa 6 | 5,5.0,3.6,1.4,0.2,Iris-setosa 7 | 6,5.4,3.9,1.7,0.4,Iris-setosa 8 | 7,4.6,3.4,1.4,0.3,Iris-setosa 9 | 8,5.0,3.4,1.5,0.2,Iris-setosa 10 | 9,4.4,2.9,1.4,0.2,Iris-setosa 11 | 10,4.9,3.1,1.5,0.1,Iris-setosa 12 | 11,5.4,3.7,1.5,0.2,Iris-setosa 13 | 12,4.8,3.4,1.6,0.2,Iris-setosa 14 | 13,4.8,3.0,1.4,0.1,Iris-setosa 15 | 14,4.3,3.0,1.1,0.1,Iris-setosa 16 | 15,5.8,4.0,1.2,0.2,Iris-setosa 17 | 16,5.7,4.4,1.5,0.4,Iris-setosa 18 | 17,5.4,3.9,1.3,0.4,Iris-setosa 19 | 18,5.1,3.5,1.4,0.3,Iris-setosa 20 | 19,5.7,3.8,1.7,0.3,Iris-setosa 21 | 20,5.1,3.8,1.5,0.3,Iris-setosa 22 | 21,5.4,3.4,1.7,0.2,Iris-setosa 23 | 22,5.1,3.7,1.5,0.4,Iris-setosa 24 | 23,4.6,3.6,1.0,0.2,Iris-setosa 25 | 24,5.1,3.3,1.7,0.5,Iris-setosa 26 | 25,4.8,3.4,1.9,0.2,Iris-setosa 27 | 26,5.0,3.0,1.6,0.2,Iris-setosa 28 | 27,5.0,3.4,1.6,0.4,Iris-setosa 29 | 28,5.2,3.5,1.5,0.2,Iris-setosa 30 | 29,5.2,3.4,1.4,0.2,Iris-setosa 31 | 30,4.7,3.2,1.6,0.2,Iris-setosa 32 | 31,4.8,3.1,1.6,0.2,Iris-setosa 33 | 32,5.4,3.4,1.5,0.4,Iris-setosa 34 | 33,5.2,4.1,1.5,0.1,Iris-setosa 35 | 34,5.5,4.2,1.4,0.2,Iris-setosa 36 | 35,4.9,3.1,1.5,0.1,Iris-setosa 37 | 36,5.0,3.2,1.2,0.2,Iris-setosa 38 | 37,5.5,3.5,1.3,0.2,Iris-setosa 39 | 38,4.9,3.1,1.5,0.1,Iris-setosa 40 | 39,4.4,3.0,1.3,0.2,Iris-setosa 41 | 40,5.1,3.4,1.5,0.2,Iris-setosa 42 | 41,5.0,3.5,1.3,0.3,Iris-setosa 43 | 42,4.5,2.3,1.3,0.3,Iris-setosa 44 | 43,4.4,3.2,1.3,0.2,Iris-setosa 45 | 44,5.0,3.5,1.6,0.6,Iris-setosa 46 | 45,5.1,3.8,1.9,0.4,Iris-setosa 47 | 46,4.8,3.0,1.4,0.3,Iris-setosa 48 | 47,5.1,3.8,1.6,0.2,Iris-setosa 49 | 48,4.6,3.2,1.4,0.2,Iris-setosa 50 | 49,5.3,3.7,1.5,0.2,Iris-setosa 51 | 50,5.0,3.3,1.4,0.2,Iris-setosa 52 | 51,7.0,3.2,4.7,1.4,Iris-versicolor 53 | 52,6.4,3.2,4.5,1.5,Iris-versicolor 54 | 53,6.9,3.1,4.9,1.5,Iris-versicolor 55 | 54,5.5,2.3,4.0,1.3,Iris-versicolor 56 | 55,6.5,2.8,4.6,1.5,Iris-versicolor 57 | 56,5.7,2.8,4.5,1.3,Iris-versicolor 58 | 57,6.3,3.3,4.7,1.6,Iris-versicolor 59 | 58,4.9,2.4,3.3,1.0,Iris-versicolor 60 | 59,6.6,2.9,4.6,1.3,Iris-versicolor 61 | 60,5.2,2.7,3.9,1.4,Iris-versicolor 62 | 61,5.0,2.0,3.5,1.0,Iris-versicolor 63 | 62,5.9,3.0,4.2,1.5,Iris-versicolor 64 | 63,6.0,2.2,4.0,1.0,Iris-versicolor 65 | 64,6.1,2.9,4.7,1.4,Iris-versicolor 66 | 65,5.6,2.9,3.6,1.3,Iris-versicolor 67 | 66,6.7,3.1,4.4,1.4,Iris-versicolor 68 | 67,5.6,3.0,4.5,1.5,Iris-versicolor 69 | 68,5.8,2.7,4.1,1.0,Iris-versicolor 70 | 69,6.2,2.2,4.5,1.5,Iris-versicolor 71 | 70,5.6,2.5,3.9,1.1,Iris-versicolor 72 | 71,5.9,3.2,4.8,1.8,Iris-versicolor 73 | 72,6.1,2.8,4.0,1.3,Iris-versicolor 74 | 73,6.3,2.5,4.9,1.5,Iris-versicolor 75 | 74,6.1,2.8,4.7,1.2,Iris-versicolor 76 | 75,6.4,2.9,4.3,1.3,Iris-versicolor 77 | 76,6.6,3.0,4.4,1.4,Iris-versicolor 78 | 77,6.8,2.8,4.8,1.4,Iris-versicolor 79 | 78,6.7,3.0,5.0,1.7,Iris-versicolor 80 | 79,6.0,2.9,4.5,1.5,Iris-versicolor 81 | 80,5.7,2.6,3.5,1.0,Iris-versicolor 82 | 81,5.5,2.4,3.8,1.1,Iris-versicolor 83 | 82,5.5,2.4,3.7,1.0,Iris-versicolor 84 | 83,5.8,2.7,3.9,1.2,Iris-versicolor 85 | 84,6.0,2.7,5.1,1.6,Iris-versicolor 86 | 85,5.4,3.0,4.5,1.5,Iris-versicolor 87 | 86,6.0,3.4,4.5,1.6,Iris-versicolor 88 | 87,6.7,3.1,4.7,1.5,Iris-versicolor 89 | 88,6.3,2.3,4.4,1.3,Iris-versicolor 90 | 89,5.6,3.0,4.1,1.3,Iris-versicolor 91 | 90,5.5,2.5,4.0,1.3,Iris-versicolor 92 | 91,5.5,2.6,4.4,1.2,Iris-versicolor 93 | 92,6.1,3.0,4.6,1.4,Iris-versicolor 94 | 93,5.8,2.6,4.0,1.2,Iris-versicolor 95 | 94,5.0,2.3,3.3,1.0,Iris-versicolor 96 | 95,5.6,2.7,4.2,1.3,Iris-versicolor 97 | 96,5.7,3.0,4.2,1.2,Iris-versicolor 98 | 97,5.7,2.9,4.2,1.3,Iris-versicolor 99 | 98,6.2,2.9,4.3,1.3,Iris-versicolor 100 | 99,5.1,2.5,3.0,1.1,Iris-versicolor 101 | 100,5.7,2.8,4.1,1.3,Iris-versicolor 102 | 101,6.3,3.3,6.0,2.5,Iris-virginica 103 | 102,5.8,2.7,5.1,1.9,Iris-virginica 104 | 103,7.1,3.0,5.9,2.1,Iris-virginica 105 | 104,6.3,2.9,5.6,1.8,Iris-virginica 106 | 105,6.5,3.0,5.8,2.2,Iris-virginica 107 | 106,7.6,3.0,6.6,2.1,Iris-virginica 108 | 107,4.9,2.5,4.5,1.7,Iris-virginica 109 | 108,7.3,2.9,6.3,1.8,Iris-virginica 110 | 109,6.7,2.5,5.8,1.8,Iris-virginica 111 | 110,7.2,3.6,6.1,2.5,Iris-virginica 112 | 111,6.5,3.2,5.1,2.0,Iris-virginica 113 | 112,6.4,2.7,5.3,1.9,Iris-virginica 114 | 113,6.8,3.0,5.5,2.1,Iris-virginica 115 | 114,5.7,2.5,5.0,2.0,Iris-virginica 116 | 115,5.8,2.8,5.1,2.4,Iris-virginica 117 | 116,6.4,3.2,5.3,2.3,Iris-virginica 118 | 117,6.5,3.0,5.5,1.8,Iris-virginica 119 | 118,7.7,3.8,6.7,2.2,Iris-virginica 120 | 119,7.7,2.6,6.9,2.3,Iris-virginica 121 | 120,6.0,2.2,5.0,1.5,Iris-virginica 122 | 121,6.9,3.2,5.7,2.3,Iris-virginica 123 | 122,5.6,2.8,4.9,2.0,Iris-virginica 124 | 123,7.7,2.8,6.7,2.0,Iris-virginica 125 | 124,6.3,2.7,4.9,1.8,Iris-virginica 126 | 125,6.7,3.3,5.7,2.1,Iris-virginica 127 | 126,7.2,3.2,6.0,1.8,Iris-virginica 128 | 127,6.2,2.8,4.8,1.8,Iris-virginica 129 | 128,6.1,3.0,4.9,1.8,Iris-virginica 130 | 129,6.4,2.8,5.6,2.1,Iris-virginica 131 | 130,7.2,3.0,5.8,1.6,Iris-virginica 132 | 131,7.4,2.8,6.1,1.9,Iris-virginica 133 | 132,7.9,3.8,6.4,2.0,Iris-virginica 134 | 133,6.4,2.8,5.6,2.2,Iris-virginica 135 | 134,6.3,2.8,5.1,1.5,Iris-virginica 136 | 135,6.1,2.6,5.6,1.4,Iris-virginica 137 | 136,7.7,3.0,6.1,2.3,Iris-virginica 138 | 137,6.3,3.4,5.6,2.4,Iris-virginica 139 | 138,6.4,3.1,5.5,1.8,Iris-virginica 140 | 139,6.0,3.0,4.8,1.8,Iris-virginica 141 | 140,6.9,3.1,5.4,2.1,Iris-virginica 142 | 141,6.7,3.1,5.6,2.4,Iris-virginica 143 | 142,6.9,3.1,5.1,2.3,Iris-virginica 144 | 143,5.8,2.7,5.1,1.9,Iris-virginica 145 | 144,6.8,3.2,5.9,2.3,Iris-virginica 146 | 145,6.7,3.3,5.7,2.5,Iris-virginica 147 | 146,6.7,3.0,5.2,2.3,Iris-virginica 148 | 147,6.3,2.5,5.0,1.9,Iris-virginica 149 | 148,6.5,3.0,5.2,2.0,Iris-virginica 150 | 149,6.2,3.4,5.4,2.3,Iris-virginica 151 | 150,5.9,3.0,5.1,1.8,Iris-virginica 152 | -------------------------------------------------------------------------------- /10-Pandas/data/retail_store_sales.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/10-Pandas/data/retail_store_sales.xlsx -------------------------------------------------------------------------------- /10-Pandas/data/temp/new_csv_file.csv: -------------------------------------------------------------------------------- 1 | ,Name,Age,Rating 2 | 0,Tom,25,4.23 3 | 1,Jack,26,4.1 4 | 2,Steve,25,3.4 5 | 3,Ricky,35,5.0 6 | 4,Vin,23, 7 | 5,James,33,4.7 8 | 6,Smith,31,3.1 9 | -------------------------------------------------------------------------------- /10-Pandas/data/temp/new_csv_file_no_index.csv: -------------------------------------------------------------------------------- 1 | Name,Age,Rating 2 | Tom,25,4.23 3 | Jack,26,4.1 4 | Steve,25,3.4 5 | Ricky,35,5.0 6 | Vin,23, 7 | James,33,4.7 8 | Smith,31,3.1 9 | -------------------------------------------------------------------------------- /10-Pandas/data/temp/new_excel_file.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/10-Pandas/data/temp/new_excel_file.xlsx -------------------------------------------------------------------------------- /10-Pandas/data/temp/new_excel_file_noIndex.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/10-Pandas/data/temp/new_excel_file_noIndex.xlsx -------------------------------------------------------------------------------- /10-Pandas/data/temp/new_iris_no_index.csv: -------------------------------------------------------------------------------- 1 | Id,SepalLengthCm,SepalWidthCm,PetalLengthCm,PetalWidthCm,Species 2 | 1,5.1,3.5,1.4,0.2,Iris-setosa 3 | 2,4.9,3.0,1.4,0.2,Iris-setosa 4 | 3,4.7,3.2,1.3,0.2,Iris-setosa 5 | 4,4.6,3.1,1.5,0.2,Iris-setosa 6 | 5,5.0,3.6,1.4,0.2,Iris-setosa 7 | 6,5.4,3.9,1.7,0.4,Iris-setosa 8 | 7,4.6,3.4,1.4,0.3,Iris-setosa 9 | 8,5.0,3.4,1.5,0.2,Iris-setosa 10 | 9,4.4,2.9,1.4,0.2,Iris-setosa 11 | 10,4.9,3.1,1.5,0.1,Iris-setosa 12 | 11,5.4,3.7,1.5,0.2,Iris-setosa 13 | 12,4.8,3.4,1.6,0.2,Iris-setosa 14 | 13,4.8,3.0,1.4,0.1,Iris-setosa 15 | 14,4.3,3.0,1.1,0.1,Iris-setosa 16 | 15,5.8,4.0,1.2,0.2,Iris-setosa 17 | 16,5.7,4.4,1.5,0.4,Iris-setosa 18 | 17,5.4,3.9,1.3,0.4,Iris-setosa 19 | 18,5.1,3.5,1.4,0.3,Iris-setosa 20 | 19,5.7,3.8,1.7,0.3,Iris-setosa 21 | 20,5.1,3.8,1.5,0.3,Iris-setosa 22 | 21,5.4,3.4,1.7,0.2,Iris-setosa 23 | 22,5.1,3.7,1.5,0.4,Iris-setosa 24 | 23,4.6,3.6,1.0,0.2,Iris-setosa 25 | 24,5.1,3.3,1.7,0.5,Iris-setosa 26 | 25,4.8,3.4,1.9,0.2,Iris-setosa 27 | 26,5.0,3.0,1.6,0.2,Iris-setosa 28 | 27,5.0,3.4,1.6,0.4,Iris-setosa 29 | 28,5.2,3.5,1.5,0.2,Iris-setosa 30 | 29,5.2,3.4,1.4,0.2,Iris-setosa 31 | 30,4.7,3.2,1.6,0.2,Iris-setosa 32 | 31,4.8,3.1,1.6,0.2,Iris-setosa 33 | 32,5.4,3.4,1.5,0.4,Iris-setosa 34 | 33,5.2,4.1,1.5,0.1,Iris-setosa 35 | 34,5.5,4.2,1.4,0.2,Iris-setosa 36 | 35,4.9,3.1,1.5,0.1,Iris-setosa 37 | 36,5.0,3.2,1.2,0.2,Iris-setosa 38 | 37,5.5,3.5,1.3,0.2,Iris-setosa 39 | 38,4.9,3.1,1.5,0.1,Iris-setosa 40 | 39,4.4,3.0,1.3,0.2,Iris-setosa 41 | 40,5.1,3.4,1.5,0.2,Iris-setosa 42 | 41,5.0,3.5,1.3,0.3,Iris-setosa 43 | 42,4.5,2.3,1.3,0.3,Iris-setosa 44 | 43,4.4,3.2,1.3,0.2,Iris-setosa 45 | 44,5.0,3.5,1.6,0.6,Iris-setosa 46 | 45,5.1,3.8,1.9,0.4,Iris-setosa 47 | 46,4.8,3.0,1.4,0.3,Iris-setosa 48 | 47,5.1,3.8,1.6,0.2,Iris-setosa 49 | 48,4.6,3.2,1.4,0.2,Iris-setosa 50 | 49,5.3,3.7,1.5,0.2,Iris-setosa 51 | 50,5.0,3.3,1.4,0.2,Iris-setosa 52 | 51,7.0,3.2,4.7,1.4,Iris-versicolor 53 | 52,6.4,3.2,4.5,1.5,Iris-versicolor 54 | 53,6.9,3.1,4.9,1.5,Iris-versicolor 55 | 54,5.5,2.3,4.0,1.3,Iris-versicolor 56 | 55,6.5,2.8,4.6,1.5,Iris-versicolor 57 | 56,5.7,2.8,4.5,1.3,Iris-versicolor 58 | 57,6.3,3.3,4.7,1.6,Iris-versicolor 59 | 58,4.9,2.4,3.3,1.0,Iris-versicolor 60 | 59,6.6,2.9,4.6,1.3,Iris-versicolor 61 | 60,5.2,2.7,3.9,1.4,Iris-versicolor 62 | 61,5.0,2.0,3.5,1.0,Iris-versicolor 63 | 62,5.9,3.0,4.2,1.5,Iris-versicolor 64 | 63,6.0,2.2,4.0,1.0,Iris-versicolor 65 | 64,6.1,2.9,4.7,1.4,Iris-versicolor 66 | 65,5.6,2.9,3.6,1.3,Iris-versicolor 67 | 66,6.7,3.1,4.4,1.4,Iris-versicolor 68 | 67,5.6,3.0,4.5,1.5,Iris-versicolor 69 | 68,5.8,2.7,4.1,1.0,Iris-versicolor 70 | 69,6.2,2.2,4.5,1.5,Iris-versicolor 71 | 70,5.6,2.5,3.9,1.1,Iris-versicolor 72 | 71,5.9,3.2,4.8,1.8,Iris-versicolor 73 | 72,6.1,2.8,4.0,1.3,Iris-versicolor 74 | 73,6.3,2.5,4.9,1.5,Iris-versicolor 75 | 74,6.1,2.8,4.7,1.2,Iris-versicolor 76 | 75,6.4,2.9,4.3,1.3,Iris-versicolor 77 | 76,6.6,3.0,4.4,1.4,Iris-versicolor 78 | 77,6.8,2.8,4.8,1.4,Iris-versicolor 79 | 78,6.7,3.0,5.0,1.7,Iris-versicolor 80 | 79,6.0,2.9,4.5,1.5,Iris-versicolor 81 | 80,5.7,2.6,3.5,1.0,Iris-versicolor 82 | 81,5.5,2.4,3.8,1.1,Iris-versicolor 83 | 82,5.5,2.4,3.7,1.0,Iris-versicolor 84 | 83,5.8,2.7,3.9,1.2,Iris-versicolor 85 | 84,6.0,2.7,5.1,1.6,Iris-versicolor 86 | 85,5.4,3.0,4.5,1.5,Iris-versicolor 87 | 86,6.0,3.4,4.5,1.6,Iris-versicolor 88 | 87,6.7,3.1,4.7,1.5,Iris-versicolor 89 | 88,6.3,2.3,4.4,1.3,Iris-versicolor 90 | 89,5.6,3.0,4.1,1.3,Iris-versicolor 91 | 90,5.5,2.5,4.0,1.3,Iris-versicolor 92 | 91,5.5,2.6,4.4,1.2,Iris-versicolor 93 | 92,6.1,3.0,4.6,1.4,Iris-versicolor 94 | 93,5.8,2.6,4.0,1.2,Iris-versicolor 95 | 94,5.0,2.3,3.3,1.0,Iris-versicolor 96 | 95,5.6,2.7,4.2,1.3,Iris-versicolor 97 | 96,5.7,3.0,4.2,1.2,Iris-versicolor 98 | 97,5.7,2.9,4.2,1.3,Iris-versicolor 99 | 98,6.2,2.9,4.3,1.3,Iris-versicolor 100 | 99,5.1,2.5,3.0,1.1,Iris-versicolor 101 | 100,5.7,2.8,4.1,1.3,Iris-versicolor 102 | 101,6.3,3.3,6.0,2.5,Iris-virginica 103 | 102,5.8,2.7,5.1,1.9,Iris-virginica 104 | 103,7.1,3.0,5.9,2.1,Iris-virginica 105 | 104,6.3,2.9,5.6,1.8,Iris-virginica 106 | 105,6.5,3.0,5.8,2.2,Iris-virginica 107 | 106,7.6,3.0,6.6,2.1,Iris-virginica 108 | 107,4.9,2.5,4.5,1.7,Iris-virginica 109 | 108,7.3,2.9,6.3,1.8,Iris-virginica 110 | 109,6.7,2.5,5.8,1.8,Iris-virginica 111 | 110,7.2,3.6,6.1,2.5,Iris-virginica 112 | 111,6.5,3.2,5.1,2.0,Iris-virginica 113 | 112,6.4,2.7,5.3,1.9,Iris-virginica 114 | 113,6.8,3.0,5.5,2.1,Iris-virginica 115 | 114,5.7,2.5,5.0,2.0,Iris-virginica 116 | 115,5.8,2.8,5.1,2.4,Iris-virginica 117 | 116,6.4,3.2,5.3,2.3,Iris-virginica 118 | 117,6.5,3.0,5.5,1.8,Iris-virginica 119 | 118,7.7,3.8,6.7,2.2,Iris-virginica 120 | 119,7.7,2.6,6.9,2.3,Iris-virginica 121 | 120,6.0,2.2,5.0,1.5,Iris-virginica 122 | 121,6.9,3.2,5.7,2.3,Iris-virginica 123 | 122,5.6,2.8,4.9,2.0,Iris-virginica 124 | 123,7.7,2.8,6.7,2.0,Iris-virginica 125 | 124,6.3,2.7,4.9,1.8,Iris-virginica 126 | 125,6.7,3.3,5.7,2.1,Iris-virginica 127 | 126,7.2,3.2,6.0,1.8,Iris-virginica 128 | 127,6.2,2.8,4.8,1.8,Iris-virginica 129 | 128,6.1,3.0,4.9,1.8,Iris-virginica 130 | 129,6.4,2.8,5.6,2.1,Iris-virginica 131 | 130,7.2,3.0,5.8,1.6,Iris-virginica 132 | 131,7.4,2.8,6.1,1.9,Iris-virginica 133 | 132,7.9,3.8,6.4,2.0,Iris-virginica 134 | 133,6.4,2.8,5.6,2.2,Iris-virginica 135 | 134,6.3,2.8,5.1,1.5,Iris-virginica 136 | 135,6.1,2.6,5.6,1.4,Iris-virginica 137 | 136,7.7,3.0,6.1,2.3,Iris-virginica 138 | 137,6.3,3.4,5.6,2.4,Iris-virginica 139 | 138,6.4,3.1,5.5,1.8,Iris-virginica 140 | 139,6.0,3.0,4.8,1.8,Iris-virginica 141 | 140,6.9,3.1,5.4,2.1,Iris-virginica 142 | 141,6.7,3.1,5.6,2.4,Iris-virginica 143 | 142,6.9,3.1,5.1,2.3,Iris-virginica 144 | 143,5.8,2.7,5.1,1.9,Iris-virginica 145 | 144,6.8,3.2,5.9,2.3,Iris-virginica 146 | 145,6.7,3.3,5.7,2.5,Iris-virginica 147 | 146,6.7,3.0,5.2,2.3,Iris-virginica 148 | 147,6.3,2.5,5.0,1.9,Iris-virginica 149 | 148,6.5,3.0,5.2,2.0,Iris-virginica 150 | 149,6.2,3.4,5.4,2.3,Iris-virginica 151 | 150,5.9,3.0,5.1,1.8,Iris-virginica 152 | -------------------------------------------------------------------------------- /10-Pandas/data/temp/updated_weather_data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/10-Pandas/data/temp/updated_weather_data.xlsx -------------------------------------------------------------------------------- /10-Pandas/data/weather_data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/10-Pandas/data/weather_data.xlsx -------------------------------------------------------------------------------- /10-Pandas/image/00_pandas.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/10-Pandas/image/00_pandas.jpg -------------------------------------------------------------------------------- /10-Pandas/image/01_table_dataframe.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/10-Pandas/image/01_table_dataframe.PNG -------------------------------------------------------------------------------- /10-Pandas/image/02_io_readwrite.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/10-Pandas/image/02_io_readwrite.PNG -------------------------------------------------------------------------------- /10-Pandas/image/03_reduction.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/10-Pandas/image/03_reduction.PNG -------------------------------------------------------------------------------- /10-Pandas/image/04_iris_setosa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/10-Pandas/image/04_iris_setosa.jpg -------------------------------------------------------------------------------- /10-Pandas/image/05_iris_versicolor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/10-Pandas/image/05_iris_versicolor.jpg -------------------------------------------------------------------------------- /10-Pandas/image/06_iris_virginica.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/10-Pandas/image/06_iris_virginica.jpg -------------------------------------------------------------------------------- /10-Pandas/image/07_subset_columns.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/10-Pandas/image/07_subset_columns.PNG -------------------------------------------------------------------------------- /10-Pandas/image/08_newcolumn.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/10-Pandas/image/08_newcolumn.PNG -------------------------------------------------------------------------------- /11-SQL/project/architecutre.md: -------------------------------------------------------------------------------- 1 | --- 2 | ## 🧩 Modules & Classes (Pseudocode) 3 | --- 4 | 5 | ### 1. `input_reader.py` 6 | 7 | ```python 8 | CLASS InputReader: 9 | METHOD read_from_console() -> dict: 10 | PROMPT user for: 11 | - name 12 | - age 13 | - email 14 | - phone 15 | - gender 16 | - country 17 | - dob 18 | RETURN dictionary of raw inputs 19 | ``` 20 | 21 | --- 22 | 23 | ### 2. `data_processor.py` 24 | 25 | ```python 26 | CLASS DataProcessor: 27 | METHOD preprocess(raw_data: dict) -> User: 28 | VALIDATE and CLEAN: 29 | - Trim and store name 30 | - Convert and validate age 31 | - Format and validate email using regex 32 | - Strip non-numeric from phone and validate length 33 | - Normalize gender (e.g., "m" → "Male") 34 | - Capitalize country name 35 | - Accept date of birth (dob) 36 | 37 | RETURN User object 38 | 39 | METHOD _normalize_gender(gender: str) -> str: 40 | CONVERT to lower, map values to "Male", "Female", or "Other" 41 | 42 | METHOD _capitalize(text: str) -> str: 43 | RETURN capitalized version of input 44 | ``` 45 | 46 | --- 47 | 48 | ### 3. `user.py` 49 | 50 | ```python 51 | CLASS User: 52 | CONTAINS attributes: 53 | - name 54 | - age 55 | - email 56 | - phone 57 | - gender 58 | - country 59 | - dob 60 | 61 | METHOD __init__(...): 62 | ASSIGN parameters to attributes 63 | ``` 64 | 65 | --- 66 | 67 | ### 4. `database_handler.py` 68 | 69 | ```python 70 | CLASS DatabaseHandler: 71 | METHOD __init__(host, user, password, db_name): 72 | CONNECT to MySQL server 73 | CALL _init_db() 74 | SWITCH to db_name 75 | CALL _init_table() 76 | 77 | METHOD _init_db(): 78 | CHECK if database exists 79 | IF not: 80 | CREATE database 81 | 82 | METHOD _init_table(): 83 | CHECK if users table exists 84 | IF not: 85 | CREATE table with schema 86 | 87 | METHOD insert_user(user: User): 88 | PREPARE insert SQL query 89 | EXECUTE insert with user fields 90 | 91 | METHOD close(): 92 | CLOSE cursor and connection 93 | ``` 94 | 95 | --- 96 | 97 | ### 5. `main.py` 98 | 99 | ```python 100 | FUNCTION main(): 101 | INITIALIZE InputReader 102 | raw_data = READ from console 103 | 104 | INITIALIZE DataProcessor 105 | user = PREPROCESS raw_data 106 | 107 | INITIALIZE DatabaseHandler 108 | INSERT user into database 109 | CLOSE database connection 110 | 111 | IF script is main: 112 | CALL main() 113 | ``` 114 | 115 | --- 116 | 117 | ## 🔁 Data Flow Summary 118 | 119 | ```text 120 | User input (console) 121 | ↓ 122 | InputReader.read_from_console() 123 | ↓ 124 | Raw dict of user fields 125 | ↓ 126 | DataProcessor.preprocess() 127 | ↓ 128 | Structured and validated User object 129 | ↓ 130 | DatabaseHandler.insert_user(user) 131 | ↓ 132 | User data inserted into MySQL ✅ 133 | ``` 134 | -------------------------------------------------------------------------------- /11-SQL/sql/Cloning in SQL.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/11-SQL/sql/Cloning in SQL.docx -------------------------------------------------------------------------------- /11-SQL/sql/DML,DCL, Table create,delete,drop...docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/11-SQL/sql/DML,DCL, Table create,delete,drop...docx -------------------------------------------------------------------------------- /11-SQL/sql/IN and Between.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/11-SQL/sql/IN and Between.docx -------------------------------------------------------------------------------- /11-SQL/sql/Mysql - DataType.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/11-SQL/sql/Mysql - DataType.docx -------------------------------------------------------------------------------- /11-SQL/sql/SQL - clauses.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/11-SQL/sql/SQL - clauses.docx -------------------------------------------------------------------------------- /11-SQL/sql/Stored Procedure.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/11-SQL/sql/Stored Procedure.docx -------------------------------------------------------------------------------- /11-SQL/sql/null,like,min,update.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/11-SQL/sql/null,like,min,update.docx -------------------------------------------------------------------------------- /11-SQL/sql/sql joins.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/11-SQL/sql/sql joins.docx -------------------------------------------------------------------------------- /11-SQL/sqlite/database.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/11-SQL/sqlite/database.db -------------------------------------------------------------------------------- /11-SQL/superstore.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/11-SQL/superstore.xlsx -------------------------------------------------------------------------------- /13-Threading/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/13-Threading/image.png -------------------------------------------------------------------------------- /14-Unit testing/__pycache__/cap.cpython-312.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/14-Unit testing/__pycache__/cap.cpython-312.pyc -------------------------------------------------------------------------------- /14-Unit testing/cap.py: -------------------------------------------------------------------------------- 1 | def cap_text(text): 2 | return text.capitalize() 3 | -------------------------------------------------------------------------------- /14-Unit testing/simple1.py: -------------------------------------------------------------------------------- 1 | """ 2 | A very simple script. 3 | """ 4 | 5 | def myfunc(): 6 | """ 7 | An extremely simple function. 8 | """ 9 | first = 1 10 | second = 2 11 | print(first) 12 | print(second) 13 | 14 | myfunc() 15 | -------------------------------------------------------------------------------- /14-Unit testing/test.py: -------------------------------------------------------------------------------- 1 | 2 | def myfunc(): 3 | """ 4 | An extremely simple function. 5 | """ 6 | first = 1 7 | second = 2 8 | print(first) 9 | 10 | 11 | myfunc() 12 | 13 | -------------------------------------------------------------------------------- /14-Unit testing/test_cap.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import cap 3 | 4 | class TestCap(unittest.TestCase): 5 | 6 | def test_one_word(self): 7 | text = 'python' 8 | result = cap.cap_text(text) # function calling 9 | self.assertEqual(result, 'Python') 10 | 11 | def test_multiple_words(self): 12 | text = 'hi python' 13 | result = cap.cap_text(text) 14 | self.assertEqual(result, 'Hi Python') 15 | 16 | if __name__ == '__main__': 17 | unittest.main() 18 | -------------------------------------------------------------------------------- /15-Decorator/large_file.txt: -------------------------------------------------------------------------------- 1 | Smt. Droupadi Murmu was sworn in as the 15th President of India on 25 July, 2022. Previously, she was the Governor of Jharkhand from 2015 to 2021. She has devoted her life to empowering the downtrodden and the marginalised sections and deepening the democratic values. 2 | 3 | Early Life and Education 4 | 5 | Born in a Santhali tribal family on 20 June, 1958 at Uparbeda village, Mayurbhanj, Odisha, Smt. Murmu’s early life was marked by hardships and struggle. On completion of primary education from the village school, she went to Bhubaneswar on her own initiative to continue her studies. She earned the degree of Bachelor of Arts from Ramadevi Women’s College, Bhubaneswar and became the first woman from her village to receive college education. 6 | 7 | Professional Career 8 | 9 | From 1979 to 1983, Smt. Murmu served as a Junior Assistant in the Irrigation and Power Department, Government of Odisha. Later, she served as an honorary teacher at Sri Aurobindo Integral Education Centre, Rairangpur, from 1994 to 1997. 10 | 11 | Public Life 12 | 13 | In 2000, Smt. Murmu was elected from the Rairangpur constituency as a Member of the Legislative Assembly of Odisha and continued to hold the post till 2009, serving two terms. During this period, she served as Minister of State (Independent Charge), Department of Commerce and Transport in the Government of Odisha from March 6, 2000 to August 6, 2002 and as Minister of State (Independent Charge), Department of Fisheries and Animal Resources Development, Government of Odisha from Augu -------------------------------------------------------------------------------- /16-Counters,OS,Regex/00-Collections-Module.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Collections Module\n", 8 | "\n", 9 | "The collections module is a built-in module that implements specialized container data types providing alternatives to Python’s general purpose built-in containers. We've already gone over the basics: dict, list, set, and tuple.\n", 10 | "\n", 11 | "Now we'll learn about the alternatives that the collections module provides.\n", 12 | "\n", 13 | "## Counter\n", 14 | "\n", 15 | "*Counter* is a *dict* subclass which helps count hashable objects. Inside of it elements are stored as dictionary keys and the counts of the objects are stored as the value.\n", 16 | "\n", 17 | "Let's see how it can be used:" 18 | ] 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": 8, 23 | "metadata": { 24 | "collapsed": true 25 | }, 26 | "outputs": [], 27 | "source": [ 28 | "from collections import Counter" 29 | ] 30 | }, 31 | { 32 | "cell_type": "markdown", 33 | "metadata": {}, 34 | "source": [ 35 | "**Counter() with lists**" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": 4, 41 | "metadata": {}, 42 | "outputs": [ 43 | { 44 | "data": { 45 | "text/plain": [ 46 | "Counter({1: 6, 2: 6, 3: 4, 12: 1, 32: 1, 21: 1, 223: 1})" 47 | ] 48 | }, 49 | "execution_count": 4, 50 | "metadata": {}, 51 | "output_type": "execute_result" 52 | } 53 | ], 54 | "source": [ 55 | "lst = [1,2,2,2,2,3,3,3,1,2,1,12,3,2,32,1,21,1,223,1]\n", 56 | "\n", 57 | "Counter(lst)" 58 | ] 59 | }, 60 | { 61 | "cell_type": "markdown", 62 | "metadata": {}, 63 | "source": [ 64 | "**Counter with strings**" 65 | ] 66 | }, 67 | { 68 | "cell_type": "code", 69 | "execution_count": 3, 70 | "metadata": {}, 71 | "outputs": [ 72 | { 73 | "data": { 74 | "text/plain": [ 75 | "Counter({'a': 2, 'b': 7, 'h': 3, 's': 6})" 76 | ] 77 | }, 78 | "execution_count": 3, 79 | "metadata": {}, 80 | "output_type": "execute_result" 81 | } 82 | ], 83 | "source": [ 84 | "Counter('aabsbsbsbhshhbbsbs')" 85 | ] 86 | }, 87 | { 88 | "cell_type": "markdown", 89 | "metadata": {}, 90 | "source": [ 91 | "**Counter with words in a sentence**" 92 | ] 93 | }, 94 | { 95 | "cell_type": "code", 96 | "execution_count": 4, 97 | "metadata": {}, 98 | "outputs": [ 99 | { 100 | "data": { 101 | "text/plain": [ 102 | "Counter({'How': 1,\n", 103 | " 'does': 1,\n", 104 | " 'each': 3,\n", 105 | " 'in': 1,\n", 106 | " 'many': 1,\n", 107 | " 'sentence': 1,\n", 108 | " 'show': 1,\n", 109 | " 'this': 1,\n", 110 | " 'times': 2,\n", 111 | " 'up': 1,\n", 112 | " 'word': 3})" 113 | ] 114 | }, 115 | "execution_count": 4, 116 | "metadata": {}, 117 | "output_type": "execute_result" 118 | } 119 | ], 120 | "source": [ 121 | "s = 'How many times does each word show up in this sentence word times each each word'\n", 122 | "\n", 123 | "words = s.split()\n", 124 | "\n", 125 | "Counter(words)" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": 5, 131 | "metadata": {}, 132 | "outputs": [ 133 | { 134 | "data": { 135 | "text/plain": [ 136 | "[('each', 3), ('word', 3)]" 137 | ] 138 | }, 139 | "execution_count": 5, 140 | "metadata": {}, 141 | "output_type": "execute_result" 142 | } 143 | ], 144 | "source": [ 145 | "# Methods with Counter()\n", 146 | "c = Counter(words)\n", 147 | "\n", 148 | "c.most_common(2)" 149 | ] 150 | }, 151 | { 152 | "cell_type": "markdown", 153 | "metadata": {}, 154 | "source": [ 155 | "## Common patterns when using the Counter() object" 156 | ] 157 | }, 158 | { 159 | "cell_type": "markdown", 160 | "metadata": { 161 | "collapsed": true 162 | }, 163 | "source": [ 164 | " sum(c.values()) # total of all counts\n", 165 | " c.clear() # reset all counts\n", 166 | " list(c) # list unique elements\n", 167 | " set(c) # convert to a set\n", 168 | " dict(c) # convert to a regular dictionary\n", 169 | " c.items() # convert to a list of (elem, cnt) pairs\n", 170 | " Counter(dict(list_of_pairs)) # convert from a list of (elem, cnt) pairs\n", 171 | " c.most_common()[:-n-1:-1] # n least common elements\n", 172 | " c += Counter() # remove zero and negative counts" 173 | ] 174 | } 175 | ], 176 | "metadata": { 177 | "kernelspec": { 178 | "display_name": "Python 3.9.7 ('base')", 179 | "language": "python", 180 | "name": "python3" 181 | }, 182 | "language_info": { 183 | "codemirror_mode": { 184 | "name": "ipython", 185 | "version": 3 186 | }, 187 | "file_extension": ".py", 188 | "mimetype": "text/x-python", 189 | "name": "python", 190 | "nbconvert_exporter": "python", 191 | "pygments_lexer": "ipython3", 192 | "version": "3.9.7" 193 | }, 194 | "vscode": { 195 | "interpreter": { 196 | "hash": "adbf8baac3fd83462ba4d3cf155237b9080954f140b6d8291bc95ec68b06c358" 197 | } 198 | } 199 | }, 200 | "nbformat": 4, 201 | "nbformat_minor": 1 202 | } 203 | -------------------------------------------------------------------------------- /16-Counters,OS,Regex/subfolder/practice.txt: -------------------------------------------------------------------------------- 1 | test -------------------------------------------------------------------------------- /17-Flask/01_path_query_parameter.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, jsonify 2 | 3 | app = Flask(__name__) 4 | 5 | @app.route('/') 6 | def hello_world(): 7 | """ 8 | Return a simple 'Hello, World!' message. 9 | """ 10 | return "Hello, World!" 11 | 12 | @app.route('/sum') 13 | def sum_numbers(): 14 | """ 15 | Get query parameters 'a' and 'b' and return their sum. 16 | 17 | Returns: 18 | JSON object: {"result": sum} 19 | sum (int): The sum of parameters 'a' and 'b'. 20 | 21 | If either 'a' or 'b' is missing, returns a JSON object with an error message. 22 | """ 23 | a = request.args.get('a', type=int) 24 | b = request.args.get('b', type=int) 25 | if a is None or b is None: 26 | return jsonify(error="Parameters 'a' and 'b' are required.") 27 | return jsonify(a + b) 28 | 29 | @app.route('/multiply//') 30 | def multiply_numbers(a, b): 31 | """ 32 | Get path parameters 'a' and 'b' and return their product. 33 | 34 | Parameters: 35 | a (int): The first number. 36 | b (int): The second number. 37 | 38 | Returns: 39 | JSON object: {"result": product} 40 | product (int): The product of parameters 'a' and 'b'. 41 | """ 42 | return jsonify(result=a * b) 43 | 44 | if __name__ == '__main__': 45 | app.run(debug=True) 46 | 47 | 48 | """ 49 | http://127.0.0.1:5000/ will return "Hello, World!" 50 | http://127.0.0.1:5000/sum?a=3&b=5 will return {"result": 8} 51 | http://127.0.0.1:5000/multiply/4/6 will return {"result": 24} 52 | 53 | """ 54 | 55 | 56 | 57 | #---------------------------------------------------------------------------------- 58 | 59 | 60 | 61 | """ 62 | from flask import Flask, request 63 | 64 | app = Flask(__name__) 65 | 66 | @app.route('/') 67 | def hello(): 68 | # Get individual query parameters using request.args.get() 69 | name = request.args.get('name', 'Guest') 70 | age = request.args.get('age', 'Unknown') 71 | city = request.args.get('city', 'Unknown') 72 | 73 | # Display the values of the query parameters 74 | return f'Hello, {name}! Age: {age}, City: {city}' 75 | 76 | if __name__ == '__main__': 77 | app.run(debug=True) 78 | 79 | 80 | # http://127.0.0.1:5000/?name=John&age=30&city=New+York 81 | """ -------------------------------------------------------------------------------- /17-Flask/__pycache__/package.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/17-Flask/__pycache__/package.cpython-38.pyc -------------------------------------------------------------------------------- /17-Flask/__pycache__/package.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/17-Flask/__pycache__/package.cpython-39.pyc -------------------------------------------------------------------------------- /17-Flask/__pycache__/package_1.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/17-Flask/__pycache__/package_1.cpython-38.pyc -------------------------------------------------------------------------------- /17-Flask/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | app = Flask(__name__) 3 | @app.route('/') 4 | def index(): 5 | return "hello flask application" 6 | 7 | 8 | if __name__ == "__main__": 9 | app.run(debug=True) -------------------------------------------------------------------------------- /17-Flask/basic_app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | 3 | app = Flask(__name__) 4 | 5 | @app.route("/hello") 6 | def hello_world(): 7 | # Function to handle GET requests to the root path "/" 8 | return "Hello from Flask! This is a GET request." 9 | 10 | 11 | @app.route("/firstpage") 12 | def first_page(): 13 | # Function to handle GET requests to the root path "/" 14 | return "This is your first page" 15 | 16 | if __name__ == "__main__": 17 | app.run(debug=True) 18 | 19 | 20 | 21 | """ 22 | We import the Flask class from the flask library. 23 | We create an instance of the Flask class and name it app. 24 | We use the @app.route("/") decorator to define a route for the root path (/). 25 | The function hello_world() is associated with this route. 26 | When a GET request is made to the root path, the hello_world() function is executed. 27 | This function simply returns a string "Hello from Flask! This is a GET request." 28 | """ -------------------------------------------------------------------------------- /17-Flask/form/form.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request 2 | 3 | app = Flask(__name__) 4 | 5 | @app.route('/',methods = ['GET']) # api endpoint 6 | def student(): 7 | return render_template('student.html') 8 | 9 | @app.route('/result',methods = ['POST']) 10 | def result(): 11 | if request.method == 'POST': 12 | form_result = request.form 13 | numerical_values = [int(value) for key, value in form_result.items() if value.isdigit()] 14 | avg_result = sum(numerical_values)//len(numerical_values) 15 | return render_template("result.html",result = form_result,avg_result = avg_result) 16 | 17 | if __name__ == '__main__': 18 | app.run(debug = True) -------------------------------------------------------------------------------- /17-Flask/form/static/hello.js: -------------------------------------------------------------------------------- 1 | function sayHello() { 2 | alert("Awesome Job") 3 | } -------------------------------------------------------------------------------- /17-Flask/form/templates/result.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | {% for key, value in result.items() %} 10 | 11 | 12 | 13 | 14 | {% endfor %} 15 |
{{ key.upper() }} {{ value }}
16 | 17 |

average mark = {{avg_result}}

18 | 19 | {% if avg_result>80 %} 20 |

You Scored good mark

21 | {% else %} 22 |

Your result is awesome keep going

23 | {% endif %} 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /17-Flask/form/templates/student.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |

Name

5 |

Physics

6 |

Chemistry

7 |

Maths

8 |

9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /17-Flask/form_args_get/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, render_template 2 | 3 | app = Flask(__name__) 4 | 5 | @app.route('/form', methods=['GET']) 6 | def get_data(): 7 | user_input = request.args.get('data') 8 | if user_input: 9 | return f'You entered: {user_input.upper()}' 10 | return render_template('index.html') 11 | 12 | if __name__ == '__main__': 13 | app.run(debug=True) 14 | -------------------------------------------------------------------------------- /17-Flask/form_args_get/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Enter Data 5 | 6 | 7 |

Enter Data as a Query Parameter

8 |
9 | 10 | 11 | 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /17-Flask/form_args_post/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, render_template 2 | 3 | app = Flask(__name__) 4 | 5 | # Route to display the form 6 | @app.route('/') 7 | def display_form(): 8 | return render_template('form.html') 9 | 10 | # Route to process the form data 11 | @app.route('/process', methods=['POST']) 12 | def process_form(): 13 | # Retrieve form data using request.form 14 | name = request.form.get('name') 15 | email = request.form.get('email') 16 | 17 | # You can now use 'name' and 'email' in your application logic 18 | return f"Received form data. Name: {name}, Email: {email}" 19 | 20 | if __name__ == '__main__': 21 | app.run(debug=True) 22 | """ 23 | 24 | --- 25 | 26 | ### **When to Use Each?** 27 | | Scenario | Use | 28 | |----------|-----| 29 | | Retrieving **URL parameters** (e.g., `/search?q=flask`) | `request.args.get()` | 30 | | Retrieving **form data** submitted via `POST` | `request.form.get()` | 31 | | If unsure whether the data comes from **query parameters or form data** | `request.values.get()` (checks both) | 32 | 33 | """ -------------------------------------------------------------------------------- /17-Flask/form_args_post/templates/form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Sample Form 5 | 6 | 7 |
8 | 9 |

10 | 11 | 12 |

13 | 14 | 15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /17-Flask/jinja_tem/templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {% block title %}Base Title{% endblock %} 7 | 8 | 9 |
10 |

{% block heading %}Base Heading{% endblock %}

11 |
12 | {% block content %}Base Content{% endblock %} 13 |
14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /17-Flask/jinja_tem/templates/child.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block title %}Child Title{% endblock %} 4 | {% block heading %}Child Heading{% endblock %} 5 | {% block content %} 6 |

This is the content of the child template.

7 |

You can add more content here.

8 | {% endblock %} 9 | -------------------------------------------------------------------------------- /17-Flask/swagger_sample/app.py: -------------------------------------------------------------------------------- 1 | # from flask import Flask 2 | # from flask_restful import Api, Resource 3 | # from flasgger import Swagger 4 | 5 | # app = Flask(__name__) 6 | # api = Api(app) 7 | # swagger = Swagger(app) 8 | 9 | 10 | # class HelloWorld(Resource): 11 | # def get(self): 12 | # """ 13 | # This is the example endpoint. 14 | # """ 15 | # return {'message': 'Hello, World!'} 16 | 17 | 18 | # api.add_resource(HelloWorld, '/') 19 | 20 | 21 | # if __name__ == '__main__': 22 | # app.run(debug=True) 23 | 24 | #---------------------------------------------------------------------------- 25 | 26 | from flask import Flask, request 27 | from flasgger import Swagger 28 | 29 | app = Flask(__name__) 30 | swagger = Swagger(app) 31 | 32 | 33 | @app.route('/add', methods=['POST']) 34 | def add_numbers(): 35 | """ 36 | Add two numbers. 37 | 38 | --- 39 | parameters: 40 | - name: num1 41 | in: formData 42 | type: number 43 | required: true 44 | description: The first number. 45 | - name: num2 46 | in: formData 47 | type: number 48 | required: true 49 | description: The second number. 50 | responses: 51 | 200: 52 | description: The sum of the two numbers. 53 | """ 54 | num1 = request.form.get('num1') 55 | num2 = request.form.get('num2') 56 | 57 | try: 58 | result = float(num1) + float(num2) 59 | return {'result': result}, 200 60 | except ValueError: 61 | return {'message': 'Invalid input. Please provide valid numbers.'}, 400 62 | 63 | 64 | if __name__ == '__main__': 65 | app.run(debug=True) 66 | 67 | # ------------------------------------------------------------------------ 68 | 69 | 70 | 71 | # http://127.0.0.1:5000/apidocs/ -------------------------------------------------------------------------------- /17-Flask/web_api/images/.ipynb_checkpoints/methods-checkpoint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/17-Flask/web_api/images/.ipynb_checkpoints/methods-checkpoint.png -------------------------------------------------------------------------------- /17-Flask/web_api/images/.ipynb_checkpoints/status_code_1-checkpoint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/17-Flask/web_api/images/.ipynb_checkpoints/status_code_1-checkpoint.png -------------------------------------------------------------------------------- /17-Flask/web_api/images/anatomy_url.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/17-Flask/web_api/images/anatomy_url.PNG -------------------------------------------------------------------------------- /17-Flask/web_api/images/methods.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/17-Flask/web_api/images/methods.png -------------------------------------------------------------------------------- /17-Flask/web_api/images/status_code_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/17-Flask/web_api/images/status_code_1.png -------------------------------------------------------------------------------- /17-Flask/web_api/images/status_code_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/17-Flask/web_api/images/status_code_2.png -------------------------------------------------------------------------------- /Flask_application/crudapp/__pycache__/create_db.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/Flask_application/crudapp/__pycache__/create_db.cpython-310.pyc -------------------------------------------------------------------------------- /Flask_application/crudapp/__pycache__/create_db.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/Flask_application/crudapp/__pycache__/create_db.cpython-39.pyc -------------------------------------------------------------------------------- /Flask_application/crudapp/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask,render_template,request,redirect,url_for,flash 2 | import create_db 3 | import sqlite3 as sql 4 | app=Flask(__name__) 5 | 6 | @app.route("/") 7 | @app.route("/index") 8 | def index(): 9 | con=sql.connect("db_web.db") 10 | con.row_factory=sql.Row 11 | cur=con.cursor() 12 | cur.execute("select * from users") 13 | data=cur.fetchall() 14 | return render_template("index.html",datas=data) 15 | 16 | @app.route("/add_user",methods=['POST','GET']) 17 | def add_user(): 18 | if request.method=='POST': 19 | uname=request.form['uname'] 20 | contact=request.form['contact'] 21 | con=sql.connect("db_web.db") 22 | cur=con.cursor() 23 | cur.execute("insert into users(UNAME,CONTACT) values (?,?)",(uname,contact)) 24 | con.commit() 25 | flash('User Added','success') 26 | return redirect(url_for("index")) 27 | return render_template("add_user.html") 28 | 29 | @app.route("/edit_user/",methods=['POST','GET']) 30 | def edit_user(uid): 31 | if request.method=='POST': 32 | uname=request.form['uname'] 33 | contact=request.form['contact'] 34 | con=sql.connect("db_web.db") 35 | cur=con.cursor() 36 | cur.execute("update users set UNAME=?,CONTACT=? where UID=?",(uname,contact,uid)) 37 | con.commit() 38 | flash('User Updated','success') 39 | return redirect(url_for("index")) 40 | con=sql.connect("db_web.db") 41 | con.row_factory=sql.Row 42 | cur=con.cursor() 43 | cur.execute("select * from users where UID=?",(uid,)) 44 | data=cur.fetchone() 45 | return render_template("edit_user.html",datas=data) 46 | 47 | @app.route("/delete_user/",methods=['GET']) 48 | def delete_user(uid): 49 | con=sql.connect("db_web.db") 50 | cur=con.cursor() 51 | cur.execute("delete from users where UID=?",(uid,)) 52 | con.commit() 53 | flash('User Deleted','warning') 54 | return redirect(url_for("index")) 55 | 56 | if __name__=='__main__': 57 | app.secret_key = "admin@12345" 58 | app.run(debug=True) -------------------------------------------------------------------------------- /Flask_application/crudapp/create_db.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as sql 2 | 3 | #connect to SQLite 4 | con = sql.connect('db_web.db') 5 | 6 | #Create a Connection 7 | cur = con.cursor() 8 | 9 | #Drop users table if already exsist. 10 | cur.execute("DROP TABLE IF EXISTS users") 11 | 12 | #Create users table in db_web database 13 | sql ='''CREATE TABLE "users" ( 14 | "UID" INTEGER PRIMARY KEY AUTOINCREMENT, 15 | "UNAME" TEXT, 16 | "CONTACT" TEXT 17 | )''' 18 | cur.execute(sql) 19 | 20 | #commit changes 21 | con.commit() 22 | 23 | #close the connection 24 | con.close() -------------------------------------------------------------------------------- /Flask_application/crudapp/db_web.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/Flask_application/crudapp/db_web.db -------------------------------------------------------------------------------- /Flask_application/crudapp/templates/add_user.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html' %} 2 | {% block body %} 3 |
4 |
5 |

Add user


6 |
7 |
8 | 9 | 10 |
11 |
12 | 13 | 14 |
15 | 16 |
17 | 18 |
19 |
20 | {% endblock %} -------------------------------------------------------------------------------- /Flask_application/crudapp/templates/edit_user.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html' %} 2 | {% block body %} 3 |
4 |
5 |

Edit user


6 |
7 |
8 | 9 | 10 |
11 |
12 | 13 | 14 |
15 | 16 |
17 |
18 |
19 | {% endblock %} -------------------------------------------------------------------------------- /Flask_application/crudapp/templates/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html' %} 2 | {% block body %} 3 |

Flask - SQLite CRUD Application

4 |

+Add User

5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {% for row in datas %} 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | {%endfor%} 23 | 24 |
SNoNameContactEditDelete
{{loop.index}}{{row.UNAME}}{{row.CONTACT}}EditDelete
25 | {% endblock %} -------------------------------------------------------------------------------- /Flask_application/crudapp/templates/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flask - SQLite 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | {% with messages=get_flashed_messages(with_categories=true) %} 12 | {% if messages %} 13 | {% for category,message in messages %} 14 |
{{message}}
15 | {% endfor %} 16 | {% endif %} 17 | {% endwith %} 18 | {% block body %} 19 | 20 | {% endblock %} 21 |
22 | 23 | -------------------------------------------------------------------------------- /Flowchart.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/Flowchart.pdf -------------------------------------------------------------------------------- /Installing Anaconda on windows.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/Installing Anaconda on windows.docx -------------------------------------------------------------------------------- /Pesudocode.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/Pesudocode.docx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # python_june_notes 2 | python note books 3 | -------------------------------------------------------------------------------- /Section-1.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/Section-1.pptx -------------------------------------------------------------------------------- /beginners_python_cheat_sheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/beginners_python_cheat_sheet.pdf -------------------------------------------------------------------------------- /cheatsheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/cheatsheet.pdf -------------------------------------------------------------------------------- /cheatsheet_01.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/cheatsheet_01.pdf -------------------------------------------------------------------------------- /console_application/__pycache__/theater_info.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/console_application/__pycache__/theater_info.cpython-310.pyc -------------------------------------------------------------------------------- /console_application/__pycache__/theater_info.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/console_application/__pycache__/theater_info.cpython-38.pyc -------------------------------------------------------------------------------- /console_application/__pycache__/theater_info.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/console_application/__pycache__/theater_info.cpython-39.pyc -------------------------------------------------------------------------------- /console_application/__pycache__/user_info.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/console_application/__pycache__/user_info.cpython-310.pyc -------------------------------------------------------------------------------- /console_application/__pycache__/user_info.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/console_application/__pycache__/user_info.cpython-38.pyc -------------------------------------------------------------------------------- /console_application/__pycache__/user_info.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/console_application/__pycache__/user_info.cpython-39.pyc -------------------------------------------------------------------------------- /console_application/beginners_python_cheat_sheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/console_application/beginners_python_cheat_sheet.pdf -------------------------------------------------------------------------------- /console_application/main.py: -------------------------------------------------------------------------------- 1 | import time 2 | import theater_info,user_info 3 | 4 | user_input = 20 5 | s = theater_info.seats() 6 | total_seats, no_of_rows, no_of_seats= s.capacity() 7 | st=theater_info.statistics() 8 | total_seats_booked=0 9 | total_income = 0 10 | current_income=0 11 | 12 | while user_input != 0: 13 | print("1: Show the Seats\n2: Choose the movie\n3: Choose movie language\n4: Show the time\n5: Buy a Ticket\n6: Statistics\n7: Show booked Tickets User Info\n0: Exit") 14 | print(50*"-") 15 | user_input = int(input()) 16 | 17 | if user_input == 1: 18 | s.show_the_seats() 19 | time.sleep(2) 20 | # New object is created for the Theater class in theater_info.py 21 | elif user_input == 2: 22 | 23 | theater_class = theater_info.Theater() #Object created 24 | theater_class.movie_name() # call the movie method in Theater class with theater_class object 25 | 26 | elif user_input == 3: 27 | theater_class.movie_language() # call the movie_language in Theater class with theater_class object 28 | 29 | 30 | elif user_input == 4: 31 | theater_class.timing() # call the movie timing in Theater class with theater_class object 32 | 33 | 34 | 35 | elif user_input == 5: 36 | t = theater_info.tickets() 37 | if t.book_row<=no_of_rows and t.book_column<=no_of_seats : 38 | b,current_income=t.buy_ticket(total_seats,no_of_rows,total_income,total_seats_booked) 39 | if b != None: 40 | total_income = total_income + current_income 41 | if b == True: 42 | total_seats_booked += 1 43 | else: 44 | print("you are trying to book the wrong seat") 45 | print(50*"-") 46 | time.sleep(2) 47 | 48 | elif user_input == 6: 49 | t1=st.stats(total_seats_booked,total_seats,current_income,total_income) 50 | 51 | elif user_input == 7: 52 | u1=user_info.user_info() 53 | checkR = int(input("Enter the row you want to check: ")) 54 | checkC = int(input("Enter the column you want to check: ")) 55 | print(50*"-") 56 | u1.booked_tickets_user_info(checkR, checkC,current_income) 57 | 58 | elif user_input == 8: 59 | u1=user_info.user_info() 60 | 61 | 62 | -------------------------------------------------------------------------------- /console_application/project requirements.txt: -------------------------------------------------------------------------------- 1 | Enter the Number of Rows: # number of rows 2 | Enter the Number of Seats: # number of columns 3 | 1: Show the Seats 4 | 2: Choose the movie 5 | 3: Choose movie language 6 | 4: Show the time 7 | 5: Buy a Ticket 8 | 6: Statistics 9 | 7: Show booked Tickets User Info 10 | 0: Exit 11 | 12 | 13 | -------------------------------------------------------------------------------- /console_application/theater_info.py: -------------------------------------------------------------------------------- 1 | from winreg import EnumValue 2 | import user_info 3 | class seats: 4 | global matrix,total_seats_booked 5 | matrix = [] 6 | 7 | 8 | def __init__(self): 9 | self.no_of_rows = int(input("Enter the Number of Rows:")) 10 | self.no_of_seats = int(input("Enter the Number of Seats:")) 11 | 12 | 13 | def capacity(self): 14 | for i in range(self.no_of_rows + 1): 15 | a = [] 16 | for j in range(self.no_of_seats + 1): 17 | a.append("S") 18 | matrix.append(a) 19 | 20 | total_seats = self.no_of_seats * self.no_of_rows 21 | return total_seats, self.no_of_rows,self.no_of_seats 22 | 23 | def show_the_seats(self): 24 | 25 | for i in range(0, self.no_of_rows + 1): 26 | if i == 0: 27 | for j in range(0, self.no_of_seats + 1): 28 | print(j, end=" ") 29 | else: 30 | print(i, end=" ") 31 | for k in range(self.no_of_seats): 32 | print(matrix[i - 1][k], end=" ") 33 | print() 34 | 35 | 36 | 37 | class tickets: 38 | global price_each_ticket,p 39 | 40 | def __init__(self): 41 | self.book_row = int(input("Please enter the row no. you want to book: ")) 42 | self.book_column = int(input("Please enter the column no. you want to book: ")) 43 | 44 | 45 | def buy_ticket(self, total_seats, no_of_rows,total_income,total_seats_booked ): 46 | 47 | p = tickets.price_per_ticket(self,total_seats, no_of_rows,total_income) 48 | print(p) 49 | 50 | print("The Price of your ticket will be: ", p) 51 | confirmation = input("Please Confirm to book your ticket Yes/No") 52 | 53 | if confirmation == 'Yes' or confirmation=='yes': 54 | 55 | matrix[self.book_row - 1][self.book_column - 1] = "B" 56 | u=user_info.user_info() 57 | u.user(self.book_row,self.book_column) 58 | return True,p 59 | 60 | else: 61 | print("No ticket booked") 62 | return None,None 63 | 64 | def price_per_ticket(self, total_seats, no_of_rows,total_income): 65 | current_income=0 66 | if total_seats <= 60: 67 | current_income=10 68 | total_income=total_income + current_income 69 | return 10 70 | 71 | else: 72 | if self.book_row >= (no_of_rows / 2): 73 | current_income = 8 74 | 75 | return 8 76 | else: 77 | current_income = 10 78 | 79 | return 10 80 | 81 | class statistics: 82 | def stats(self,total_seats_booked,total_seats,c,total_income): 83 | print("Number of Purchased Tickets: ",total_seats_booked) 84 | print("Percentage of Tickets Booked: ",(total_seats_booked/total_seats)*100) 85 | print("Current Income: ",c,"$") 86 | print("Total_income: ",total_income,"$") 87 | print(50*"-") 88 | 89 | 90 | # New class created 91 | class Theater: 92 | # Method 93 | def movie_name(self): 94 | print("please choose the movie:\n") 95 | movie_list = ["Aaa","Bbb","ccc"] # list containg Movie names 96 | for i,value in enumerate (movie_list): 97 | print(i,":",value,"\n") # Print the movie names 98 | self.user_movie = int(input("Enter the Movie number: \n")) # Get the input 99 | 100 | print(50*"-") 101 | 102 | # Method 103 | def movie_language(self): 104 | print("Please choose the Lanuage") 105 | 106 | # Specific language for each movie 107 | if self.user_movie == 0: 108 | lang = ["Tamil","English","Hindi","Kannada","Telugu"] # langugaes for movie Aaa (can add more languages) 109 | for i,value in enumerate (lang): 110 | print(i,":",value,"\n") 111 | elif self.user_movie == 1: # langugaes for movie Bbb (can add more languages) 112 | lang = ["Tamil","English","Kannada","Telugu"] 113 | for i,value in enumerate (lang): 114 | print(i,":",value,"\n") 115 | else: #elif self.user_movie == 2: 116 | lang = ["Tamil","English"] # # langugaes for movie Ccc (can add more languages) 117 | for i,value in enumerate (lang): 118 | print(i,":",value,"\n") 119 | 120 | lang_val = int(input("choose the number: \n")) 121 | self.lang_flag = True 122 | print(50*"-") 123 | 124 | # Method 125 | def timing(self): 126 | value_time = ["09:00 Am", "11:00 AM","02:00 Am", "06:00 Am", "10:00 Am"] #Timings 127 | for i,value in enumerate (value_time): 128 | print(i,":",value,"\n") 129 | user_time = int(input("Enter the Time slot: \n")) 130 | print(50*"-") 131 | 132 | -------------------------------------------------------------------------------- /console_application/user_info.py: -------------------------------------------------------------------------------- 1 | import re 2 | class user_info: 3 | 4 | global dict_info 5 | list_booked_seats=[] 6 | 7 | def user(self,book_row,book_column): 8 | dict_info = {"Name": "", "Gender": "", "Age": int, "Phone_no": int} 9 | 10 | name=input("Enter the Name: ") 11 | gender=input("Enter your Sex: ") 12 | Age=int(input("Enter your Age: ")) 13 | phone_no=input("Enter your Phone number: ") 14 | 15 | 16 | for i in range(10): 17 | mat = re.fullmatch("[89][0-9]{9}", phone_no) 18 | if mat != None: 19 | 20 | dict_info["Name"] = name 21 | dict_info["Gender"] = gender 22 | dict_info["Age"] = Age 23 | dict_info["Phone_no"] = phone_no 24 | 25 | list1 = [book_row, book_column, dict_info] 26 | user_info.list_booked_seats.append(list1) 27 | print("CONGRATS!!! Booked Successfully") 28 | break 29 | else: 30 | print("Invalid Phone Number!!!") 31 | phone_no = input("Please Enter Valid Mobile Number: ") 32 | 33 | def booked_tickets_user_info(self,row_c,column_c,current_income): 34 | 35 | if len(user_info.list_booked_seats)>0 : 36 | for i in range(len(user_info.list_booked_seats)): 37 | if (user_info.list_booked_seats[i][0]==row_c and user_info.list_booked_seats[i][1]==column_c): 38 | 39 | print("Name: ",user_info.list_booked_seats[i][2].get("Name")) 40 | print("Gender: ", user_info.list_booked_seats[i][2].get("Gender")) 41 | print("Age: ", user_info.list_booked_seats[i][2].get("Age")) 42 | print("Phone Number: ", user_info.list_booked_seats[i][2].get("Phone_no")) 43 | print("Ticket Price :",current_income,'$') 44 | break 45 | else: 46 | print("Seat is vacant") 47 | 48 | else: 49 | print("Auditorium is Empty") 50 | 51 | -------------------------------------------------------------------------------- /db_web.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/db_web.db -------------------------------------------------------------------------------- /mongodb/basic_app/app.py: -------------------------------------------------------------------------------- 1 | # pip install Flask pymongo 2 | from flask import Flask, request, jsonify 3 | from pymongo import MongoClient 4 | 5 | app = Flask(__name__) 6 | 7 | # MongoDB connection URI 8 | uri = "mongodb://localhost:27017" 9 | client = MongoClient(uri) 10 | 11 | # Specify the database and collection 12 | db = client.my_database 13 | collection = db.my_collection 14 | 15 | @app.route('/insert', methods=['POST']) 16 | def insert_document(): 17 | try: 18 | # Get JSON data from the request 19 | data = request.json 20 | if not data: 21 | return jsonify({"error": "No data provided"}), 400 22 | 23 | # Insert the data into the collection 24 | insert_result = collection.insert_one(data) 25 | 26 | return jsonify({"message": "Document inserted", "id": str(insert_result.inserted_id)}), 201 27 | except Exception as e: 28 | return jsonify({"error": str(e)}), 500 29 | 30 | if __name__ == '__main__': 31 | app.run(debug=True) 32 | 33 | 34 | 35 | # Use Postman to Insert Data 36 | 37 | # Open Postman. 38 | # Create a new POST request to http://127.0.0.1:5000/insert. 39 | # Set the request body to raw and select JSON format. 40 | # Add the JSON data you want to insert. For example: 41 | """ 42 | 43 | { 44 | "name": "Jane Doe", 45 | "age": 32, 46 | "email": "jane.doe@example.com" 47 | } 48 | 49 | """ 50 | # Send the request 51 | 52 | 53 | -------------------------------------------------------------------------------- /mongodb/basic_crud/crud_app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, jsonify 2 | from pymongo import MongoClient 3 | from bson.objectid import ObjectId 4 | 5 | app = Flask(__name__) 6 | 7 | # MongoDB connection URI 8 | uri = "mongodb://localhost:27017" 9 | client = MongoClient(uri) 10 | 11 | # Specify the database and collection 12 | db = client.my_database 13 | collection = db.my_collection 14 | 15 | # Create (Insert) a new document 16 | @app.route('/insert', methods=['POST']) 17 | def insert_document(): 18 | try: 19 | data = request.json 20 | if not data: 21 | return jsonify({"error": "No data provided"}), 400 22 | 23 | insert_result = collection.insert_one(data) 24 | return jsonify({"message": "Document inserted", "id": str(insert_result.inserted_id)}), 201 25 | except Exception as e: 26 | return jsonify({"error": str(e)}), 500 27 | 28 | # Read (Get) all documents 29 | @app.route('/documents', methods=['GET']) 30 | def get_documents(): 31 | try: 32 | documents = list(collection.find()) 33 | for document in documents: 34 | document['_id'] = str(document['_id']) # Convert ObjectId to string for JSON serialization 35 | return jsonify(documents), 200 36 | except Exception as e: 37 | return jsonify({"error": str(e)}), 500 38 | 39 | # Read (Get) a single document by ID 40 | @app.route('/documents/', methods=['GET']) 41 | def get_document_by_id(id): 42 | try: 43 | document = collection.find_one({"_id": ObjectId(id)}) 44 | if document: 45 | document['_id'] = str(document['_id']) # Convert ObjectId to string for JSON serialization 46 | return jsonify(document), 200 47 | else: 48 | return jsonify({"error": "Document not found"}), 404 49 | except Exception as e: 50 | return jsonify({"error": str(e)}), 500 51 | 52 | # Update a document by ID 53 | @app.route('/documents/', methods=['PUT']) 54 | def update_document(id): 55 | try: 56 | data = request.json 57 | if not data: 58 | return jsonify({"error": "No data provided"}), 400 59 | 60 | update_result = collection.update_one({"_id": ObjectId(id)}, {"$set": data}) 61 | if update_result.modified_count == 0: 62 | return jsonify({"message": "No document found to update"}), 404 63 | return jsonify({"message": "Document updated"}), 200 64 | except Exception as e: 65 | return jsonify({"error": str(e)}), 500 66 | 67 | # Delete a document by ID 68 | @app.route('/documents/', methods=['DELETE']) 69 | def delete_document(id): 70 | try: 71 | delete_result = collection.delete_one({"_id": ObjectId(id)}) 72 | if delete_result.deleted_count == 0: 73 | return jsonify({"message": "No document found to delete"}), 404 74 | return jsonify({"message": "Document deleted"}), 200 75 | except Exception as e: 76 | return jsonify({"error": str(e)}), 500 77 | 78 | if __name__ == '__main__': 79 | app.run(debug=True) 80 | 81 | 82 | 83 | # Use Postman to Test the CRUD Operations 84 | 85 | ## Create (Insert) a Document 86 | 87 | """ 88 | 89 | Method: POST 90 | URL: http://127.0.0.1:5000/insert 91 | Headers: Content-Type: application/json 92 | Body (raw, JSON): 93 | 94 | { 95 | "name": "John Doe", 96 | "age": 30, 97 | "email": "john.doe@example.com" 98 | } 99 | 100 | """ 101 | 102 | 103 | # #Read (Get) All Documents 104 | 105 | """ 106 | 107 | Method: GET 108 | URL: http://127.0.0.1:5000/documents 109 | 110 | """ 111 | 112 | ## Read (Get) a Single Document by ID 113 | 114 | """ 115 | 116 | Method: GET 117 | URL: http://127.0.0.1:5000/documents/ 118 | 119 | """ 120 | 121 | 122 | ## Update a Document by ID 123 | 124 | """ 125 | 126 | Method: PUT 127 | URL: http://127.0.0.1:5000/documents/ 128 | Headers: Content-Type: application/json 129 | Body (raw, JSON): 130 | 131 | { 132 | "name": "John Smith", 133 | "age": 35 134 | } 135 | 136 | Replace with the actual ID of the document you want to delete. 137 | """ 138 | 139 | ## Delete a Document by ID 140 | 141 | """ 142 | 143 | Method: DELETE 144 | URL: http://127.0.0.1:5000/documents/ 145 | 146 | 147 | Replace with the actual ID of the document you want to delete. 148 | 149 | """ -------------------------------------------------------------------------------- /mongodb/crud_app/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, jsonify, render_template 2 | from pymongo import MongoClient 3 | from bson.objectid import ObjectId 4 | 5 | app = Flask(__name__) 6 | 7 | # MongoDB connection URI 8 | uri = "mongodb://localhost:27017" 9 | client = MongoClient(uri) 10 | 11 | # Specify the database and collection 12 | db = client.my_database 13 | collection = db.my_collection 14 | 15 | # Serve the HTML file 16 | @app.route('/') 17 | def serve_index(): 18 | return render_template('index.html') 19 | 20 | # Create (Insert) a new document 21 | @app.route('/insert', methods=['POST']) 22 | def insert_document(): 23 | try: 24 | data = request.json 25 | if not data: 26 | return jsonify({"error": "No data provided"}), 400 27 | 28 | insert_result = collection.insert_one(data) 29 | return jsonify({"message": "Document inserted", "id": str(insert_result.inserted_id)}), 201 30 | except Exception as e: 31 | return jsonify({"error": str(e)}), 500 32 | 33 | # Read (Get) all documents 34 | @app.route('/documents', methods=['GET']) 35 | def get_documents(): 36 | try: 37 | documents = list(collection.find()) 38 | for document in documents: 39 | document['_id'] = str(document['_id']) # Convert ObjectId to string for JSON serialization 40 | return jsonify(documents), 200 41 | except Exception as e: 42 | return jsonify({"error": str(e)}), 500 43 | 44 | # Read (Get) a single document by ID 45 | @app.route('/documents/', methods=['GET']) 46 | def get_document_by_id(id): 47 | try: 48 | document = collection.find_one({"_id": ObjectId(id)}) 49 | if document: 50 | document['_id'] = str(document['_id']) # Convert ObjectId to string for JSON serialization 51 | return jsonify(document), 200 52 | else: 53 | return jsonify({"error": "Document not found"}), 404 54 | except Exception as e: 55 | return jsonify({"error": str(e)}), 500 56 | 57 | # Update a document by ID 58 | @app.route('/documents/', methods=['PUT']) 59 | def update_document(id): 60 | try: 61 | data = request.json 62 | if not data: 63 | return jsonify({"error": "No data provided"}), 400 64 | 65 | update_result = collection.update_one({"_id": ObjectId(id)}, {"$set": data}) 66 | if update_result.modified_count == 0: 67 | return jsonify({"message": "No document found to update"}), 404 68 | return jsonify({"message": "Document updated"}), 200 69 | except Exception as e: 70 | return jsonify({"error": str(e)}), 500 71 | 72 | # Delete a document by ID 73 | @app.route('/documents/', methods=['DELETE']) 74 | def delete_document(id): 75 | try: 76 | delete_result = collection.delete_one({"_id": ObjectId(id)}) 77 | if delete_result.deleted_count == 0: 78 | return jsonify({"message": "No document found to delete"}), 404 79 | return jsonify({"message": "Document deleted"}), 200 80 | except Exception as e: 81 | return jsonify({"error": str(e)}), 500 82 | 83 | if __name__ == '__main__': 84 | app.run(debug=True) 85 | -------------------------------------------------------------------------------- /mongodb/crud_app/static/script.js: -------------------------------------------------------------------------------- 1 | // Base API URL 2 | const API_URL = 'http://127.0.0.1:5000'; 3 | 4 | // Event listener for form submission 5 | document.getElementById('create-form').addEventListener('submit', async (e) => { 6 | e.preventDefault(); // Prevent the default form submission behavior 7 | 8 | // Get input values from the form 9 | const name = document.getElementById('name').value; 10 | const age = document.getElementById('age').value; 11 | const email = document.getElementById('email').value; 12 | 13 | // Send a POST request to the /insert endpoint with the form data 14 | const response = await fetch(`${API_URL}/insert`, { 15 | method: 'POST', // HTTP method 16 | headers: { 17 | 'Content-Type': 'application/json' // Content type is JSON 18 | }, 19 | body: JSON.stringify({ name, age, email }) // Convert data to JSON string 20 | }); 21 | 22 | // Parse the response from the server 23 | const result = await response.json(); 24 | if (response.status === 201) { 25 | alert('Document inserted'); // Alert if insertion was successful 26 | fetchDocuments(); // Refresh the documents list 27 | } else { 28 | alert('Error inserting document: ' + result.error); // Alert if there was an error 29 | } 30 | }); 31 | 32 | // Function to fetch and display all documents 33 | async function fetchDocuments() { 34 | // Send a GET request to the /documents endpoint 35 | const response = await fetch(`${API_URL}/documents`); 36 | // Parse the response from the server 37 | const documents = await response.json(); 38 | 39 | // Get the documents div to display the documents 40 | const documentsDiv = document.getElementById('documents'); 41 | documentsDiv.innerHTML = ''; // Clear the div 42 | 43 | // Iterate over each document and create a div element for it 44 | documents.forEach(doc => { 45 | const docDiv = document.createElement('div'); 46 | docDiv.className = 'document'; // Add class for styling 47 | docDiv.innerHTML = ` 48 | ${doc.name} - ${doc.age} - ${doc.email} 49 |
50 | 51 | 52 |
53 | `; // Add document details and buttons for update and delete 54 | documentsDiv.appendChild(docDiv); // Append the document div to the documents div 55 | }); 56 | } 57 | 58 | // Function to update a document 59 | async function updateDocument(id) { 60 | // Prompt the user for new values 61 | const name = prompt('Enter new name'); 62 | const age = prompt('Enter new age'); 63 | const email = prompt('Enter new email'); 64 | 65 | // Send a PUT request to the /documents/:id endpoint with the new data 66 | const response = await fetch(`${API_URL}/documents/${id}`, { 67 | method: 'PUT', // HTTP method 68 | headers: { 69 | 'Content-Type': 'application/json' // Content type is JSON 70 | }, 71 | body: JSON.stringify({ name, age, email }) // Convert data to JSON string 72 | }); 73 | 74 | // Parse the response from the server 75 | const result = await response.json(); 76 | if (response.status === 200) { 77 | alert('Document updated'); // Alert if update was successful 78 | fetchDocuments(); // Refresh the documents list 79 | } else { 80 | alert('Error updating document: ' + result.error); // Alert if there was an error 81 | } 82 | } 83 | 84 | // Function to delete a document 85 | async function deleteDocument(id) { 86 | // Send a DELETE request to the /documents/:id endpoint 87 | const response = await fetch(`${API_URL}/documents/${id}`, { 88 | method: 'DELETE' // HTTP method 89 | }); 90 | 91 | // Parse the response from the server 92 | const result = await response.json(); 93 | if (response.status === 200) { 94 | alert('Document deleted'); // Alert if deletion was successful 95 | fetchDocuments(); // Refresh the documents list 96 | } else { 97 | alert('Error deleting document: ' + result.error); // Alert if there was an error 98 | } 99 | } 100 | 101 | // Initial fetch to display documents when the page loads 102 | fetchDocuments(); 103 | -------------------------------------------------------------------------------- /mongodb/crud_app/static/styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: Arial, sans-serif; 3 | margin: 0; 4 | padding: 0; 5 | background-color: #f4f4f4; 6 | } 7 | 8 | .container { 9 | max-width: 800px; 10 | margin: 50px auto; 11 | padding: 20px; 12 | background-color: #fff; 13 | border-radius: 5px; 14 | box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); 15 | } 16 | 17 | h1, h2 { 18 | text-align: center; 19 | } 20 | 21 | form { 22 | display: flex; 23 | flex-direction: column; 24 | gap: 10px; 25 | } 26 | 27 | form input, form button { 28 | padding: 10px; 29 | font-size: 16px; 30 | } 31 | 32 | #documents { 33 | margin-top: 20px; 34 | } 35 | 36 | .document { 37 | display: flex; 38 | justify-content: space-between; 39 | background-color: #e9e9e9; 40 | padding: 10px; 41 | margin-bottom: 10px; 42 | border-radius: 5px; 43 | } 44 | 45 | .document button { 46 | margin-left: 10px; 47 | } 48 | -------------------------------------------------------------------------------- /mongodb/crud_app/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Flask MongoDB CRUD App 7 | 8 | 9 | 13 | 14 | 15 |
16 |

Flask MongoDB CRUD Application

17 | 18 |

Create Document

19 |
20 | 21 | 22 | 23 | 24 |
25 | 26 |

Documents

27 |
28 |
29 | 30 | 31 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /mongodb/objectId.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/mongodb/objectId.jpg -------------------------------------------------------------------------------- /mongodb/sqlvsmongodb.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/mongodb/sqlvsmongodb.PNG -------------------------------------------------------------------------------- /resources.txt: -------------------------------------------------------------------------------- 1 | What is git and github 2 | What is version control 3 | What is Github desktop 4 | What is Cloud 5 | What is Hosting 6 | What is Linux os/ windows os 7 | What is Command prompt 8 | What is Powershell 9 | Script language vs programming languages 10 | 11 | Blog: 12 | https://www.geeksforgeeks.org/how-to-approach-a-coding-problem/ 13 | 14 | https://medium.com/hackernoon/how-to-approach-any-coding-problem-9230f3ad6f9 15 | 16 | How Python Works: 17 | https://www.youtube.com/watch?v=-ZPg5lJCln8 18 | 19 | Binary code work 20 | https://www.youtube.com/watch?v=wgbV6DLVezo 21 | 22 | 1s and 0s 23 | https://www.youtube.com/watch?v=Xpk67YzOn5w 24 | 25 | Programming vs Coding 26 | https://www.youtube.com/watch?v=CIRGjwYgdT4 27 | 28 | https://www.youtube.com/live/LA2LIBZGink?si=2lDFNPOqHes-r9tX 29 | 30 | https://youtu.be/rdKX9hzA2lU?si=P7bhXJEaliWA8f4e 31 | 32 | Flowcharts: 33 | https://youtube.com/playlist?list=PLMQ4k-hUWGNl-_4tGH-2Gq-06yZbzl5az&si=AZnNvcZSF6zDwvx- 34 | 35 | Visualizers: 36 | https://algorithm-visualizer.org/ 37 | 38 | https://memlayout.com/ 39 | 40 | https://codepal.ai/code-visualizer 41 | 42 | https://cscircles.cemc.uwaterloo.ca/visualize#mode=display 43 | 44 | https://pythontutor.com/visualize.html#mode=display 45 | 46 | https://youtu.be/lYbATjjjDxM?si=rWJjvZmNjrWRNW5g 47 | 48 | 49 | basic projects: 50 | https://youtu.be/DLn3jOsNRVE 51 | 52 | qrsacn generate : 53 | https://youtu.be/onHPipeASdk 54 | 55 | github upload file: 56 | https://youtu.be/eGaImwD8fPQ 57 | 58 | streamlit project: 59 | https://youtu.be/VqgUkExPvLY 60 | https://youtube.com/playlist?list=PLuU3eVwK0I9PT48ZBYAHdKPFazhXg76h5&si=m8MHGJ4olsn7w4Tl 61 | 62 | 63 | Pratice Programs: 64 | https://www.hackerrank.com/domains/python 65 | 66 | https://www.w3resource.com/python-exercises/python-basic-exercises.php 67 | 68 | Flask App: 69 | https://youtu.be/XTpLbBJTOM4?si=uuyO9kfDJqP3z81A 70 | 71 | Youtube Materials: 72 | https://youtube.com/playlist?list=PLzgPDYo_3xulOYHoVsg7uASoF-OE3GE-S 73 | 74 | https://youtu.be/PMFd95RgIwE?si=sV1ks_jzGvySpFZr 75 | 76 | Hackerank: 77 | https://www.youtube.com/playlist?list=PL_8jNcohs27XQfEmWAHCgLFqpsNaWxUSe 78 | 79 | LeetCode DataStructures: 80 | https://leetcode.com/studyplan/top-interview-150/ 81 | 82 | https://leetcode.com/studyplan/dynamic-programming/ 83 | 84 | https://www.youtube.com/@TheAdityaVerma/playlists 85 | 86 | https://www.youtube.com/@NeetCode/playlists 87 | 88 | MCQ questions: 89 | https://www.sanfoundry.com/1000-python-questions-answers/ 90 | 91 | CheatSheet: 92 | https://perso.limsi.fr/pointal/_media/python:cours:mementopython3-english.pdf 93 | 94 | 95 | 6 Levels of Thinking: 96 | https://youtu.be/1xqerXscTsE?si=y6uB0bDrPBxaWpjO 97 | 98 | template 01: 99 | 100 | "Give me questions that [academic year] engineering level for [programming language] programming functions in Bloom's Taxonomy at level [Bloom's level]." 101 | 102 | Replace the variables as follows: 103 | 104 | [academic year]: Specify the academic year, e.g., "first-year". 105 | [programming language]: Specify the programming language, e.g., "Python". 106 | [Bloom's level]: Specify the Bloom's Taxonomy level, e.g., "4" for Analyzing. 107 | Example using the template: 108 | 109 | "Give me questions that first-year engineering level for Python programming functions in Bloom's Taxonomy at level 4." 110 | 111 | 112 | template 02: 113 | 114 | "Give me questions that [difficulty/proficiency level] for [programming language] programming functions in Bloom's Taxonomy at level [Bloom's level]." 115 | 116 | Replace the variables as follows: 117 | 118 | [difficulty/proficiency level]: Choose a term that indicates the difficulty or proficiency level, e.g., "Beginner level". 119 | [programming language]: Specify the programming language, e.g., "Python". 120 | [Bloom's level]: Specify the Bloom's Taxonomy level, e.g., "4" for Analyzing. 121 | Example using the template: 122 | 123 | "Give me questions that Beginner level for Python programming functions in Bloom's Taxonomy at level 4." 124 | -------------------------------------------------------------------------------- /resume_template.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hari-810/python_june_notes/c3eefd3253d88f0007e57506e5f9f22fd9a5fa59/resume_template.docx -------------------------------------------------------------------------------- /sample.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 3, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "[1, 2, 4.6, -0.7, 'A', 'hello', True]\n", 13 | "\n" 14 | ] 15 | } 16 | ], 17 | "source": [ 18 | "# LIST\n", 19 | "# Non primitive\n", 20 | "\n", 21 | "l = [1, 2, 4.6, -0.7, \"A\", \"hello\", True] # assign\n", 22 | "print(l)\n", 23 | "print(type(l))" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": 4, 29 | "metadata": {}, 30 | "outputs": [ 31 | { 32 | "name": "stdout", 33 | "output_type": "stream", 34 | "text": [ 35 | "[1]\n" 36 | ] 37 | } 38 | ], 39 | "source": [ 40 | "l = [] # reassign\n", 41 | "l = list() # reassign\n", 42 | "\n", 43 | "l.append(1)\n", 44 | "print(l)" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": 14, 50 | "metadata": {}, 51 | "outputs": [ 52 | { 53 | "name": "stdout", 54 | "output_type": "stream", 55 | "text": [ 56 | "8\n", 57 | "[1, 2, 'HI']\n", 58 | "hi\n" 59 | ] 60 | } 61 | ], 62 | "source": [ 63 | "# mutable\n", 64 | "\n", 65 | "l = [1, 2, 4.6, -0.7, \"A\", \"hello\", True, [1,2,\"HI\"]]\n", 66 | "print(len(l))\n", 67 | "print(l[7]) # a = [1, 2, 'HI'] l[7][2]\n", 68 | "print(l[7][2].lower())" 69 | ] 70 | }, 71 | { 72 | "cell_type": "code", 73 | "execution_count": 20, 74 | "metadata": {}, 75 | "outputs": [ 76 | { 77 | "name": "stdout", 78 | "output_type": "stream", 79 | "text": [ 80 | "(1, 2, 4.6, -0.7, 'A', 'hello', True, [1, 2], (192, 234))\n", 81 | "\n", 82 | "1\n", 83 | "(-0.7, 'A', 'hello')\n" 84 | ] 85 | } 86 | ], 87 | "source": [ 88 | "# Tuple\n", 89 | "\n", 90 | "t = (1, 2, 4.6, -0.7, \"A\", \"hello\", True,[1,2],(192,234))\n", 91 | "print(t)\n", 92 | "print(type(t))\n", 93 | "print(t[0])\n", 94 | "print(t[-6:6])" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "execution_count": null, 100 | "metadata": {}, 101 | "outputs": [], 102 | "source": [ 103 | "print(\"HI\")" 104 | ] 105 | } 106 | ], 107 | "metadata": { 108 | "kernelspec": { 109 | "display_name": "Python 3", 110 | "language": "python", 111 | "name": "python3" 112 | }, 113 | "language_info": { 114 | "codemirror_mode": { 115 | "name": "ipython", 116 | "version": 3 117 | }, 118 | "file_extension": ".py", 119 | "mimetype": "text/x-python", 120 | "name": "python", 121 | "nbconvert_exporter": "python", 122 | "pygments_lexer": "ipython3", 123 | "version": "3.11.3" 124 | } 125 | }, 126 | "nbformat": 4, 127 | "nbformat_minor": 2 128 | } 129 | --------------------------------------------------------------------------------