├── Batch-3 ├── Day-1 │ └── Welcome.md ├── Day-2 │ ├── Assignment Day 2.pdf │ └── Day 2 Notes.ipynb ├── Day-3 │ ├── Assignment Day 3_Updated.pdf │ ├── Day 3 - Assignment Solution .ipynb │ └── Day 3 Notes.ipynb ├── Day-4 │ ├── Assignment Day 4.pdf │ ├── Day 4 Assignment Solution.ipynb │ └── Day 4 FCS Notes .ipynb ├── Day-5 │ ├── Assignment Day 5.pdf │ ├── Day 5 Assignments Solution .ipynb │ └── Day 5 Notes.ipynb ├── Day-6 │ ├── Assignment Day 6.pdf │ ├── Day 6 Assignment Solution.ipynb │ └── Day 6 notes .ipynb ├── Day-7 │ ├── Assignment Day 7.pdf │ ├── Day 7 Assignment Solution .ipynb │ └── Day 7 Notes.ipynb ├── Day-8 │ ├── Assignment Day 8 (optional).pdf │ └── Day 8 Notes.ipynb ├── Optional Assignment - 7 May 2020 │ └── Optional Assignment.pdf └── Silver Project - Tic Tac Toe │ └── TIC TAC TOE Solution .ipynb ├── Batch-4 ├── Day 2 │ ├── Assignment Day 2.pdf │ └── Day 2 Notes.ipynb ├── Day 3 │ ├── Assignment Day 3.pdf │ └── Day 3 Notes.ipynb ├── Day-4 │ ├── Assignment Day 4 .ipynb │ ├── Assignment Day 4.pdf │ ├── Day 4 - Python FCS B4 (1).ipynb │ └── Day 4 Notes.ipynb ├── Day-5 │ ├── Assignment Day 5.pdf │ └── Day 5 Notes.ipynb ├── Day-6 │ ├── Assignment Day 6.pdf │ └── Day 6 Notes.ipynb ├── Day-7 │ ├── Assignment Day 7.pdf │ └── Day 7 Notes.ipynb └── Day-8 │ ├── Assignment Day 8.pdf │ └── Day 8 Notes.ipynb ├── Batch-5 ├── Day-2 │ ├── Day 2 Assignment.pdf │ └── Day 2 Notes.ipynb ├── Day-3 │ ├── Assignment Day 3.pdf │ └── Day 3 Notes.ipynb ├── Day-4 │ ├── Assignment Day 4.pdf │ └── Day 4 Notes.ipynb ├── Day-5 │ ├── Assignment Day 5.pdf │ └── Day 5 Notes.ipynb ├── Day-6 │ ├── Assignment Day 6.pdf │ └── Day 6 Notes.ipynb ├── Day-7 │ ├── Assignment Day 7.pdf │ └── Day 7 Notes.ipynb └── Day-8 │ ├── Assignment Day 8.pdf │ └── Day 8 Notes.ipynb ├── Batch-6 ├── Day-2 │ └── Assignment Day 2.pdf ├── Day-3 │ └── Assignment Day 3.pdf ├── Day-4 │ └── Day 4 Assignment.pdf ├── Day-5 │ └── Day 5 Assignment.pdf ├── Day-6 │ └── Day 6 Assignment.pdf └── Day-7 │ └── Day 7 Assignment.pdf └── Batch-7 ├── Day-2 ├── Assignment │ └── Day 2 Assignment.pdf └── Notes │ └── Day_2_-_B7.ipynb ├── Day-3 ├── Assignment │ └── Day 3 Assignment.pdf └── Notes │ └── Day_3_-_B7.ipynb ├── Day-4 ├── Assignment │ └── Day 4 Assignment.pdf └── Notes │ └── Day 4 Notes.ipynb ├── Day-5 ├── Assignment │ └── Day 5 Assignment.pdf └── Notes │ └── Day 5 .ipynb ├── Day-6 ├── Assignments │ └── Assignment Day 6.pdf ├── Notes │ └── Day 6 .ipynb └── Silver Project │ └── Silver Project .ipynb ├── Day-7 └── Notes │ └── Day 7 - Python .ipynb ├── Day-8 ├── Assignment │ └── Assignment Day 8.pdf └── Notes │ └── Day 8 Notes.ipynb └── Day-9 ├── Assignment └── Assignment Day 9.pdf └── Notes └── Day 9 Notes.ipynb /Batch-3/Day-1/Welcome.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-3/Day-1/Welcome.md -------------------------------------------------------------------------------- /Batch-3/Day-2/Assignment Day 2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-3/Day-2/Assignment Day 2.pdf -------------------------------------------------------------------------------- /Batch-3/Day-3/Assignment Day 3_Updated.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-3/Day-3/Assignment Day 3_Updated.pdf -------------------------------------------------------------------------------- /Batch-3/Day-3/Day 3 - Assignment Solution .ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "# Q1 - WAP for taking one number a input and then using if elif else concept, assign a grade to the input number from \n", 10 | "\n", 11 | "#A,B,C,D,E, Fail\n", 12 | "\n", 13 | "#In a formatted report card\n", 14 | "\n", 15 | "#|------|\n", 16 | "#| A |\n", 17 | "#|_____|\n", 18 | "\n", 19 | "\n" 20 | ] 21 | }, 22 | { 23 | "cell_type": "code", 24 | "execution_count": 19, 25 | "metadata": {}, 26 | "outputs": [ 27 | { 28 | "name": "stdout", 29 | "output_type": "stream", 30 | "text": [ 31 | "Enter your marks - 78\n", 32 | "|--------|\n", 33 | "| B |\n", 34 | "|--------|\n" 35 | ] 36 | } 37 | ], 38 | "source": [ 39 | "#Assignment 1 - \n", 40 | "\n", 41 | "marks = int(input(\"Enter your marks - \"))\n", 42 | "\n", 43 | "print('|--------|')\n", 44 | "if(marks >= 85):\n", 45 | " print(\"| A |\")\n", 46 | "elif (marks>=75 and marks <= 84):\n", 47 | " print(\"| B |\")\n", 48 | "elif (marks>=65 and marks <= 74):\n", 49 | " print(\"| C |\")\n", 50 | "elif (marks>=55 and marks <= 64):\n", 51 | " print(\"| D |\")\n", 52 | "elif (marks>=45 and marks <= 54):\n", 53 | " print(\"| E |\")\n", 54 | "else:\n", 55 | " print(\"Need imporvement\")\n", 56 | " \n", 57 | "print('|--------|')\n" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 7, 63 | "metadata": {}, 64 | "outputs": [ 65 | { 66 | "name": "stdout", 67 | "output_type": "stream", 68 | "text": [ 69 | "Computer Generated Team India Cricket Score - 58\n", 70 | "enter your guess 55\n", 71 | "Close by, you are True Indian Fan!\n" 72 | ] 73 | } 74 | ], 75 | "source": [ 76 | "# Assignment 2 - \n", 77 | "\n", 78 | "#Generating computer Score module \n", 79 | "\n", 80 | "from random import randint \n", 81 | "\n", 82 | "computer_generated_team_india_score = randint(1,250)\n", 83 | "print(\"Computer Generated Team India Cricket Score - \",computer_generated_team_india_score)\n", 84 | "\n", 85 | "#Guessing module --- \n", 86 | "while True:\n", 87 | " user_input = int(input(\"enter your guess \"))\n", 88 | " if(user_input>=1 and user_input<=250):\n", 89 | " break\n", 90 | " else:\n", 91 | " print(\"Reduce your expectation for 20-20 Cricket. Enter your number again\")\n", 92 | "\n", 93 | "#Checking whether the number is near by yes or no \n", 94 | "diffeence = abs(user_input - computer_generated_team_india_score)\n", 95 | "\n", 96 | "if ( diffeence <=10 and diffeence >=1):\n", 97 | " print(\"Close by, you are True Indian Fan!\")\n", 98 | "else:\n", 99 | " print(\"You don't watch that much! :P\")" 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "execution_count": 4, 105 | "metadata": {}, 106 | "outputs": [], 107 | "source": [ 108 | "# Assignment 3 - \n", 109 | "\n", 110 | "\n", 111 | "file = open(\"assignment5.txt\",'w')\n", 112 | "\n", 113 | "file.write(\"I love and live for FCS\")\n", 114 | "\n", 115 | "file.close()\n" 116 | ] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": 6, 121 | "metadata": {}, 122 | "outputs": [ 123 | { 124 | "name": "stdout", 125 | "output_type": "stream", 126 | "text": [ 127 | "I love and live for FCS\n" 128 | ] 129 | } 130 | ], 131 | "source": [ 132 | "file = open(\"assignment5.txt\",'r')\n", 133 | "\n", 134 | "print(file.read())\n", 135 | "\n", 136 | "file.close()" 137 | ] 138 | }, 139 | { 140 | "cell_type": "code", 141 | "execution_count": 10, 142 | "metadata": {}, 143 | "outputs": [ 144 | { 145 | "name": "stdout", 146 | "output_type": "stream", 147 | "text": [ 148 | "Enter number of chances you want a user to upload ?2\n", 149 | "Enter the min Length ?10\n", 150 | "Enter ur Height of photo ?0\n", 151 | "Enter ur Width of the photo ?0\n", 152 | "minimum photo size should be four - 10\n", 153 | "Enter ur Height of photo ?10\n", 154 | "Enter ur Width of the photo ?20\n", 155 | "Crop it\n" 156 | ] 157 | } 158 | ], 159 | "source": [ 160 | "# Assignment 4 -- \n", 161 | "\n", 162 | "# L, N, W, H\n", 163 | "# how many times u want to upload a Photo ? \n", 164 | "n = int(input(\"Enter number of chances you want a user to upload ?\"))\n", 165 | "\n", 166 | "#Enter the Lenght size \n", 167 | "l = int(input(\"Enter the min Length ?\"))\n", 168 | "\n", 169 | "curent_operation = 0\n", 170 | "while(curent_operation= l and w >=l):\n", 177 | " if(h==w):\n", 178 | " print(\"Accepted\")\n", 179 | " else:\n", 180 | " print(\"Crop it\")\n", 181 | " else:\n", 182 | " print(\"minimum photo size should be - \", l )" 183 | ] 184 | }, 185 | { 186 | "cell_type": "code", 187 | "execution_count": null, 188 | "metadata": {}, 189 | "outputs": [], 190 | "source": [ 191 | "# Assignment 5\n", 192 | "\n", 193 | "ankit_x = 0 \n", 194 | "ankit_y = 0 \n", 195 | "\n", 196 | "max_move = 0\n", 197 | "\n", 198 | "while(max_move <= 5):\n", 199 | " max_move += 1\n", 200 | " command = input(\"Enter the Command for ankit to move - \")\n", 201 | " command = command.lower()\n", 202 | " \n", 203 | " if(command == \"l\"):\n", 204 | " ankit_x += -1\n", 205 | " elif (command == \"r\"):\n", 206 | " ankit_x += +1\n", 207 | " elif (command == \"u\"):\n", 208 | " ankit_y += 1\n", 209 | " elif( command == \"d\"):\n", 210 | " ankit_y -= 1\n", 211 | " else: \n", 212 | " print(\"Enter valid input, L,R,U,D\")\n", 213 | " \n", 214 | " print(\"ankit is here - \", ankit_x, ankit_y)\n", 215 | " " 216 | ] 217 | }, 218 | { 219 | "cell_type": "code", 220 | "execution_count": null, 221 | "metadata": {}, 222 | "outputs": [], 223 | "source": [] 224 | } 225 | ], 226 | "metadata": { 227 | "kernelspec": { 228 | "display_name": "Python 3", 229 | "language": "python", 230 | "name": "python3" 231 | }, 232 | "language_info": { 233 | "codemirror_mode": { 234 | "name": "ipython", 235 | "version": 3 236 | }, 237 | "file_extension": ".py", 238 | "mimetype": "text/x-python", 239 | "name": "python", 240 | "nbconvert_exporter": "python", 241 | "pygments_lexer": "ipython3", 242 | "version": "3.7.6" 243 | } 244 | }, 245 | "nbformat": 4, 246 | "nbformat_minor": 2 247 | } 248 | -------------------------------------------------------------------------------- /Batch-3/Day-4/Assignment Day 4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-3/Day-4/Assignment Day 4.pdf -------------------------------------------------------------------------------- /Batch-3/Day-4/Day 4 Assignment Solution.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Assignment 4" 8 | ] 9 | }, 10 | { 11 | "cell_type": "raw", 12 | "metadata": {}, 13 | "source": [ 14 | "Write a program to identify [1,1,5] in the given list in the same order,\n", 15 | "if yes print \"It's a Match\"if no then print \"It's Gone\"\n", 16 | "\n", 17 | "Output should be something like this\n", 18 | "for examples : Listy = [1,5,6,4,1,2,3,5] -- It's a Match (only if the condition is true)\n", 19 | " Listy = [1,5,6,5,1,2,3,6] -- It's Gone (if the condition is false)" 20 | ] 21 | }, 22 | { 23 | "cell_type": "raw", 24 | "metadata": {}, 25 | "source": [ 26 | "1. Take input of 8 elements as a list\n", 27 | "2. Check if sublist [1,1,5] is coming in same order" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": 3, 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "name": "stdout", 37 | "output_type": "stream", 38 | "text": [ 39 | "Enter number 1: 1\n", 40 | "Enter number 2: 4\n", 41 | "Enter number 3: 5\n", 42 | "Enter number 4: 5\n", 43 | "Enter number 5: 4\n", 44 | "Enter number 6: 4\n", 45 | "Enter number 7: 4\n", 46 | "Enter number 8: 4\n", 47 | "Provided List is : [1, 4, 5, 5, 4, 4, 4, 4]\n" 48 | ] 49 | }, 50 | { 51 | "data": { 52 | "text/plain": [ 53 | "\"It's gone\"" 54 | ] 55 | }, 56 | "execution_count": 3, 57 | "metadata": {}, 58 | "output_type": "execute_result" 59 | } 60 | ], 61 | "source": [ 62 | "#Function to get input from the user\n", 63 | "def getInput():\n", 64 | " tempList=[]\n", 65 | " i=0\n", 66 | " while i < 8:\n", 67 | " val = int(input(f\"Enter number {i+1}: \"))#search about formatted output in python for the \"f\" part\n", 68 | " tempList.append(val)\n", 69 | " i+=1\n", 70 | " return tempList\n", 71 | "\n", 72 | "#function to check if the sublist exist in the superlist in the same order\n", 73 | "def check(a):\n", 74 | " subList = [1,1,5]\n", 75 | " for i in a:\n", 76 | " for j in subList:\n", 77 | " if(len(subList)>=0 and j == i):\n", 78 | " subList.pop(0)\n", 79 | " else:\n", 80 | " break\n", 81 | " \n", 82 | " if len(subList)==0:\n", 83 | " return \"It's a match\"\n", 84 | " else:\n", 85 | " return \"It's gone\"\n", 86 | "\n", 87 | "#Main\n", 88 | "supList = getInput() \n", 89 | "print(\"Provided List is :\",supList)\n", 90 | "check(supList) \n", 91 | " " 92 | ] 93 | }, 94 | { 95 | "cell_type": "code", 96 | "execution_count": null, 97 | "metadata": {}, 98 | "outputs": [], 99 | "source": [] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": null, 104 | "metadata": {}, 105 | "outputs": [], 106 | "source": [] 107 | } 108 | ], 109 | "metadata": { 110 | "kernelspec": { 111 | "display_name": "Python 3", 112 | "language": "python", 113 | "name": "python3" 114 | }, 115 | "language_info": { 116 | "codemirror_mode": { 117 | "name": "ipython", 118 | "version": 3 119 | }, 120 | "file_extension": ".py", 121 | "mimetype": "text/x-python", 122 | "name": "python", 123 | "nbconvert_exporter": "python", 124 | "pygments_lexer": "ipython3", 125 | "version": "3.7.6" 126 | } 127 | }, 128 | "nbformat": 4, 129 | "nbformat_minor": 4 130 | } 131 | -------------------------------------------------------------------------------- /Batch-3/Day-4/Day 4 FCS Notes .ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# methods " 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 1, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "lst = [1,2,3,4,5,6]" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 2, 22 | "metadata": {}, 23 | "outputs": [], 24 | "source": [ 25 | "lst.append(12)" 26 | ] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "execution_count": 3, 31 | "metadata": {}, 32 | "outputs": [ 33 | { 34 | "name": "stdout", 35 | "output_type": "stream", 36 | "text": [ 37 | "Help on built-in function append:\n", 38 | "\n", 39 | "append(object, /) method of builtins.list instance\n", 40 | " Append object to the end of the list.\n", 41 | "\n" 42 | ] 43 | } 44 | ], 45 | "source": [ 46 | "help(lst.append)" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": 4, 52 | "metadata": {}, 53 | "outputs": [], 54 | "source": [ 55 | "dit = {\"key1\":1,\"key2\":2}" 56 | ] 57 | }, 58 | { 59 | "cell_type": "markdown", 60 | "metadata": {}, 61 | "source": [ 62 | "# Functions ?\n", 63 | "\n" 64 | ] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "metadata": {}, 69 | "source": [ 70 | "1. We use functions for breaking the big peice of code to small manageable codes \n", 71 | "\n", 72 | "2. we use functions for code reusablity, \n", 73 | "\n", 74 | "3. we use function for recuding down the memory usage. \n", 75 | "\n", 76 | "4. We use function for reducing time and efforts \n" 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "execution_count": 15, 82 | "metadata": {}, 83 | "outputs": [], 84 | "source": [ 85 | "# How to write our first function in Python \n", 86 | "\n", 87 | "def someFunction():\n", 88 | " '''\n", 89 | " Hey this function is there for our understanding !! :)\n", 90 | " '''\n", 91 | " print(\"Hey Hi i am a peice of module - \")\n", 92 | " print(\"I am another line from the code\")\n", 93 | " " 94 | ] 95 | }, 96 | { 97 | "cell_type": "code", 98 | "execution_count": 7, 99 | "metadata": {}, 100 | "outputs": [ 101 | { 102 | "name": "stdout", 103 | "output_type": "stream", 104 | "text": [ 105 | "Hey Hi i am a peice of module - \n", 106 | "I am another line from the code\n" 107 | ] 108 | } 109 | ], 110 | "source": [ 111 | "# How to call a function\n", 112 | "\n", 113 | "someFunction()" 114 | ] 115 | }, 116 | { 117 | "cell_type": "code", 118 | "execution_count": 12, 119 | "metadata": {}, 120 | "outputs": [ 121 | { 122 | "data": { 123 | "text/plain": [ 124 | "" 125 | ] 126 | }, 127 | "execution_count": 12, 128 | "metadata": {}, 129 | "output_type": "execute_result" 130 | } 131 | ], 132 | "source": [ 133 | "# if u dont write () in the end what happens ?\n", 134 | "someFunction\n", 135 | "# It prints ur Address of the function from the memory" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": 13, 141 | "metadata": {}, 142 | "outputs": [ 143 | { 144 | "name": "stdout", 145 | "output_type": "stream", 146 | "text": [ 147 | "Hey Hi i am a peice of module - \n", 148 | "I am another line from the code\n" 149 | ] 150 | } 151 | ], 152 | "source": [ 153 | "someFunction()" 154 | ] 155 | }, 156 | { 157 | "cell_type": "code", 158 | "execution_count": 14, 159 | "metadata": {}, 160 | "outputs": [ 161 | { 162 | "name": "stdout", 163 | "output_type": "stream", 164 | "text": [ 165 | "Help on function someFunction in module __main__:\n", 166 | "\n", 167 | "someFunction()\n", 168 | " Doc String for expanations\n", 169 | "\n" 170 | ] 171 | } 172 | ], 173 | "source": [ 174 | "help(someFunction)" 175 | ] 176 | }, 177 | { 178 | "cell_type": "code", 179 | "execution_count": 16, 180 | "metadata": {}, 181 | "outputs": [ 182 | { 183 | "name": "stdout", 184 | "output_type": "stream", 185 | "text": [ 186 | "Help on function someFunction in module __main__:\n", 187 | "\n", 188 | "someFunction()\n", 189 | " Hey this function is there for our understanding !! :)\n", 190 | "\n" 191 | ] 192 | } 193 | ], 194 | "source": [ 195 | "help(someFunction)" 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": 20, 201 | "metadata": {}, 202 | "outputs": [], 203 | "source": [ 204 | "#How to take a aurgument for my functionm\n", 205 | "\n", 206 | "def someFunction(thisIsOurAurgument, ourSecAurgument):\n", 207 | " '''\n", 208 | " Hey this function is there for our understanding !! :)\n", 209 | " '''\n", 210 | " print(\"Hey Hi i am a peice of module - \", thisIsOurAurgument)\n", 211 | " print(\"I am another line from the code - \", ourSecAurgument)" 212 | ] 213 | }, 214 | { 215 | "cell_type": "code", 216 | "execution_count": 21, 217 | "metadata": {}, 218 | "outputs": [ 219 | { 220 | "name": "stdout", 221 | "output_type": "stream", 222 | "text": [ 223 | "Hey Hi i am a peice of module - Aditya\n", 224 | "I am another line from the code Shekhar\n" 225 | ] 226 | } 227 | ], 228 | "source": [ 229 | "someFunction(\" Aditya\", \"Shekhar\")" 230 | ] 231 | }, 232 | { 233 | "cell_type": "code", 234 | "execution_count": 28, 235 | "metadata": {}, 236 | "outputs": [], 237 | "source": [ 238 | "#How can our Fun. return a value ?\n", 239 | "\n", 240 | "def playingMyFavSong(songNo):\n", 241 | " '''\n", 242 | " This function suggest u a song\n", 243 | " '''\n", 244 | " if songNo == 1:\n", 245 | " return \"Despacito\"\n", 246 | " elif songNo == 2:\n", 247 | " return \"Samajavagamana\"\n", 248 | " elif songNo == 3 :\n", 249 | " return \"Dil Se\"\n", 250 | " elif songNo == 4 :\n", 251 | " return \"Chogada Tara\"\n", 252 | " elif songNo == 5 :\n", 253 | " return \"Chinamma Chinamma\" \n", 254 | " elif songNo == 6 :\n", 255 | " return \"Zinggant\"\n", 256 | " else:\n", 257 | " return \"Listen to Faded\"" 258 | ] 259 | }, 260 | { 261 | "cell_type": "code", 262 | "execution_count": 29, 263 | "metadata": {}, 264 | "outputs": [ 265 | { 266 | "data": { 267 | "text/plain": [ 268 | "'Chinamma Chinamma'" 269 | ] 270 | }, 271 | "execution_count": 29, 272 | "metadata": {}, 273 | "output_type": "execute_result" 274 | } 275 | ], 276 | "source": [ 277 | "playingMyFavSong(5)" 278 | ] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": 30, 283 | "metadata": {}, 284 | "outputs": [ 285 | { 286 | "data": { 287 | "text/plain": [ 288 | "'Zinggant'" 289 | ] 290 | }, 291 | "execution_count": 30, 292 | "metadata": {}, 293 | "output_type": "execute_result" 294 | } 295 | ], 296 | "source": [ 297 | "playingMyFavSong(6)" 298 | ] 299 | }, 300 | { 301 | "cell_type": "code", 302 | "execution_count": 47, 303 | "metadata": {}, 304 | "outputs": [], 305 | "source": [ 306 | "from random import randint\n", 307 | "\n", 308 | "# this function is returing A Random Odd Number\n", 309 | "\n", 310 | "def getUsARamdomOddNumber():\n", 311 | " value = randint(2, 100)\n", 312 | " if value % 2 == 0:\n", 313 | " value = value -1\n", 314 | " return value" 315 | ] 316 | }, 317 | { 318 | "cell_type": "code", 319 | "execution_count": 60, 320 | "metadata": {}, 321 | "outputs": [ 322 | { 323 | "data": { 324 | "text/plain": [ 325 | "97" 326 | ] 327 | }, 328 | "execution_count": 60, 329 | "metadata": {}, 330 | "output_type": "execute_result" 331 | } 332 | ], 333 | "source": [ 334 | "getUsARamdomOddNumber()" 335 | ] 336 | }, 337 | { 338 | "cell_type": "code", 339 | "execution_count": 62, 340 | "metadata": {}, 341 | "outputs": [], 342 | "source": [ 343 | "# We need to make a function which actually get two random odd numbers \n", 344 | "# then multiple it and return the number\n", 345 | "\n", 346 | "def multipleTwoRandomOddNumber():\n", 347 | " value1 = getUsARamdomOddNumber()\n", 348 | " value2 = getUsARamdomOddNumber()\n", 349 | " print(value1,' ', value2)\n", 350 | " return value1 * value2" 351 | ] 352 | }, 353 | { 354 | "cell_type": "code", 355 | "execution_count": 65, 356 | "metadata": {}, 357 | "outputs": [ 358 | { 359 | "name": "stdout", 360 | "output_type": "stream", 361 | "text": [ 362 | "57 85\n" 363 | ] 364 | }, 365 | { 366 | "data": { 367 | "text/plain": [ 368 | "4845" 369 | ] 370 | }, 371 | "execution_count": 65, 372 | "metadata": {}, 373 | "output_type": "execute_result" 374 | } 375 | ], 376 | "source": [ 377 | "multipleTwoRandomOddNumber()" 378 | ] 379 | }, 380 | { 381 | "cell_type": "code", 382 | "execution_count": 80, 383 | "metadata": {}, 384 | "outputs": [], 385 | "source": [ 386 | "# if you wish to take N number of Arguments in the python function, \n", 387 | "\n", 388 | "# how to do take \n", 389 | "\n", 390 | "def takeN_NumberOfAurguments(*sgra):\n", 391 | " for i in sgra:\n", 392 | " print(\"Args which we got - \",i) " 393 | ] 394 | }, 395 | { 396 | "cell_type": "code", 397 | "execution_count": 81, 398 | "metadata": {}, 399 | "outputs": [ 400 | { 401 | "name": "stdout", 402 | "output_type": "stream", 403 | "text": [ 404 | "Args which we got - HI\n", 405 | "Args which we got - [1, 2, 3]\n", 406 | "Args which we got - {'key1': 1, 'key2': 2}\n", 407 | "Args which we got - 4\n", 408 | "Args which we got - I Hope u are understanding ?\n" 409 | ] 410 | } 411 | ], 412 | "source": [ 413 | "takeN_NumberOfAurguments(\"HI\",[1,2,3],{'key1':1,\"key2\":2},4,\"I Hope u are understanding ?\")" 414 | ] 415 | }, 416 | { 417 | "cell_type": "code", 418 | "execution_count": 82, 419 | "metadata": {}, 420 | "outputs": [], 421 | "source": [ 422 | "# If u want to pass multiple Arguments into the function \n", 423 | "# But want to have a variable name for each one of the aurgument a\n", 424 | "# just like how we use in Dict \n", 425 | "# then we should look at **KWARGS \n", 426 | "\n", 427 | "def takeMultipleKeyValueArgs(**agrawk):\n", 428 | " for key, value in agrawk.items():\n", 429 | " print(\"The Key - [\", key,\"] The Val - [\",value,\" ]\")\n", 430 | " " 431 | ] 432 | }, 433 | { 434 | "cell_type": "code", 435 | "execution_count": 83, 436 | "metadata": {}, 437 | "outputs": [ 438 | { 439 | "name": "stdout", 440 | "output_type": "stream", 441 | "text": [ 442 | "The Key - [ name ] The Val - [ LetsUpgrade ]\n", 443 | "The Key - [ age ] The Val - [ 2 ]\n", 444 | "The Key - [ dob ] The Val - [ 8th May 2018 ]\n" 445 | ] 446 | } 447 | ], 448 | "source": [ 449 | "takeMultipleKeyValueArgs(name= \"LetsUpgrade\", age = 2, dob = \"8th May 2018\")\n", 450 | "\n" 451 | ] 452 | }, 453 | { 454 | "cell_type": "code", 455 | "execution_count": 84, 456 | "metadata": {}, 457 | "outputs": [], 458 | "source": [ 459 | "# *args is used of passing multiplew value, u cant access with name\n", 460 | "\n", 461 | "# **kwargs is used for passing multiple Key value pairs to make\n", 462 | "# sure you can access any value with a name\n", 463 | "\n" 464 | ] 465 | }, 466 | { 467 | "cell_type": "code", 468 | "execution_count": 85, 469 | "metadata": {}, 470 | "outputs": [], 471 | "source": [ 472 | "# problem statement is - \n", 473 | "\n", 474 | "# Build a Fucntion for sending mails to a specif \n", 475 | "# email ids given in a argument\n", 476 | "\n", 477 | "\n", 478 | "def sendEmailsToTheListOfPeople(*emailList):\n", 479 | " for emails in emailList:\n", 480 | " print(\"Email is been sent to - \",emails) \n" 481 | ] 482 | }, 483 | { 484 | "cell_type": "code", 485 | "execution_count": 88, 486 | "metadata": {}, 487 | "outputs": [ 488 | { 489 | "name": "stdout", 490 | "output_type": "stream", 491 | "text": [ 492 | "Email is been sent to - sai@itm.edu\n", 493 | "Email is been sent to - viralp@itm.edu\n", 494 | "Email is been sent to - amareshb@itm.edu\n", 495 | "Email is been sent to - vishnun@itm.edu\n", 496 | "Email is been sent to - harshrajs@itm.edu\n" 497 | ] 498 | } 499 | ], 500 | "source": [ 501 | "sendEmailsToTheListOfPeople(\"sai@itm.edu\",\"viralp@itm.edu\",\n", 502 | " \"amareshb@itm.edu\",\"vishnun@itm.edu\",\n", 503 | " \"harshrajs@itm.edu\")" 504 | ] 505 | }, 506 | { 507 | "cell_type": "code", 508 | "execution_count": 89, 509 | "metadata": {}, 510 | "outputs": [], 511 | "source": [ 512 | "# Problem statement 2 - \n", 513 | "\n", 514 | "# print the name, age and dob of the student in a formatted way \n", 515 | "\n", 516 | "#like \n", 517 | "\n", 518 | "# ---------------\n", 519 | "# | Name - |\n", 520 | "# | Age - |\n", 521 | "# | DOB - |\n", 522 | "# ---------------" 523 | ] 524 | }, 525 | { 526 | "cell_type": "code", 527 | "execution_count": 96, 528 | "metadata": {}, 529 | "outputs": [], 530 | "source": [ 531 | "def printStudentDataInFormat(**studentInfo):\n", 532 | " \n", 533 | " print(\"------------\")\n", 534 | " print(\"Name - \", studentInfo.get(\"name\") )\n", 535 | " print(\"Age - \", studentInfo.get(\"age\") )\n", 536 | " print(\"DOB - \", studentInfo.get(\"dob\") )\n", 537 | " print(\"------------\")\n", 538 | "\n", 539 | " \n", 540 | " \n", 541 | " " 542 | ] 543 | }, 544 | { 545 | "cell_type": "code", 546 | "execution_count": 97, 547 | "metadata": {}, 548 | "outputs": [ 549 | { 550 | "name": "stdout", 551 | "output_type": "stream", 552 | "text": [ 553 | "------------\n", 554 | "Name - Sai\n", 555 | "Age - 60\n", 556 | "DOB - 01 01 1960\n", 557 | "------------\n" 558 | ] 559 | } 560 | ], 561 | "source": [ 562 | "printStudentDataInFormat(name = \"Sai\", age =60,dob = \"01 01 1960\")" 563 | ] 564 | }, 565 | { 566 | "cell_type": "code", 567 | "execution_count": null, 568 | "metadata": {}, 569 | "outputs": [], 570 | "source": [] 571 | } 572 | ], 573 | "metadata": { 574 | "kernelspec": { 575 | "display_name": "Python 3", 576 | "language": "python", 577 | "name": "python3" 578 | }, 579 | "language_info": { 580 | "codemirror_mode": { 581 | "name": "ipython", 582 | "version": 3 583 | }, 584 | "file_extension": ".py", 585 | "mimetype": "text/x-python", 586 | "name": "python", 587 | "nbconvert_exporter": "python", 588 | "pygments_lexer": "ipython3", 589 | "version": "3.7.4" 590 | } 591 | }, 592 | "nbformat": 4, 593 | "nbformat_minor": 2 594 | } 595 | -------------------------------------------------------------------------------- /Batch-3/Day-5/Assignment Day 5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-3/Day-5/Assignment Day 5.pdf -------------------------------------------------------------------------------- /Batch-3/Day-5/Day 5 Assignments Solution .ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "class Bank():\n", 10 | " def __init__(self,owner,balance=0):\n", 11 | " self.owner = owner\n", 12 | " self.balance = balance\n", 13 | " \n", 14 | " def deposit(self, balance):\n", 15 | " self.balance+= balance\n", 16 | " return self.balance\n", 17 | " \n", 18 | " def withdraw(self,balance):\n", 19 | " if self.balance >= balance:\n", 20 | " self.balance-=balance\n", 21 | " else:\n", 22 | " return \"Not Possible only \" + str(self.balance) + ' is avaliable'\n", 23 | " return self.balance" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": 3, 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "account1 = Bank('account1',100)" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 4, 38 | "metadata": {}, 39 | "outputs": [ 40 | { 41 | "data": { 42 | "text/plain": [ 43 | "1100" 44 | ] 45 | }, 46 | "execution_count": 4, 47 | "metadata": {}, 48 | "output_type": "execute_result" 49 | } 50 | ], 51 | "source": [ 52 | "account1.deposit(1000)" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": 5, 58 | "metadata": {}, 59 | "outputs": [ 60 | { 61 | "data": { 62 | "text/plain": [ 63 | "'Not Possible only 1100 is avaliable'" 64 | ] 65 | }, 66 | "execution_count": 5, 67 | "metadata": {}, 68 | "output_type": "execute_result" 69 | } 70 | ], 71 | "source": [ 72 | "account1.withdraw(2000)" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": 6, 78 | "metadata": {}, 79 | "outputs": [ 80 | { 81 | "data": { 82 | "text/plain": [ 83 | "400" 84 | ] 85 | }, 86 | "execution_count": 6, 87 | "metadata": {}, 88 | "output_type": "execute_result" 89 | } 90 | ], 91 | "source": [ 92 | "account1.withdraw(700)" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": 10, 98 | "metadata": {}, 99 | "outputs": [], 100 | "source": [ 101 | "import math\n", 102 | "class Cone:\n", 103 | " def __init__(self,r=1,h=1):\n", 104 | " self.r = r\n", 105 | " self.h = h\n", 106 | " self.volume =0\n", 107 | " self.surface_area = 0\n", 108 | " def volume_fun(self):\n", 109 | " self.volume = math.pi * self.r * self.r * (self.h/3)\n", 110 | " return self.volume\n", 111 | " def surface_area_fun(self):\n", 112 | " base = math.pi * self.r * self.r\n", 113 | " side = math.pi * self.r * math.sqrt(self.r**2 + self.h**2)\n", 114 | " self.surface_area = base + side\n", 115 | " return self.surface_area" 116 | ] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": 11, 121 | "metadata": {}, 122 | "outputs": [], 123 | "source": [ 124 | "cone1 = Cone(5,7)" 125 | ] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "execution_count": 12, 130 | "metadata": {}, 131 | "outputs": [ 132 | { 133 | "data": { 134 | "text/plain": [ 135 | "183.2595714594046" 136 | ] 137 | }, 138 | "execution_count": 12, 139 | "metadata": {}, 140 | "output_type": "execute_result" 141 | } 142 | ], 143 | "source": [ 144 | "cone1.volume_fun()" 145 | ] 146 | }, 147 | { 148 | "cell_type": "code", 149 | "execution_count": null, 150 | "metadata": {}, 151 | "outputs": [], 152 | "source": [] 153 | } 154 | ], 155 | "metadata": { 156 | "kernelspec": { 157 | "display_name": "Python 3", 158 | "language": "python", 159 | "name": "python3" 160 | }, 161 | "language_info": { 162 | "codemirror_mode": { 163 | "name": "ipython", 164 | "version": 3 165 | }, 166 | "file_extension": ".py", 167 | "mimetype": "text/x-python", 168 | "name": "python", 169 | "nbconvert_exporter": "python", 170 | "pygments_lexer": "ipython3", 171 | "version": "3.7.4" 172 | } 173 | }, 174 | "nbformat": 4, 175 | "nbformat_minor": 2 176 | } 177 | -------------------------------------------------------------------------------- /Batch-3/Day-6/Assignment Day 6.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-3/Day-6/Assignment Day 6.pdf -------------------------------------------------------------------------------- /Batch-3/Day-6/Day 6 Assignment Solution.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Write a python Function for finding is a given number prime or not and do Unit Testing on it using PyLint & Unittest Library." 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 1, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "import sympy\n", 17 | "\n", 18 | "def checkPrimeNumber(num):\n", 19 | " if sympy.isprime(num):\n", 20 | " return num\n", 21 | " else:\n", 22 | " return(\"No Prime\")" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": 2, 28 | "metadata": {}, 29 | "outputs": [ 30 | { 31 | "data": { 32 | "text/plain": [ 33 | "7" 34 | ] 35 | }, 36 | "execution_count": 2, 37 | "metadata": {}, 38 | "output_type": "execute_result" 39 | } 40 | ], 41 | "source": [ 42 | "checkPrimeNumber(7)" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 1, 48 | "metadata": {}, 49 | "outputs": [ 50 | { 51 | "name": "stdout", 52 | "output_type": "stream", 53 | "text": [ 54 | "Writing check_pri.py\n" 55 | ] 56 | } 57 | ], 58 | "source": [ 59 | "%%writefile check_pri.py\n", 60 | "import sympy\n", 61 | "'''\n", 62 | "Module to check prime Number\n", 63 | "'''\n", 64 | "def checkPrimeNumber(num):\n", 65 | " '''\n", 66 | " Function to Check Prime takes a Input\n", 67 | " '''\n", 68 | " if sympy.isprime(num):\n", 69 | " '''\n", 70 | " if statement\n", 71 | " '''\n", 72 | " return num\n", 73 | " else:\n", 74 | " return \"No Prime\"" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": 15, 80 | "metadata": {}, 81 | "outputs": [ 82 | { 83 | "name": "stdout", 84 | "output_type": "stream", 85 | "text": [ 86 | "************* Module chPrime\n", 87 | "chPrime.py:1:0: C0103: Module name \"chPrime\" doesn't conform to snake_case naming style (invalid-name)\n", 88 | "chPrime.py:1:0: C0114: Missing module docstring (missing-module-docstring)\n", 89 | "chPrime.py:4:-1: W0105: String statement has no effect (pointless-string-statement)\n", 90 | "chPrime.py:5:0: C0103: Function name \"checkPrimeNumber\" doesn't conform to snake_case naming style (invalid-name)\n", 91 | "chPrime.py:9:4: R1705: Unnecessary \"else\" after \"return\" (no-else-return)\n", 92 | "\n", 93 | "-----------------------------------\n", 94 | "Your code has been rated at 1.67/10\n", 95 | "\n" 96 | ] 97 | } 98 | ], 99 | "source": [ 100 | "!pylint chPrime.py" 101 | ] 102 | }, 103 | { 104 | "cell_type": "code", 105 | "execution_count": 2, 106 | "metadata": {}, 107 | "outputs": [ 108 | { 109 | "name": "stdout", 110 | "output_type": "stream", 111 | "text": [ 112 | "Overwriting check_prime.py\n" 113 | ] 114 | } 115 | ], 116 | "source": [ 117 | "%%writefile check_prime.py\n", 118 | "import unittest \n", 119 | "import check_pri\n", 120 | "\n", 121 | "class TestPrime(unittest.TestCase):\n", 122 | " def checkprimeNumber(self):\n", 123 | " num = 7\n", 124 | " result = chPrime.checkPrimeNumber(num)\n", 125 | " self.assertEqual(result,num)\n", 126 | "\n", 127 | " def checkNotPrimenumber(self):\n", 128 | " num= 8\n", 129 | " result = chPrime.checkPrimeNumber(num)\n", 130 | " self.assertEqual(result,\"No Prime\")\n", 131 | "\n", 132 | "if __name__ == \"__main__\":\n", 133 | " unittest.main()" 134 | ] 135 | }, 136 | { 137 | "cell_type": "code", 138 | "execution_count": 4, 139 | "metadata": {}, 140 | "outputs": [ 141 | { 142 | "name": "stdout", 143 | "output_type": "stream", 144 | "text": [ 145 | "\r\n", 146 | "----------------------------------------------------------------------\r\n", 147 | "Ran 0 tests in 0.000s\r\n", 148 | "\r\n", 149 | "OK\r\n" 150 | ] 151 | } 152 | ], 153 | "source": [ 154 | "!python check_prime.py" 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "execution_count": 7, 160 | "metadata": {}, 161 | "outputs": [ 162 | { 163 | "name": "stdout", 164 | "output_type": "stream", 165 | "text": [ 166 | "/Users/nvrsettle/Python FCS LetsUpgrade\r\n" 167 | ] 168 | } 169 | ], 170 | "source": [ 171 | "!pwd" 172 | ] 173 | }, 174 | { 175 | "cell_type": "code", 176 | "execution_count": null, 177 | "metadata": {}, 178 | "outputs": [], 179 | "source": [] 180 | } 181 | ], 182 | "metadata": { 183 | "kernelspec": { 184 | "display_name": "Python 3", 185 | "language": "python", 186 | "name": "python3" 187 | }, 188 | "language_info": { 189 | "codemirror_mode": { 190 | "name": "ipython", 191 | "version": 3 192 | }, 193 | "file_extension": ".py", 194 | "mimetype": "text/x-python", 195 | "name": "python", 196 | "nbconvert_exporter": "python", 197 | "pygments_lexer": "ipython3", 198 | "version": "3.7.4" 199 | } 200 | }, 201 | "nbformat": 4, 202 | "nbformat_minor": 2 203 | } 204 | -------------------------------------------------------------------------------- /Batch-3/Day-6/Day 6 notes .ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Error Handling and Exceptions " 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 24, 13 | "metadata": {}, 14 | "outputs": [ 15 | { 16 | "ename": "ZeroDivisionError", 17 | "evalue": "division by zero", 18 | "output_type": "error", 19 | "traceback": [ 20 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 21 | "\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", 22 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;36m5\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 23 | "\u001b[0;31mZeroDivisionError\u001b[0m: division by zero" 24 | ] 25 | } 26 | ], 27 | "source": [ 28 | "5/0" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": 10, 34 | "metadata": {}, 35 | "outputs": [ 36 | { 37 | "name": "stdout", 38 | "output_type": "stream", 39 | "text": [ 40 | "It is properly running\n", 41 | "It is a code which will run no matter what\n" 42 | ] 43 | } 44 | ], 45 | "source": [ 46 | "try:\n", 47 | " 5/1\n", 48 | " print(\"It is properly running\")\n", 49 | "except:\n", 50 | " print(\"It was an error thats where we are in Except block\")\n", 51 | "finally:\n", 52 | " print(\"It is a code which will run no matter what\")\n" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": 25, 58 | "metadata": {}, 59 | "outputs": [ 60 | { 61 | "name": "stdout", 62 | "output_type": "stream", 63 | "text": [ 64 | "Database not found or its down try loging into Insta after some time\n", 65 | "division by zero\n", 66 | "Close the connection, from the DB\n" 67 | ] 68 | } 69 | ], 70 | "source": [ 71 | "try:\n", 72 | " 5/0\n", 73 | " print(\"Get the user from the database\")\n", 74 | " print(\"Database found\")\n", 75 | "except Exception as e:\n", 76 | " print(\"Database not found or its down try loging into Insta after some time\")\n", 77 | " print(e)\n", 78 | "finally:\n", 79 | " print(\"Close the connection, from the DB\")" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": 18, 85 | "metadata": {}, 86 | "outputs": [ 87 | { 88 | "name": "stdout", 89 | "output_type": "stream", 90 | "text": [ 91 | "The file gave us error - not writable\n", 92 | "ABC\n" 93 | ] 94 | } 95 | ], 96 | "source": [ 97 | "try:\n", 98 | " file = open(\"FCS.txt\",'r')\n", 99 | " file.write(\"ABC\")\n", 100 | "except Exception as e:\n", 101 | " print(\"The file gave us error - \", e)\n", 102 | " file = open(\"FCS.txt\",'r')\n", 103 | " print(file.read())\n", 104 | "finally:\n", 105 | " file.close()" 106 | ] 107 | }, 108 | { 109 | "cell_type": "code", 110 | "execution_count": 21, 111 | "metadata": {}, 112 | "outputs": [], 113 | "source": [ 114 | "# We dont have any option of our program closing down at any point \n", 115 | "\n", 116 | "# But i am little bit worried about the line of code and think that\n", 117 | "# this may or may not give error \n", 118 | "\n", 119 | "# then what to do ?\n", 120 | "\n", 121 | "# we use Try, Except and Finally " 122 | ] 123 | }, 124 | { 125 | "cell_type": "code", 126 | "execution_count": 22, 127 | "metadata": {}, 128 | "outputs": [], 129 | "source": [ 130 | "#Try except and finally blocks gives us \n", 131 | "# as layer to try differnt code, \n", 132 | "\n", 133 | "# if at all ur try block code explodes or breaks \n", 134 | "\n", 135 | "# you go and handle that in the Except block with a error message to user, \n", 136 | "#not to complier\n", 137 | "\n", 138 | "# Finally block is somehting which makes sure ur \n", 139 | "# code is closing or ending properly\n", 140 | "\n" 141 | ] 142 | }, 143 | { 144 | "cell_type": "markdown", 145 | "metadata": {}, 146 | "source": [ 147 | "# Unit Testing \n" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": 27, 153 | "metadata": {}, 154 | "outputs": [], 155 | "source": [ 156 | "# You make a large programs, \n", 157 | "\n", 158 | "# you want progarm to work properly, with atmost performance \n", 159 | "\n", 160 | "# you wANT THEm to work as designed nothing else \n", 161 | "\n", 162 | "\n", 163 | "# how to go about it ?" 164 | ] 165 | }, 166 | { 167 | "cell_type": "code", 168 | "execution_count": 28, 169 | "metadata": {}, 170 | "outputs": [], 171 | "source": [ 172 | "# Pylint \n", 173 | "\n", 174 | "# Unittest " 175 | ] 176 | }, 177 | { 178 | "cell_type": "code", 179 | "execution_count": null, 180 | "metadata": {}, 181 | "outputs": [], 182 | "source": [] 183 | }, 184 | { 185 | "cell_type": "code", 186 | "execution_count": 31, 187 | "metadata": {}, 188 | "outputs": [ 189 | { 190 | "name": "stdout", 191 | "output_type": "stream", 192 | "text": [ 193 | "Requirement already satisfied: pylint in /opt/anaconda3/lib/python3.7/site-packages (2.4.2)\n", 194 | "Requirement already satisfied: mccabe<0.7,>=0.6 in /opt/anaconda3/lib/python3.7/site-packages (from pylint) (0.6.1)\n", 195 | "Requirement already satisfied: astroid<2.4,>=2.3.0 in /opt/anaconda3/lib/python3.7/site-packages (from pylint) (2.3.1)\n", 196 | "Requirement already satisfied: isort<5,>=4.2.5 in /opt/anaconda3/lib/python3.7/site-packages (from pylint) (4.3.21)\n", 197 | "Requirement already satisfied: six==1.12 in /opt/anaconda3/lib/python3.7/site-packages (from astroid<2.4,>=2.3.0->pylint) (1.12.0)\n", 198 | "Requirement already satisfied: typed-ast<1.5,>=1.4.0; implementation_name == \"cpython\" and python_version < \"3.8\" in /opt/anaconda3/lib/python3.7/site-packages (from astroid<2.4,>=2.3.0->pylint) (1.4.1)\n", 199 | "Requirement already satisfied: wrapt==1.11.* in /opt/anaconda3/lib/python3.7/site-packages (from astroid<2.4,>=2.3.0->pylint) (1.11.2)\n", 200 | "Requirement already satisfied: lazy-object-proxy==1.4.* in /opt/anaconda3/lib/python3.7/site-packages (from astroid<2.4,>=2.3.0->pylint) (1.4.2)\n", 201 | "\u001b[33mWARNING: You are using pip version 20.0.2; however, version 20.1 is available.\n", 202 | "You should consider upgrading via the '/opt/anaconda3/bin/python -m pip install --upgrade pip' command.\u001b[0m\n" 203 | ] 204 | } 205 | ], 206 | "source": [ 207 | "!pip install pylint" 208 | ] 209 | }, 210 | { 211 | "cell_type": "code", 212 | "execution_count": 51, 213 | "metadata": {}, 214 | "outputs": [ 215 | { 216 | "name": "stdout", 217 | "output_type": "stream", 218 | "text": [ 219 | "Overwriting ourPyLitExampleFile.py\n" 220 | ] 221 | } 222 | ], 223 | "source": [ 224 | "%%writefile ourPyLitExampleFile.py\n", 225 | "a = 1\n", 226 | "b = 2\n", 227 | "if a == b:\n", 228 | " print(\"Both are equal\")\n", 229 | "else:\n", 230 | " print(\"Both are UnEqual\")" 231 | ] 232 | }, 233 | { 234 | "cell_type": "code", 235 | "execution_count": 52, 236 | "metadata": {}, 237 | "outputs": [ 238 | { 239 | "name": "stdout", 240 | "output_type": "stream", 241 | "text": [ 242 | "************* Module ourPyLitExampleFile\r\n", 243 | "ourPyLitExampleFile.py:1:0: C0103: Module name \"ourPyLitExampleFile\" doesn't conform to snake_case naming style (invalid-name)\r\n", 244 | "ourPyLitExampleFile.py:1:0: C0114: Missing module docstring (missing-module-docstring)\r\n", 245 | "ourPyLitExampleFile.py:1:0: C0103: Constant name \"a\" doesn't conform to UPPER_CASE naming style (invalid-name)\r\n", 246 | "ourPyLitExampleFile.py:2:0: C0103: Constant name \"b\" doesn't conform to UPPER_CASE naming style (invalid-name)\r\n", 247 | "\r\n", 248 | "------------------------------------------------------------------\r\n", 249 | "Your code has been rated at 2.00/10 (previous run: 6.00/10, -4.00)\r\n", 250 | "\r\n" 251 | ] 252 | } 253 | ], 254 | "source": [ 255 | "! pylint ourPyLitExampleFile.py" 256 | ] 257 | }, 258 | { 259 | "cell_type": "code", 260 | "execution_count": 57, 261 | "metadata": {}, 262 | "outputs": [ 263 | { 264 | "name": "stdout", 265 | "output_type": "stream", 266 | "text": [ 267 | "Overwriting our_file.py\n" 268 | ] 269 | } 270 | ], 271 | "source": [ 272 | "%%writefile our_file.py\n", 273 | "'''\n", 274 | "A Sample Program for testing PyLint\n", 275 | "'''\n", 276 | "A = 1\n", 277 | "B = 2\n", 278 | "if A == B:\n", 279 | " print(\"Both are equal\")\n", 280 | "else:\n", 281 | " print(\"Both are UnEqual\")" 282 | ] 283 | }, 284 | { 285 | "cell_type": "code", 286 | "execution_count": 58, 287 | "metadata": {}, 288 | "outputs": [ 289 | { 290 | "name": "stdout", 291 | "output_type": "stream", 292 | "text": [ 293 | "\r\n", 294 | "--------------------------------------------------------------------\r\n", 295 | "Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)\r\n", 296 | "\r\n" 297 | ] 298 | } 299 | ], 300 | "source": [ 301 | "! pylint our_file.py" 302 | ] 303 | }, 304 | { 305 | "cell_type": "markdown", 306 | "metadata": {}, 307 | "source": [ 308 | "# Unittest Library " 309 | ] 310 | }, 311 | { 312 | "cell_type": "code", 313 | "execution_count": 59, 314 | "metadata": {}, 315 | "outputs": [], 316 | "source": [ 317 | "#u want to add multiple numbers\n", 318 | "\n", 319 | "#if you are sending 2 numbers it should add them both, \n", 320 | "\n", 321 | "#if u are sending multiple numbers its should run a for loop and get he answer\n", 322 | "\n" 323 | ] 324 | }, 325 | { 326 | "cell_type": "code", 327 | "execution_count": 76, 328 | "metadata": {}, 329 | "outputs": [], 330 | "source": [ 331 | "def addNumbers(*args):\n", 332 | " '''\n", 333 | " 1. send two int parameter as for there addition \n", 334 | " 2. Senf a list only with ints to add them all \n", 335 | " '''\n", 336 | " if len(args) == 2:\n", 337 | " return args[0] + args[1]\n", 338 | " elif len(args)>2:\n", 339 | " return \"Refer Doc String\"\n", 340 | " else:\n", 341 | " addNum = 0 \n", 342 | " for item in args[0]:\n", 343 | " addNum = addNum + item\n", 344 | " return addNum\n" 345 | ] 346 | }, 347 | { 348 | "cell_type": "code", 349 | "execution_count": null, 350 | "metadata": {}, 351 | "outputs": [], 352 | "source": [] 353 | }, 354 | { 355 | "cell_type": "code", 356 | "execution_count": 78, 357 | "metadata": {}, 358 | "outputs": [ 359 | { 360 | "data": { 361 | "text/plain": [ 362 | "3" 363 | ] 364 | }, 365 | "execution_count": 78, 366 | "metadata": {}, 367 | "output_type": "execute_result" 368 | } 369 | ], 370 | "source": [ 371 | "addNumbers(1,2)" 372 | ] 373 | }, 374 | { 375 | "cell_type": "code", 376 | "execution_count": 79, 377 | "metadata": {}, 378 | "outputs": [ 379 | { 380 | "data": { 381 | "text/plain": [ 382 | "11850" 383 | ] 384 | }, 385 | "execution_count": 79, 386 | "metadata": {}, 387 | "output_type": "execute_result" 388 | } 389 | ], 390 | "source": [ 391 | "addNumbers([1000,4545,23,6112,24,63,4,32,23,24])" 392 | ] 393 | }, 394 | { 395 | "cell_type": "code", 396 | "execution_count": 80, 397 | "metadata": {}, 398 | "outputs": [ 399 | { 400 | "data": { 401 | "text/plain": [ 402 | "'Refer Doc String'" 403 | ] 404 | }, 405 | "execution_count": 80, 406 | "metadata": {}, 407 | "output_type": "execute_result" 408 | } 409 | ], 410 | "source": [ 411 | "addNumbers(1,2,3)" 412 | ] 413 | }, 414 | { 415 | "cell_type": "code", 416 | "execution_count": 104, 417 | "metadata": {}, 418 | "outputs": [ 419 | { 420 | "name": "stdout", 421 | "output_type": "stream", 422 | "text": [ 423 | "Overwriting adding_Multiplenumbers.py\n" 424 | ] 425 | } 426 | ], 427 | "source": [ 428 | "%%writefile adding_Multiplenumbers.py\n", 429 | "def addNumbers(*args):\n", 430 | " '''\n", 431 | " 1. send two int parameter as for there addition\n", 432 | " 2. Senf a list only with ints to add them all\n", 433 | " '''\n", 434 | " if len(args) == 2:\n", 435 | " return args[0] + args[1]\n", 436 | " elif len(args) > 2:\n", 437 | " return \"Refer to doc string\"\n", 438 | " else:\n", 439 | " addNum = 0\n", 440 | " for item in args[0]:\n", 441 | " addNum = addNum + item\n", 442 | " return addNum" 443 | ] 444 | }, 445 | { 446 | "cell_type": "code", 447 | "execution_count": 92, 448 | "metadata": {}, 449 | "outputs": [ 450 | { 451 | "name": "stdout", 452 | "output_type": "stream", 453 | "text": [ 454 | "************* Module adding_Multiplenumbers\r\n", 455 | "adding_Multiplenumbers.py:1:0: C0103: Module name \"adding_Multiplenumbers\" doesn't conform to snake_case naming style (invalid-name)\r\n", 456 | "adding_Multiplenumbers.py:1:0: C0114: Missing module docstring (missing-module-docstring)\r\n", 457 | "adding_Multiplenumbers.py:1:0: C0103: Function name \"addNumbers\" doesn't conform to snake_case naming style (invalid-name)\r\n", 458 | "adding_Multiplenumbers.py:6:4: R1705: Unnecessary \"elif\" after \"return\" (no-else-return)\r\n", 459 | "adding_Multiplenumbers.py:11:8: C0103: Variable name \"addNum\" doesn't conform to snake_case naming style (invalid-name)\r\n", 460 | "adding_Multiplenumbers.py:13:12: C0103: Variable name \"addNum\" doesn't conform to snake_case naming style (invalid-name)\r\n", 461 | "\r\n", 462 | "------------------------------------------------------------------\r\n", 463 | "Your code has been rated at 3.33/10 (previous run: 1.11/10, +2.22)\r\n", 464 | "\r\n" 465 | ] 466 | } 467 | ], 468 | "source": [ 469 | "! pylint adding_Multiplenumbers.py" 470 | ] 471 | }, 472 | { 473 | "cell_type": "code", 474 | "execution_count": 114, 475 | "metadata": {}, 476 | "outputs": [ 477 | { 478 | "name": "stdout", 479 | "output_type": "stream", 480 | "text": [ 481 | "Overwriting unittestof_Twonumbers.py\n" 482 | ] 483 | } 484 | ], 485 | "source": [ 486 | "%%writefile unittestof_Twonumbers.py\n", 487 | "import unittest\n", 488 | "import adding_Multiplenumbers\n", 489 | "\n", 490 | "class TestAddition(unittest.TestCase):\n", 491 | " \n", 492 | " def test_two_numbers(self):\n", 493 | " A = 1\n", 494 | " B = 2\n", 495 | " result = adding_Multiplenumbers.addNumbers(A,B)\n", 496 | " self.assertEqual(result,3)\n", 497 | " \n", 498 | " def test_multiple_numbers(self):\n", 499 | " list_of_Numbers = list(range(1,200))\n", 500 | " result = adding_Multiplenumbers.addNumbers(list_of_Numbers)\n", 501 | " self.assertEqual(result,19900)\n", 502 | " \n", 503 | " def test_three_args(self):\n", 504 | " A= 1\n", 505 | " B= 2\n", 506 | " C= 3\n", 507 | " result = adding_Multiplenumbers.addNumbers(A,B,C)\n", 508 | " self.assertEqual(result,\"Refer to doc string\")\n", 509 | " \n", 510 | " \n", 511 | "if __name__ == '__main__':\n", 512 | " unittest.main()" 513 | ] 514 | }, 515 | { 516 | "cell_type": "code", 517 | "execution_count": 115, 518 | "metadata": {}, 519 | "outputs": [ 520 | { 521 | "name": "stdout", 522 | "output_type": "stream", 523 | "text": [ 524 | "...\r\n", 525 | "----------------------------------------------------------------------\r\n", 526 | "Ran 3 tests in 0.000s\r\n", 527 | "\r\n", 528 | "OK\r\n" 529 | ] 530 | } 531 | ], 532 | "source": [ 533 | "! python unittestof_Twonumbers.py" 534 | ] 535 | }, 536 | { 537 | "cell_type": "code", 538 | "execution_count": 97, 539 | "metadata": {}, 540 | "outputs": [], 541 | "source": [ 542 | "#if __name__ == '__main__':\n", 543 | "# unittest.main()" 544 | ] 545 | }, 546 | { 547 | "cell_type": "code", 548 | "execution_count": null, 549 | "metadata": {}, 550 | "outputs": [], 551 | "source": [] 552 | }, 553 | { 554 | "cell_type": "code", 555 | "execution_count": null, 556 | "metadata": {}, 557 | "outputs": [], 558 | "source": [] 559 | }, 560 | { 561 | "cell_type": "code", 562 | "execution_count": null, 563 | "metadata": {}, 564 | "outputs": [], 565 | "source": [] 566 | } 567 | ], 568 | "metadata": { 569 | "kernelspec": { 570 | "display_name": "Python 3", 571 | "language": "python", 572 | "name": "python3" 573 | }, 574 | "language_info": { 575 | "codemirror_mode": { 576 | "name": "ipython", 577 | "version": 3 578 | }, 579 | "file_extension": ".py", 580 | "mimetype": "text/x-python", 581 | "name": "python", 582 | "nbconvert_exporter": "python", 583 | "pygments_lexer": "ipython3", 584 | "version": "3.7.4" 585 | } 586 | }, 587 | "nbformat": 4, 588 | "nbformat_minor": 2 589 | } 590 | -------------------------------------------------------------------------------- /Batch-3/Day-7/Assignment Day 7.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-3/Day-7/Assignment Day 7.pdf -------------------------------------------------------------------------------- /Batch-3/Day-7/Day 7 Assignment Solution .ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "# fibonacci Series ?\n", 10 | "\n", 11 | "\n", 12 | "#1 1 2 3 5 8 13 21 ...." 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 14, 18 | "metadata": {}, 19 | "outputs": [ 20 | { 21 | "name": "stdout", 22 | "output_type": "stream", 23 | "text": [ 24 | "1\n", 25 | "1\n", 26 | "2\n", 27 | "3\n", 28 | "5\n", 29 | "8\n", 30 | "13\n", 31 | "21\n", 32 | "34\n", 33 | "55\n", 34 | "89\n" 35 | ] 36 | } 37 | ], 38 | "source": [ 39 | "oldnumber = 0\n", 40 | "previousNumber = 1\n", 41 | "print('1')\n", 42 | "for i in range(0,10):\n", 43 | " newNumber = previousNumber +oldnumber\n", 44 | " oldnumber = previousNumber\n", 45 | " previousNumber = newNumber\n", 46 | " print(newNumber)" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": 19, 52 | "metadata": {}, 53 | "outputs": [], 54 | "source": [ 55 | "def fibonacciSe(n):\n", 56 | " oldnumber = 0\n", 57 | " previousNumber = 1\n", 58 | " print('1')\n", 59 | " for i in range(0,n):\n", 60 | " newNumber = previousNumber +oldnumber\n", 61 | " oldnumber = previousNumber\n", 62 | " previousNumber = newNumber\n", 63 | " print(newNumber)" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 21, 69 | "metadata": {}, 70 | "outputs": [ 71 | { 72 | "name": "stdout", 73 | "output_type": "stream", 74 | "text": [ 75 | "1\n", 76 | "1\n", 77 | "2\n", 78 | "3\n", 79 | "5\n", 80 | "8\n", 81 | "13\n", 82 | "21\n", 83 | "34\n", 84 | "55\n", 85 | "89\n" 86 | ] 87 | } 88 | ], 89 | "source": [ 90 | "fibonacciSe(10)" 91 | ] 92 | }, 93 | { 94 | "cell_type": "code", 95 | "execution_count": 22, 96 | "metadata": {}, 97 | "outputs": [], 98 | "source": [ 99 | "# Decorator for the Function -- \n", 100 | "\n", 101 | "def inputDecoFun(argFun):\n", 102 | " \n", 103 | " def newFun():\n", 104 | " num = int(input(\"Enter any Number - \"))\n", 105 | " argFun(num)\n", 106 | " return newFun\n", 107 | " " 108 | ] 109 | }, 110 | { 111 | "cell_type": "code", 112 | "execution_count": 23, 113 | "metadata": {}, 114 | "outputs": [], 115 | "source": [ 116 | "@inputDecoFun\n", 117 | "def fibonacciSe(n):\n", 118 | " oldnumber = 0\n", 119 | " previousNumber = 1\n", 120 | " print('1')\n", 121 | " for i in range(0,n):\n", 122 | " newNumber = previousNumber +oldnumber\n", 123 | " oldnumber = previousNumber\n", 124 | " previousNumber = newNumber\n", 125 | " print(newNumber)" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": 24, 131 | "metadata": {}, 132 | "outputs": [ 133 | { 134 | "name": "stdout", 135 | "output_type": "stream", 136 | "text": [ 137 | "Enter any Number - 45\n", 138 | "1\n", 139 | "1\n", 140 | "2\n", 141 | "3\n", 142 | "5\n", 143 | "8\n", 144 | "13\n", 145 | "21\n", 146 | "34\n", 147 | "55\n", 148 | "89\n", 149 | "144\n", 150 | "233\n", 151 | "377\n", 152 | "610\n", 153 | "987\n", 154 | "1597\n", 155 | "2584\n", 156 | "4181\n", 157 | "6765\n", 158 | "10946\n", 159 | "17711\n", 160 | "28657\n", 161 | "46368\n", 162 | "75025\n", 163 | "121393\n", 164 | "196418\n", 165 | "317811\n", 166 | "514229\n", 167 | "832040\n", 168 | "1346269\n", 169 | "2178309\n", 170 | "3524578\n", 171 | "5702887\n", 172 | "9227465\n", 173 | "14930352\n", 174 | "24157817\n", 175 | "39088169\n", 176 | "63245986\n", 177 | "102334155\n", 178 | "165580141\n", 179 | "267914296\n", 180 | "433494437\n", 181 | "701408733\n", 182 | "1134903170\n", 183 | "1836311903\n" 184 | ] 185 | } 186 | ], 187 | "source": [ 188 | "fibonacciSe()" 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": null, 194 | "metadata": {}, 195 | "outputs": [], 196 | "source": [] 197 | } 198 | ], 199 | "metadata": { 200 | "kernelspec": { 201 | "display_name": "Python 3", 202 | "language": "python", 203 | "name": "python3" 204 | }, 205 | "language_info": { 206 | "codemirror_mode": { 207 | "name": "ipython", 208 | "version": 3 209 | }, 210 | "file_extension": ".py", 211 | "mimetype": "text/x-python", 212 | "name": "python", 213 | "nbconvert_exporter": "python", 214 | "pygments_lexer": "ipython3", 215 | "version": "3.7.4" 216 | } 217 | }, 218 | "nbformat": 4, 219 | "nbformat_minor": 2 220 | } 221 | -------------------------------------------------------------------------------- /Batch-3/Day-8/Assignment Day 8 (optional).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-3/Day-8/Assignment Day 8 (optional).pdf -------------------------------------------------------------------------------- /Batch-3/Optional Assignment - 7 May 2020/Optional Assignment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-3/Optional Assignment - 7 May 2020/Optional Assignment.pdf -------------------------------------------------------------------------------- /Batch-3/Silver Project - Tic Tac Toe/TIC TAC TOE Solution .ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from IPython.display import clear_output\n", 10 | "\n", 11 | "def display_board(board):\n", 12 | " clear_output()\n", 13 | " print(' '+board[7]+' | '+board[8]+' | '+board[9]+' ')\n", 14 | " print('---------')\n", 15 | " print(' '+board[4]+' | '+board[5]+' | '+board[6]+' ')\n", 16 | " print('---------')\n", 17 | " print(' '+board[1]+' | '+board[2]+' | '+board[3]+' ')\n", 18 | " " 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": null, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "execution_count": 2, 31 | "metadata": {}, 32 | "outputs": [], 33 | "source": [ 34 | "board = ['#','X','O','X','O','X','O','X','O','X','O']" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": 3, 40 | "metadata": {}, 41 | "outputs": [ 42 | { 43 | "name": "stdout", 44 | "output_type": "stream", 45 | "text": [ 46 | " X | O | X \n", 47 | "---------\n", 48 | " O | X | O \n", 49 | "---------\n", 50 | " X | O | X \n" 51 | ] 52 | } 53 | ], 54 | "source": [ 55 | "display_board(board)" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": 4, 61 | "metadata": {}, 62 | "outputs": [], 63 | "source": [ 64 | "def player_input():\n", 65 | " marker = ''\n", 66 | " \n", 67 | " while not (marker == 'X' or marker == \"O\"):\n", 68 | " marker = input(\"Enter a Marker X/O for player one : \").upper()\n", 69 | " \n", 70 | " if marker == 'X':\n", 71 | " return ('X','O')\n", 72 | " else:\n", 73 | " return ('O','X')\n" 74 | ] 75 | }, 76 | { 77 | "cell_type": "code", 78 | "execution_count": 5, 79 | "metadata": {}, 80 | "outputs": [ 81 | { 82 | "name": "stdout", 83 | "output_type": "stream", 84 | "text": [ 85 | "Enter a Marker X/O for player one : \n", 86 | "Enter a Marker X/O for player one : \n", 87 | "Enter a Marker X/O for player one : \n", 88 | "Enter a Marker X/O for player one : 1\n", 89 | "Enter a Marker X/O for player one : x\n" 90 | ] 91 | }, 92 | { 93 | "data": { 94 | "text/plain": [ 95 | "('X', 'O')" 96 | ] 97 | }, 98 | "execution_count": 5, 99 | "metadata": {}, 100 | "output_type": "execute_result" 101 | } 102 | ], 103 | "source": [ 104 | "player_input()" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": 7, 110 | "metadata": {}, 111 | "outputs": [], 112 | "source": [ 113 | "def place_marker(board,marker,position):\n", 114 | " board[position] = marker" 115 | ] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "execution_count": 8, 120 | "metadata": {}, 121 | "outputs": [], 122 | "source": [ 123 | "place_marker(board,\"X\",5)" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": 9, 129 | "metadata": {}, 130 | "outputs": [ 131 | { 132 | "name": "stdout", 133 | "output_type": "stream", 134 | "text": [ 135 | " X | O | X \n", 136 | "---------\n", 137 | " O | X | O \n", 138 | "---------\n", 139 | " X | O | X \n" 140 | ] 141 | } 142 | ], 143 | "source": [ 144 | "display_board(board)" 145 | ] 146 | }, 147 | { 148 | "cell_type": "code", 149 | "execution_count": 10, 150 | "metadata": {}, 151 | "outputs": [], 152 | "source": [ 153 | "def win_check(board,marker):\n", 154 | " \n", 155 | " if( (board[7]==marker and board[8]==marker and board[9]==marker) or\n", 156 | " (board[4]==marker and board[5]==marker and board[6]==marker) or\n", 157 | " (board[1]==marker and board[2]==marker and board[3]==marker) or\n", 158 | " (board[7]==marker and board[4]==marker and board[1]==marker) or\n", 159 | " (board[8]==marker and board[5]==marker and board[2]==marker) or\n", 160 | " (board[9]==marker and board[6]==marker and board[3]==marker) or\n", 161 | " (board[7]==marker and board[5]==marker and board[3]==marker) or\n", 162 | " (board[9]==marker and board[5]==marker and board[1]==marker)):\n", 163 | " return True\n", 164 | " else:\n", 165 | " return False" 166 | ] 167 | }, 168 | { 169 | "cell_type": "code", 170 | "execution_count": 11, 171 | "metadata": {}, 172 | "outputs": [ 173 | { 174 | "data": { 175 | "text/plain": [ 176 | "True" 177 | ] 178 | }, 179 | "execution_count": 11, 180 | "metadata": {}, 181 | "output_type": "execute_result" 182 | } 183 | ], 184 | "source": [ 185 | "win_check(board,'X')" 186 | ] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": 12, 191 | "metadata": {}, 192 | "outputs": [ 193 | { 194 | "data": { 195 | "text/plain": [ 196 | "False" 197 | ] 198 | }, 199 | "execution_count": 12, 200 | "metadata": {}, 201 | "output_type": "execute_result" 202 | } 203 | ], 204 | "source": [ 205 | "win_check(board,'O')" 206 | ] 207 | }, 208 | { 209 | "cell_type": "code", 210 | "execution_count": 13, 211 | "metadata": {}, 212 | "outputs": [], 213 | "source": [ 214 | "import random \n", 215 | "\n", 216 | "def choose_first():\n", 217 | " num = random.randint(0,1)\n", 218 | " \n", 219 | " if num == 1:\n", 220 | " return 'Player 1'\n", 221 | " else:\n", 222 | " return 'Player 2'" 223 | ] 224 | }, 225 | { 226 | "cell_type": "code", 227 | "execution_count": 14, 228 | "metadata": {}, 229 | "outputs": [ 230 | { 231 | "data": { 232 | "text/plain": [ 233 | "'Player 1'" 234 | ] 235 | }, 236 | "execution_count": 14, 237 | "metadata": {}, 238 | "output_type": "execute_result" 239 | } 240 | ], 241 | "source": [ 242 | "choose_first()" 243 | ] 244 | }, 245 | { 246 | "cell_type": "code", 247 | "execution_count": 15, 248 | "metadata": {}, 249 | "outputs": [], 250 | "source": [ 251 | "board = ['#','X',' ',' ','O','X',' ','X',' ','X','O']" 252 | ] 253 | }, 254 | { 255 | "cell_type": "code", 256 | "execution_count": 16, 257 | "metadata": {}, 258 | "outputs": [], 259 | "source": [ 260 | "def space_check(board,position):\n", 261 | " return board[position] == ' '" 262 | ] 263 | }, 264 | { 265 | "cell_type": "code", 266 | "execution_count": 17, 267 | "metadata": {}, 268 | "outputs": [ 269 | { 270 | "data": { 271 | "text/plain": [ 272 | "True" 273 | ] 274 | }, 275 | "execution_count": 17, 276 | "metadata": {}, 277 | "output_type": "execute_result" 278 | } 279 | ], 280 | "source": [ 281 | "space_check(board,6)" 282 | ] 283 | }, 284 | { 285 | "cell_type": "code", 286 | "execution_count": 18, 287 | "metadata": {}, 288 | "outputs": [], 289 | "source": [ 290 | "def full_board_check(board):\n", 291 | " isFull = True\n", 292 | " for i in board:\n", 293 | " if i == ' ':\n", 294 | " isFull = False\n", 295 | " return isFull\n", 296 | " " 297 | ] 298 | }, 299 | { 300 | "cell_type": "code", 301 | "execution_count": 19, 302 | "metadata": {}, 303 | "outputs": [ 304 | { 305 | "data": { 306 | "text/plain": [ 307 | "False" 308 | ] 309 | }, 310 | "execution_count": 19, 311 | "metadata": {}, 312 | "output_type": "execute_result" 313 | } 314 | ], 315 | "source": [ 316 | "full_board_check(board)" 317 | ] 318 | }, 319 | { 320 | "cell_type": "code", 321 | "execution_count": 20, 322 | "metadata": {}, 323 | "outputs": [], 324 | "source": [ 325 | "def full_board_check(board):\n", 326 | " for i in range(1,10):\n", 327 | " if space_check(board,i):\n", 328 | " return False\n", 329 | " return True" 330 | ] 331 | }, 332 | { 333 | "cell_type": "code", 334 | "execution_count": 21, 335 | "metadata": {}, 336 | "outputs": [ 337 | { 338 | "data": { 339 | "text/plain": [ 340 | "False" 341 | ] 342 | }, 343 | "execution_count": 21, 344 | "metadata": {}, 345 | "output_type": "execute_result" 346 | } 347 | ], 348 | "source": [ 349 | "full_board_check(board)" 350 | ] 351 | }, 352 | { 353 | "cell_type": "code", 354 | "execution_count": 22, 355 | "metadata": {}, 356 | "outputs": [], 357 | "source": [ 358 | "def players_choice(board):\n", 359 | " position = 0\n", 360 | " \n", 361 | " while not position in [1,2,3,4,5,6,7,8,9] or not space_check(board,position) : \n", 362 | " position = int(input(\"Enter your next position : \"))\n", 363 | " \n", 364 | " return position" 365 | ] 366 | }, 367 | { 368 | "cell_type": "code", 369 | "execution_count": 23, 370 | "metadata": {}, 371 | "outputs": [ 372 | { 373 | "name": "stdout", 374 | "output_type": "stream", 375 | "text": [ 376 | "Enter your next position : 4\n", 377 | "Enter your next position : 3\n" 378 | ] 379 | }, 380 | { 381 | "data": { 382 | "text/plain": [ 383 | "3" 384 | ] 385 | }, 386 | "execution_count": 23, 387 | "metadata": {}, 388 | "output_type": "execute_result" 389 | } 390 | ], 391 | "source": [ 392 | "players_choice(board)" 393 | ] 394 | }, 395 | { 396 | "cell_type": "code", 397 | "execution_count": 24, 398 | "metadata": {}, 399 | "outputs": [], 400 | "source": [ 401 | "def replay():\n", 402 | " return input(\"Do you want to play again (Y/N) : \").lower().startswith('y')" 403 | ] 404 | }, 405 | { 406 | "cell_type": "code", 407 | "execution_count": 25, 408 | "metadata": {}, 409 | "outputs": [ 410 | { 411 | "name": "stdout", 412 | "output_type": "stream", 413 | "text": [ 414 | "Do you want to play again (Y/N) : y\n" 415 | ] 416 | }, 417 | { 418 | "data": { 419 | "text/plain": [ 420 | "True" 421 | ] 422 | }, 423 | "execution_count": 25, 424 | "metadata": {}, 425 | "output_type": "execute_result" 426 | } 427 | ], 428 | "source": [ 429 | "replay()" 430 | ] 431 | }, 432 | { 433 | "cell_type": "code", 434 | "execution_count": 27, 435 | "metadata": {}, 436 | "outputs": [ 437 | { 438 | "name": "stdout", 439 | "output_type": "stream", 440 | "text": [ 441 | " O | | \n", 442 | "---------\n", 443 | " | O | \n", 444 | "---------\n", 445 | " X | X | O \n", 446 | "Player 2 Won the game!! congratzz\n", 447 | "Do you want to play again (Y/N) : n\n" 448 | ] 449 | } 450 | ], 451 | "source": [ 452 | "# Here Comes the final Assembly of the game \n", 453 | "\n", 454 | "\n", 455 | "while True:\n", 456 | " \n", 457 | " board = [' ']* 10\n", 458 | " \n", 459 | " \n", 460 | " player1_marker, player2_marker = player_input()\n", 461 | " turn = choose_first()\n", 462 | " \n", 463 | " print(turn + \" Will play First\")\n", 464 | " \n", 465 | " play_game = input(\"Are you ready to play the game Y/N\").lower().startswith('y')\n", 466 | " \n", 467 | " if play_game:\n", 468 | " game_on = True\n", 469 | " else:\n", 470 | " game_on = False\n", 471 | " \n", 472 | " while game_on:\n", 473 | " if turn == 'Player 1':\n", 474 | " # Game logic starts here for player 1 \n", 475 | " \n", 476 | " display_board(board)\n", 477 | " position = players_choice(board)\n", 478 | " place_marker(board,player1_marker,position)\n", 479 | " \n", 480 | " if win_check(board,player1_marker):\n", 481 | " display_board(board)\n", 482 | " print(\"Player 1 Won the game!! congratzz\")\n", 483 | " game_on = False\n", 484 | " else:\n", 485 | " if full_board_check(board):\n", 486 | " display_board(board)\n", 487 | " print('The Game is Draw, Better luck next time !!')\n", 488 | " break\n", 489 | " else:\n", 490 | " turn = \"Player 2\"\n", 491 | " else:\n", 492 | " # Player 2 Logic \n", 493 | " \n", 494 | " display_board(board)\n", 495 | " position = players_choice(board)\n", 496 | " place_marker(board,player2_marker,position)\n", 497 | " \n", 498 | " if win_check(board,player2_marker):\n", 499 | " display_board(board)\n", 500 | " print(\"Player 2 Won the game!! congratzz\")\n", 501 | " game_on = False\n", 502 | " else:\n", 503 | " if full_board_check(board):\n", 504 | " display_board(board)\n", 505 | " print('The Game is Draw, Better luck next time !!')\n", 506 | " break\n", 507 | " else:\n", 508 | " turn = \"Player 1\"\n", 509 | " \n", 510 | " if not replay():\n", 511 | " break " 512 | ] 513 | }, 514 | { 515 | "cell_type": "code", 516 | "execution_count": null, 517 | "metadata": {}, 518 | "outputs": [], 519 | "source": [] 520 | } 521 | ], 522 | "metadata": { 523 | "kernelspec": { 524 | "display_name": "Python 3", 525 | "language": "python", 526 | "name": "python3" 527 | }, 528 | "language_info": { 529 | "codemirror_mode": { 530 | "name": "ipython", 531 | "version": 3 532 | }, 533 | "file_extension": ".py", 534 | "mimetype": "text/x-python", 535 | "name": "python", 536 | "nbconvert_exporter": "python", 537 | "pygments_lexer": "ipython3", 538 | "version": "3.7.6" 539 | } 540 | }, 541 | "nbformat": 4, 542 | "nbformat_minor": 2 543 | } 544 | -------------------------------------------------------------------------------- /Batch-4/Day 2/Assignment Day 2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-4/Day 2/Assignment Day 2.pdf -------------------------------------------------------------------------------- /Batch-4/Day 3/Assignment Day 3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-4/Day 3/Assignment Day 3.pdf -------------------------------------------------------------------------------- /Batch-4/Day-4/Assignment Day 4 .ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 9, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "#Function for caluclator for +,-,*,/ \n", 10 | "\n", 11 | "def calculator(num1,num2,op):\n", 12 | " if op == \"+\":\n", 13 | " return num1 +num2\n", 14 | " elif op == \"-\":\n", 15 | " return num1 -num2 \n", 16 | " elif op == \"*\":\n", 17 | " return num1 * num2\n", 18 | " elif op == \"/\":\n", 19 | " return num1 / num2\n", 20 | " else:\n", 21 | " return \"Give proper Operand, +, - , *, /\"" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": 10, 27 | "metadata": {}, 28 | "outputs": [ 29 | { 30 | "data": { 31 | "text/plain": [ 32 | "32" 33 | ] 34 | }, 35 | "execution_count": 10, 36 | "metadata": {}, 37 | "output_type": "execute_result" 38 | } 39 | ], 40 | "source": [ 41 | "calculator(45,13,'-')" 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "execution_count": 11, 47 | "metadata": {}, 48 | "outputs": [ 49 | { 50 | "data": { 51 | "text/plain": [ 52 | "'Give proper Operand, +, - , *, /'" 53 | ] 54 | }, 55 | "execution_count": 11, 56 | "metadata": {}, 57 | "output_type": "execute_result" 58 | } 59 | ], 60 | "source": [ 61 | "calculator(45,13,'k')" 62 | ] 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "metadata": {}, 67 | "source": [ 68 | "# Assignment number 1 \n", 69 | "\n", 70 | "Write a program to identify sub list [1,1,5] is there in the given list in the same order, if yes print “it's a Match” if no then print “it's Gone” in function\n", 71 | "\n", 72 | "Example - \n", 73 | "Listy = [1,5,6,4,1,2,3,5] - it's a Match\n", 74 | "Listy = [1,5,6,5,1,2,3,6] - it's Gone" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": 17, 80 | "metadata": {}, 81 | "outputs": [ 82 | { 83 | "name": "stdout", 84 | "output_type": "stream", 85 | "text": [ 86 | " it's Gone \n" 87 | ] 88 | } 89 | ], 90 | "source": [ 91 | "listy = [1,5,6,4,1,2,3]\n", 92 | "\n", 93 | "sub_list = [1,1,5]\n", 94 | "\n", 95 | "\n", 96 | "for item in listy:\n", 97 | " if item == sub_list[0]:\n", 98 | " sub_list.pop(0)\n", 99 | " \n", 100 | "if len(sub_list) == 0:\n", 101 | " print(\" it's a Match \")\n", 102 | "else:\n", 103 | " print(\" it's Gone \")" 104 | ] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "execution_count": null, 109 | "metadata": {}, 110 | "outputs": [], 111 | "source": [] 112 | }, 113 | { 114 | "cell_type": "code", 115 | "execution_count": null, 116 | "metadata": {}, 117 | "outputs": [], 118 | "source": [] 119 | } 120 | ], 121 | "metadata": { 122 | "kernelspec": { 123 | "display_name": "Python 3", 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.7.4" 138 | } 139 | }, 140 | "nbformat": 4, 141 | "nbformat_minor": 2 142 | } 143 | -------------------------------------------------------------------------------- /Batch-4/Day-4/Assignment Day 4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-4/Day-4/Assignment Day 4.pdf -------------------------------------------------------------------------------- /Batch-4/Day-5/Assignment Day 5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-4/Day-5/Assignment Day 5.pdf -------------------------------------------------------------------------------- /Batch-4/Day-5/Day 5 Notes.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# File Handling ?\n", 8 | "\n", 9 | "File handling is nothing but simple handling, storing, reading and wirting of content or valuable data into files, and group of files are knows as folders " 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 1, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "# Create a New File\n", 19 | "\n", 20 | "file = open(\"Shivanshu.txt\",\"w\")\n", 21 | "\n", 22 | "file.write(\"Hi Shivanshu what happenend ?\")\n", 23 | "\n", 24 | "file.close()\n", 25 | "\n" 26 | ] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "execution_count": 10, 31 | "metadata": {}, 32 | "outputs": [ 33 | { 34 | "name": "stdout", 35 | "output_type": "stream", 36 | "text": [ 37 | "Hi Shivanshu what happenend ?I think he is not here right, but whatever problem it is let us know\n", 38 | "\n", 39 | "I think he is not here right, but whatever problem it is let us know\n", 40 | "\n", 41 | "I think he is not here right, but whatever problem it is let us know\n" 42 | ] 43 | } 44 | ], 45 | "source": [ 46 | "# Read this file \n", 47 | "\n", 48 | "file = open(\"Shivanshu.txt\",'r')\n", 49 | "\n", 50 | "text = file.read()\n", 51 | "\n", 52 | "print(text)\n", 53 | "\n", 54 | "file.close()" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": 11, 60 | "metadata": {}, 61 | "outputs": [], 62 | "source": [ 63 | "# Add something more to this file -- \n", 64 | "\n", 65 | "file = open(\"Shivanshu.txt\",\"a\")\n", 66 | "\n", 67 | "file.write(\"\\n\\nI think he is not here right, but whatever problem it is let us know\")\n", 68 | "\n", 69 | "file.close()" 70 | ] 71 | }, 72 | { 73 | "cell_type": "code", 74 | "execution_count": 12, 75 | "metadata": {}, 76 | "outputs": [ 77 | { 78 | "name": "stdout", 79 | "output_type": "stream", 80 | "text": [ 81 | "Hi Shivanshu what happenend ?I think he is not here right, but whatever problem it is let us know\n", 82 | "\n", 83 | "I think he is not here right, but whatever problem it is let us know\n", 84 | "\n", 85 | "I think he is not here right, but whatever problem it is let us know\n", 86 | "\n", 87 | "I think he is not here right, but whatever problem it is let us know\n" 88 | ] 89 | } 90 | ], 91 | "source": [ 92 | "file = open(\"Shivanshu.txt\",'r')\n", 93 | "\n", 94 | "print(file.read())\n", 95 | "\n", 96 | "file.close()" 97 | ] 98 | }, 99 | { 100 | "cell_type": "markdown", 101 | "metadata": {}, 102 | "source": [ 103 | "When ever u want to get the path of the place where u r working do pwd()" 104 | ] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "execution_count": 18, 109 | "metadata": {}, 110 | "outputs": [ 111 | { 112 | "data": { 113 | "text/plain": [ 114 | "'/Users/nvrsettle/LU B4 - Python'" 115 | ] 116 | }, 117 | "execution_count": 18, 118 | "metadata": {}, 119 | "output_type": "execute_result" 120 | } 121 | ], 122 | "source": [ 123 | "pwd()" 124 | ] 125 | }, 126 | { 127 | "cell_type": "markdown", 128 | "metadata": {}, 129 | "source": [ 130 | "# MAP, FILTER AND LAMBDA EXP. " 131 | ] 132 | }, 133 | { 134 | "cell_type": "code", 135 | "execution_count": 32, 136 | "metadata": {}, 137 | "outputs": [], 138 | "source": [ 139 | "#You want to get a cube of numbers which are \n", 140 | "#in a list and store them in another list" 141 | ] 142 | }, 143 | { 144 | "cell_type": "code", 145 | "execution_count": 29, 146 | "metadata": {}, 147 | "outputs": [], 148 | "source": [ 149 | "def cube(i):\n", 150 | " return i* i * i" 151 | ] 152 | }, 153 | { 154 | "cell_type": "code", 155 | "execution_count": 30, 156 | "metadata": {}, 157 | "outputs": [], 158 | "source": [ 159 | "lst= [1,2,3,4,5,6,7,8]\n", 160 | "#method 1 \n", 161 | "lst_cube = []\n", 162 | "for i in lst :\n", 163 | " lst_cube.append(cube(i))" 164 | ] 165 | }, 166 | { 167 | "cell_type": "code", 168 | "execution_count": 31, 169 | "metadata": {}, 170 | "outputs": [ 171 | { 172 | "name": "stdout", 173 | "output_type": "stream", 174 | "text": [ 175 | "[1, 2, 3, 4, 5, 6, 7, 8]\n", 176 | "[1, 8, 27, 64, 125, 216, 343, 512]\n" 177 | ] 178 | } 179 | ], 180 | "source": [ 181 | "print(lst)\n", 182 | "print(lst_cube)" 183 | ] 184 | }, 185 | { 186 | "cell_type": "code", 187 | "execution_count": 33, 188 | "metadata": {}, 189 | "outputs": [], 190 | "source": [ 191 | "#method 2\n", 192 | "lst_new = map(cube,lst)" 193 | ] 194 | }, 195 | { 196 | "cell_type": "code", 197 | "execution_count": 35, 198 | "metadata": {}, 199 | "outputs": [ 200 | { 201 | "data": { 202 | "text/plain": [ 203 | "[1, 8, 27, 64, 125, 216, 343, 512]" 204 | ] 205 | }, 206 | "execution_count": 35, 207 | "metadata": {}, 208 | "output_type": "execute_result" 209 | } 210 | ], 211 | "source": [ 212 | "list(lst_new)" 213 | ] 214 | }, 215 | { 216 | "cell_type": "markdown", 217 | "metadata": {}, 218 | "source": [ 219 | "\n", 220 | "# Filter -- " 221 | ] 222 | }, 223 | { 224 | "cell_type": "code", 225 | "execution_count": 48, 226 | "metadata": {}, 227 | "outputs": [], 228 | "source": [ 229 | "# I want to write a program in which numbers are stored in list \n", 230 | "# and want to get only Odd Numbers out of the list and store \n", 231 | "# it is another list " 232 | ] 233 | }, 234 | { 235 | "cell_type": "code", 236 | "execution_count": 90, 237 | "metadata": {}, 238 | "outputs": [ 239 | { 240 | "name": "stdout", 241 | "output_type": "stream", 242 | "text": [ 243 | "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 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, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]\n" 244 | ] 245 | } 246 | ], 247 | "source": [ 248 | "flst = list(range(1,101))\n", 249 | "print(flst)" 250 | ] 251 | }, 252 | { 253 | "cell_type": "code", 254 | "execution_count": 42, 255 | "metadata": {}, 256 | "outputs": [], 257 | "source": [ 258 | "def isOdd(num):\n", 259 | " return num %2 != 0 " 260 | ] 261 | }, 262 | { 263 | "cell_type": "code", 264 | "execution_count": 47, 265 | "metadata": {}, 266 | "outputs": [ 267 | { 268 | "data": { 269 | "text/plain": [ 270 | "False" 271 | ] 272 | }, 273 | "execution_count": 47, 274 | "metadata": {}, 275 | "output_type": "execute_result" 276 | } 277 | ], 278 | "source": [ 279 | "isOdd(8)" 280 | ] 281 | }, 282 | { 283 | "cell_type": "code", 284 | "execution_count": 50, 285 | "metadata": {}, 286 | "outputs": [], 287 | "source": [ 288 | "# method 1 \n", 289 | "\n", 290 | "flst_1 = []\n", 291 | "\n", 292 | "for i in flst:\n", 293 | " if isOdd(i):\n", 294 | " flst_1.append(i)" 295 | ] 296 | }, 297 | { 298 | "cell_type": "code", 299 | "execution_count": 57, 300 | "metadata": {}, 301 | "outputs": [], 302 | "source": [ 303 | "# Method 2 \n", 304 | "\n", 305 | "flst_2 = filter(isOdd,flst)" 306 | ] 307 | }, 308 | { 309 | "cell_type": "code", 310 | "execution_count": null, 311 | "metadata": {}, 312 | "outputs": [], 313 | "source": [ 314 | "list(flst_2)" 315 | ] 316 | }, 317 | { 318 | "cell_type": "markdown", 319 | "metadata": {}, 320 | "source": [ 321 | "# Lambda EXP. " 322 | ] 323 | }, 324 | { 325 | "cell_type": "markdown", 326 | "metadata": {}, 327 | "source": [ 328 | "Lambda Expressions are small tiny function which can be used for replacing on liner function, like which performs very small peice of code and get us the ans in return\n", 329 | "\n", 330 | "thats were we use Lambda Exp. they are also know as inline function. " 331 | ] 332 | }, 333 | { 334 | "cell_type": "code", 335 | "execution_count": 62, 336 | "metadata": {}, 337 | "outputs": [], 338 | "source": [ 339 | "def getPowerFive(num):\n", 340 | " return num **5" 341 | ] 342 | }, 343 | { 344 | "cell_type": "code", 345 | "execution_count": 70, 346 | "metadata": {}, 347 | "outputs": [ 348 | { 349 | "data": { 350 | "text/plain": [ 351 | "16807" 352 | ] 353 | }, 354 | "execution_count": 70, 355 | "metadata": {}, 356 | "output_type": "execute_result" 357 | } 358 | ], 359 | "source": [ 360 | "getPowerFive(7)" 361 | ] 362 | }, 363 | { 364 | "cell_type": "code", 365 | "execution_count": 68, 366 | "metadata": {}, 367 | "outputs": [], 368 | "source": [ 369 | "# Lambda - \n", 370 | "gettPower5 = lambda num : num **5" 371 | ] 372 | }, 373 | { 374 | "cell_type": "code", 375 | "execution_count": 69, 376 | "metadata": {}, 377 | "outputs": [ 378 | { 379 | "data": { 380 | "text/plain": [ 381 | "16807" 382 | ] 383 | }, 384 | "execution_count": 69, 385 | "metadata": {}, 386 | "output_type": "execute_result" 387 | } 388 | ], 389 | "source": [ 390 | "gettPower5(7)" 391 | ] 392 | }, 393 | { 394 | "cell_type": "code", 395 | "execution_count": 74, 396 | "metadata": {}, 397 | "outputs": [], 398 | "source": [ 399 | "cube = lambda i: i* i * i" 400 | ] 401 | }, 402 | { 403 | "cell_type": "code", 404 | "execution_count": 77, 405 | "metadata": {}, 406 | "outputs": [], 407 | "source": [ 408 | "lst_new = map(lambda i: i*i*i*i ,lst)" 409 | ] 410 | }, 411 | { 412 | "cell_type": "code", 413 | "execution_count": 78, 414 | "metadata": {}, 415 | "outputs": [ 416 | { 417 | "data": { 418 | "text/plain": [ 419 | "[1, 16, 81, 256, 625, 1296, 2401, 4096]" 420 | ] 421 | }, 422 | "execution_count": 78, 423 | "metadata": {}, 424 | "output_type": "execute_result" 425 | } 426 | ], 427 | "source": [ 428 | "list(lst_new)" 429 | ] 430 | }, 431 | { 432 | "cell_type": "code", 433 | "execution_count": 85, 434 | "metadata": {}, 435 | "outputs": [], 436 | "source": [ 437 | "isEven = lambda num: num %2 == 0" 438 | ] 439 | }, 440 | { 441 | "cell_type": "code", 442 | "execution_count": 86, 443 | "metadata": {}, 444 | "outputs": [ 445 | { 446 | "data": { 447 | "text/plain": [ 448 | "False" 449 | ] 450 | }, 451 | "execution_count": 86, 452 | "metadata": {}, 453 | "output_type": "execute_result" 454 | } 455 | ], 456 | "source": [ 457 | "isEven(67)" 458 | ] 459 | }, 460 | { 461 | "cell_type": "code", 462 | "execution_count": 91, 463 | "metadata": {}, 464 | "outputs": [ 465 | { 466 | "name": "stdout", 467 | "output_type": "stream", 468 | "text": [ 469 | "[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]\n" 470 | ] 471 | } 472 | ], 473 | "source": [ 474 | "print(list(filter(lambda num: num%2==0,flst)))" 475 | ] 476 | }, 477 | { 478 | "cell_type": "code", 479 | "execution_count": null, 480 | "metadata": {}, 481 | "outputs": [], 482 | "source": [] 483 | } 484 | ], 485 | "metadata": { 486 | "kernelspec": { 487 | "display_name": "Python 3", 488 | "language": "python", 489 | "name": "python3" 490 | }, 491 | "language_info": { 492 | "codemirror_mode": { 493 | "name": "ipython", 494 | "version": 3 495 | }, 496 | "file_extension": ".py", 497 | "mimetype": "text/x-python", 498 | "name": "python", 499 | "nbconvert_exporter": "python", 500 | "pygments_lexer": "ipython3", 501 | "version": "3.7.4" 502 | } 503 | }, 504 | "nbformat": 4, 505 | "nbformat_minor": 2 506 | } 507 | -------------------------------------------------------------------------------- /Batch-4/Day-6/Assignment Day 6.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-4/Day-6/Assignment Day 6.pdf -------------------------------------------------------------------------------- /Batch-4/Day-6/Day 6 Notes.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# OOPs \n", 8 | "\n" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "metadata": {}, 15 | "outputs": [], 16 | "source": [ 17 | "lst = [1,2,3,4,5]\n", 18 | "\n", 19 | "dit = {\"key1\":234,\"key2\":3553}" 20 | ] 21 | }, 22 | { 23 | "cell_type": "code", 24 | "execution_count": 2, 25 | "metadata": {}, 26 | "outputs": [ 27 | { 28 | "data": { 29 | "text/plain": [ 30 | "[1, 2, 3, 4, 5]" 31 | ] 32 | }, 33 | "execution_count": 2, 34 | "metadata": {}, 35 | "output_type": "execute_result" 36 | } 37 | ], 38 | "source": [ 39 | "lst" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 3, 45 | "metadata": {}, 46 | "outputs": [ 47 | { 48 | "data": { 49 | "text/plain": [ 50 | "{'key1': 234, 'key2': 3553}" 51 | ] 52 | }, 53 | "execution_count": 3, 54 | "metadata": {}, 55 | "output_type": "execute_result" 56 | } 57 | ], 58 | "source": [ 59 | "dit" 60 | ] 61 | }, 62 | { 63 | "cell_type": "markdown", 64 | "metadata": {}, 65 | "source": [ 66 | "OOP IS USED FOR making repeatable and organised code when we have to develop program keeping real world objects in mind,\n", 67 | "\n", 68 | "for example u are a car company owner, u want to maintian a full list of cars, \n", 69 | "\n", 70 | "then u will create an object known as Car and then give it properties\n", 71 | "\n", 72 | "based upon the properties, we can code our whole usecase\n" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": 63, 78 | "metadata": {}, 79 | "outputs": [], 80 | "source": [ 81 | "# We need to make a car object in python program \n", 82 | "\n", 83 | "\n", 84 | "# Car Sr. No. - 02\n", 85 | "# Car Color - black\n", 86 | "# Car Fuel - cng\n", 87 | "# Car Passenger - 4+1\n", 88 | "# Car is sold in - 2015\n", 89 | "# Car type - suv\n", 90 | "# Car model - 2013\n", 91 | "\n", 92 | "\n", 93 | "class car():\n", 94 | " '''\n", 95 | " THis is a Car Object which is used for storing the 3 basic values of car\n", 96 | " you need to pass car_sr_no, car_color, car_fuel when initilization it\n", 97 | " '''\n", 98 | " def __init__(self, car_sr_no=\"blank\", car_color=\"blank\", car_fuel=\"blank\"):\n", 99 | " self.car_sr_no = car_sr_no\n", 100 | " self.car_color = car_color\n", 101 | " self.car_fuel = car_fuel\n", 102 | " \n", 103 | " def some_method_to_print(self):\n", 104 | " print(self.car_sr_no)\n", 105 | " print(self.car_color)\n", 106 | " print(self.car_fuel)\n", 107 | " def set_car_sr_no(self,car_sr_no):\n", 108 | " self.car_sr_no = car_sr_no\n", 109 | " " 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": 64, 115 | "metadata": {}, 116 | "outputs": [], 117 | "source": [ 118 | "wagaonR = car(\"wagon1\",\"Navy Blue\",\"Petrol\")" 119 | ] 120 | }, 121 | { 122 | "cell_type": "code", 123 | "execution_count": 65, 124 | "metadata": {}, 125 | "outputs": [ 126 | { 127 | "data": { 128 | "text/plain": [ 129 | "'Navy Blue'" 130 | ] 131 | }, 132 | "execution_count": 65, 133 | "metadata": {}, 134 | "output_type": "execute_result" 135 | } 136 | ], 137 | "source": [ 138 | "wagaonR.car_color" 139 | ] 140 | }, 141 | { 142 | "cell_type": "code", 143 | "execution_count": 66, 144 | "metadata": {}, 145 | "outputs": [ 146 | { 147 | "data": { 148 | "text/plain": [ 149 | "'Petrol'" 150 | ] 151 | }, 152 | "execution_count": 66, 153 | "metadata": {}, 154 | "output_type": "execute_result" 155 | } 156 | ], 157 | "source": [ 158 | "wagaonR.car_fuel" 159 | ] 160 | }, 161 | { 162 | "cell_type": "code", 163 | "execution_count": 67, 164 | "metadata": {}, 165 | "outputs": [ 166 | { 167 | "data": { 168 | "text/plain": [ 169 | "'wagon1'" 170 | ] 171 | }, 172 | "execution_count": 67, 173 | "metadata": {}, 174 | "output_type": "execute_result" 175 | } 176 | ], 177 | "source": [ 178 | "wagaonR.car_sr_no" 179 | ] 180 | }, 181 | { 182 | "cell_type": "code", 183 | "execution_count": 68, 184 | "metadata": {}, 185 | "outputs": [ 186 | { 187 | "name": "stdout", 188 | "output_type": "stream", 189 | "text": [ 190 | "wagon1\n", 191 | "Navy Blue\n", 192 | "Petrol\n" 193 | ] 194 | } 195 | ], 196 | "source": [ 197 | "wagaonR.some_method_to_print()" 198 | ] 199 | }, 200 | { 201 | "cell_type": "code", 202 | "execution_count": 69, 203 | "metadata": {}, 204 | "outputs": [], 205 | "source": [ 206 | "swift = car(\"swift1\",\"White\",\"Petrol\")" 207 | ] 208 | }, 209 | { 210 | "cell_type": "code", 211 | "execution_count": 70, 212 | "metadata": {}, 213 | "outputs": [ 214 | { 215 | "name": "stdout", 216 | "output_type": "stream", 217 | "text": [ 218 | "swift1\n", 219 | "White\n", 220 | "Petrol\n" 221 | ] 222 | } 223 | ], 224 | "source": [ 225 | "swift.some_method_to_print()" 226 | ] 227 | }, 228 | { 229 | "cell_type": "code", 230 | "execution_count": 71, 231 | "metadata": {}, 232 | "outputs": [], 233 | "source": [ 234 | "skodarapid = car()" 235 | ] 236 | }, 237 | { 238 | "cell_type": "code", 239 | "execution_count": 72, 240 | "metadata": {}, 241 | "outputs": [ 242 | { 243 | "name": "stdout", 244 | "output_type": "stream", 245 | "text": [ 246 | "blank\n", 247 | "blank\n", 248 | "blank\n" 249 | ] 250 | } 251 | ], 252 | "source": [ 253 | "skodarapid.some_method_to_print()" 254 | ] 255 | }, 256 | { 257 | "cell_type": "code", 258 | "execution_count": 73, 259 | "metadata": {}, 260 | "outputs": [ 261 | { 262 | "ename": "AttributeError", 263 | "evalue": "'car' object has no attribute 'set_car_sr_no'", 264 | "output_type": "error", 265 | "traceback": [ 266 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 267 | "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", 268 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mrapid\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mset_car_sr_no\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Rapid123\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 269 | "\u001b[0;31mAttributeError\u001b[0m: 'car' object has no attribute 'set_car_sr_no'" 270 | ] 271 | } 272 | ], 273 | "source": [ 274 | "rapid.set_car_sr_no(\"Rapid123\")" 275 | ] 276 | }, 277 | { 278 | "cell_type": "code", 279 | "execution_count": 36, 280 | "metadata": {}, 281 | "outputs": [ 282 | { 283 | "name": "stdout", 284 | "output_type": "stream", 285 | "text": [ 286 | "Rapid123\n", 287 | "blank\n", 288 | "blank\n" 289 | ] 290 | } 291 | ], 292 | "source": [ 293 | "rapid.some_method_to_print()" 294 | ] 295 | }, 296 | { 297 | "cell_type": "code", 298 | "execution_count": 74, 299 | "metadata": {}, 300 | "outputs": [], 301 | "source": [ 302 | "jeepcompass = car()" 303 | ] 304 | }, 305 | { 306 | "cell_type": "code", 307 | "execution_count": 76, 308 | "metadata": {}, 309 | "outputs": [ 310 | { 311 | "name": "stdout", 312 | "output_type": "stream", 313 | "text": [ 314 | "blank\n", 315 | "blank\n", 316 | "blank\n" 317 | ] 318 | } 319 | ], 320 | "source": [ 321 | "jeepcompass.some_method_to_print()" 322 | ] 323 | }, 324 | { 325 | "cell_type": "code", 326 | "execution_count": 77, 327 | "metadata": {}, 328 | "outputs": [], 329 | "source": [ 330 | "jeepcompass.set_car_sr_no(\"Jeep_chn_01\")" 331 | ] 332 | }, 333 | { 334 | "cell_type": "code", 335 | "execution_count": 78, 336 | "metadata": {}, 337 | "outputs": [ 338 | { 339 | "data": { 340 | "text/plain": [ 341 | "'Jeep_chn_01'" 342 | ] 343 | }, 344 | "execution_count": 78, 345 | "metadata": {}, 346 | "output_type": "execute_result" 347 | } 348 | ], 349 | "source": [ 350 | "jeepcompass.car_sr_no" 351 | ] 352 | }, 353 | { 354 | "cell_type": "code", 355 | "execution_count": 6, 356 | "metadata": {}, 357 | "outputs": [], 358 | "source": [ 359 | "# Define a class for circle and develop methods, like perimeter, area\n", 360 | "\n", 361 | "class circle():\n", 362 | " pi = 3.14\n", 363 | " \n", 364 | " def __init__(self, radius):\n", 365 | " self.radius = radius\n", 366 | " \n", 367 | " sumit = lambda self : print(self.radius)\n", 368 | " \n", 369 | " def getArea(self):\n", 370 | " return circle.pi * self.radius * self.radius\n", 371 | " \n", 372 | " def getCircumference(self):\n", 373 | " return 2 * circle.pi * self.radius" 374 | ] 375 | }, 376 | { 377 | "cell_type": "code", 378 | "execution_count": 7, 379 | "metadata": {}, 380 | "outputs": [], 381 | "source": [ 382 | "circle1 = circle(23)" 383 | ] 384 | }, 385 | { 386 | "cell_type": "code", 387 | "execution_count": 8, 388 | "metadata": {}, 389 | "outputs": [ 390 | { 391 | "data": { 392 | "text/plain": [ 393 | "1661.06" 394 | ] 395 | }, 396 | "execution_count": 8, 397 | "metadata": {}, 398 | "output_type": "execute_result" 399 | } 400 | ], 401 | "source": [ 402 | "circle1.getArea()" 403 | ] 404 | }, 405 | { 406 | "cell_type": "code", 407 | "execution_count": 9, 408 | "metadata": {}, 409 | "outputs": [ 410 | { 411 | "data": { 412 | "text/plain": [ 413 | "144.44" 414 | ] 415 | }, 416 | "execution_count": 9, 417 | "metadata": {}, 418 | "output_type": "execute_result" 419 | } 420 | ], 421 | "source": [ 422 | "circle1.getCircumference()" 423 | ] 424 | }, 425 | { 426 | "cell_type": "code", 427 | "execution_count": 10, 428 | "metadata": {}, 429 | "outputs": [ 430 | { 431 | "name": "stdout", 432 | "output_type": "stream", 433 | "text": [ 434 | "23\n" 435 | ] 436 | } 437 | ], 438 | "source": [ 439 | "circle1.sumit()" 440 | ] 441 | }, 442 | { 443 | "cell_type": "markdown", 444 | "metadata": {}, 445 | "source": [ 446 | "# Inheritance " 447 | ] 448 | }, 449 | { 450 | "cell_type": "code", 451 | "execution_count": 12, 452 | "metadata": {}, 453 | "outputs": [], 454 | "source": [ 455 | "# Parent class methods+ attributes can be called inside the child class " 456 | ] 457 | }, 458 | { 459 | "cell_type": "code", 460 | "execution_count": 13, 461 | "metadata": {}, 462 | "outputs": [], 463 | "source": [ 464 | "#parent class\n", 465 | "class pen():\n", 466 | " def __init__ (self,companyName,penType):\n", 467 | " self.companyName = companyName \n", 468 | " self.penType = penType \n", 469 | " def getPenCompany(self):\n", 470 | " print(self.companyName)\n", 471 | " def getPenType(self):\n", 472 | " print(self.penType)\n", 473 | " " 474 | ] 475 | }, 476 | { 477 | "cell_type": "code", 478 | "execution_count": 29, 479 | "metadata": {}, 480 | "outputs": [], 481 | "source": [ 482 | "#Child Class\n", 483 | "class uniPen(pen):\n", 484 | " def __init__ (self,penType, country, color, srno, price):\n", 485 | " self.country = country\n", 486 | " self.color = color\n", 487 | " self.srno = srno\n", 488 | " self.price = price\n", 489 | " pen.__init__(self,\"uniPen\",penType)\n", 490 | " \n", 491 | " def setPenType(self,newPenType):\n", 492 | " print(\"We are inside the UniPen class\")\n", 493 | " self.penType = newPenType\n", 494 | " print(\"Pen Type is - \",self.penType)\n" 495 | ] 496 | }, 497 | { 498 | "cell_type": "code", 499 | "execution_count": 30, 500 | "metadata": {}, 501 | "outputs": [], 502 | "source": [ 503 | "zeroPointOneBlack = uniPen(\"ink\",\"Japan\",\"#212121\",\"sr123\",90)" 504 | ] 505 | }, 506 | { 507 | "cell_type": "code", 508 | "execution_count": 24, 509 | "metadata": {}, 510 | "outputs": [ 511 | { 512 | "name": "stdout", 513 | "output_type": "stream", 514 | "text": [ 515 | "uniPen\n" 516 | ] 517 | } 518 | ], 519 | "source": [ 520 | "zeroPointOneBlack.getPenCompany()" 521 | ] 522 | }, 523 | { 524 | "cell_type": "code", 525 | "execution_count": 25, 526 | "metadata": {}, 527 | "outputs": [ 528 | { 529 | "name": "stdout", 530 | "output_type": "stream", 531 | "text": [ 532 | "ink\n" 533 | ] 534 | } 535 | ], 536 | "source": [ 537 | "zeroPointOneBlack.getPenType()" 538 | ] 539 | }, 540 | { 541 | "cell_type": "code", 542 | "execution_count": 26, 543 | "metadata": {}, 544 | "outputs": [ 545 | { 546 | "name": "stdout", 547 | "output_type": "stream", 548 | "text": [ 549 | "We are inside the UniPen class\n", 550 | "Pen Type is - Gel\n" 551 | ] 552 | } 553 | ], 554 | "source": [ 555 | "zeroPointOneBlack.setPenType(\"Gel\")" 556 | ] 557 | }, 558 | { 559 | "cell_type": "code", 560 | "execution_count": 27, 561 | "metadata": {}, 562 | "outputs": [ 563 | { 564 | "name": "stdout", 565 | "output_type": "stream", 566 | "text": [ 567 | "Gel\n" 568 | ] 569 | } 570 | ], 571 | "source": [ 572 | "zeroPointOneBlack.getPenType()" 573 | ] 574 | }, 575 | { 576 | "cell_type": "code", 577 | "execution_count": null, 578 | "metadata": {}, 579 | "outputs": [], 580 | "source": [ 581 | "Stree Reported = ParentClassProperties + NewChildProperties = inHeritance " 582 | ] 583 | } 584 | ], 585 | "metadata": { 586 | "kernelspec": { 587 | "display_name": "Python 3", 588 | "language": "python", 589 | "name": "python3" 590 | }, 591 | "language_info": { 592 | "codemirror_mode": { 593 | "name": "ipython", 594 | "version": 3 595 | }, 596 | "file_extension": ".py", 597 | "mimetype": "text/x-python", 598 | "name": "python", 599 | "nbconvert_exporter": "python", 600 | "pygments_lexer": "ipython3", 601 | "version": "3.7.4" 602 | } 603 | }, 604 | "nbformat": 4, 605 | "nbformat_minor": 2 606 | } 607 | -------------------------------------------------------------------------------- /Batch-4/Day-7/Assignment Day 7.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-4/Day-7/Assignment Day 7.pdf -------------------------------------------------------------------------------- /Batch-4/Day-7/Day 7 Notes.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Error Handling \n", 8 | "\n", 9 | "Errors are bond to happen when we are writing a big peice of code, \n", 10 | "\n", 11 | "and when some unexcpeted event occurs, like internet not there in ur API\n", 12 | "\n", 13 | "to handle these things propeerly we use Error Handling !!!" 14 | ] 15 | }, 16 | { 17 | "cell_type": "code", 18 | "execution_count": 6, 19 | "metadata": {}, 20 | "outputs": [ 21 | { 22 | "name": "stdout", 23 | "output_type": "stream", 24 | "text": [ 25 | "HI We are working 1\n", 26 | "There was an error \n", 27 | "Hi we are working 2\n" 28 | ] 29 | } 30 | ], 31 | "source": [ 32 | "print(\"HI We are working 1\") #1\n", 33 | "try:\n", 34 | " a = 5/0 #2\n", 35 | "except:\n", 36 | " print(\"There was an error \")\n", 37 | "print(\"Hi we are working 2\") #3" 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": 15, 43 | "metadata": {}, 44 | "outputs": [ 45 | { 46 | "name": "stdout", 47 | "output_type": "stream", 48 | "text": [ 49 | "we are in try block\n", 50 | "Hi everyone welcome to day 6 of FCS \n", 51 | "There was an error - division by zero\n", 52 | "We are in Finally block\n" 53 | ] 54 | } 55 | ], 56 | "source": [ 57 | "try: # We are trying a peice of code and lets see if it break or not\n", 58 | " print(\"we are in try block\")\n", 59 | " file = open(\"fcs.txt\",'r')\n", 60 | " statement = file.read()\n", 61 | " #file.write(\"hi\")\n", 62 | " print(statement)\n", 63 | " \n", 64 | " a = 5/0\n", 65 | " \n", 66 | "except Exception as e: # Catch the error and print something to conclude \n", 67 | " print(\"There was an error - \", e)\n", 68 | " \n", 69 | "finally: # Finally is going to run what ever may happen \n", 70 | " print(\"We are in Finally block\")\n", 71 | " file.close() " 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 17, 77 | "metadata": {}, 78 | "outputs": [ 79 | { 80 | "name": "stdout", 81 | "output_type": "stream", 82 | "text": [ 83 | "we are in try block\n", 84 | "Hi everyone welcome to day 6 of FCS \n" 85 | ] 86 | }, 87 | { 88 | "ename": "ZeroDivisionError", 89 | "evalue": "division by zero", 90 | "output_type": "error", 91 | "traceback": [ 92 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 93 | "\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", 94 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstatement\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0ma\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m5\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 95 | "\u001b[0;31mZeroDivisionError\u001b[0m: division by zero" 96 | ] 97 | } 98 | ], 99 | "source": [ 100 | "print(\"we are in try block\")\n", 101 | "file = open(\"fcs.txt\",'r')\n", 102 | "statement = file.read()\n", 103 | " #file.write(\"hi\")\n", 104 | "print(statement)\n", 105 | "\n", 106 | "a = 5/0" 107 | ] 108 | }, 109 | { 110 | "cell_type": "code", 111 | "execution_count": 21, 112 | "metadata": {}, 113 | "outputs": [ 114 | { 115 | "name": "stdout", 116 | "output_type": "stream", 117 | "text": [ 118 | "There was an error - HI There we have manually kept this error to occour\n", 119 | "We are in Finally block\n" 120 | ] 121 | } 122 | ], 123 | "source": [ 124 | "try: # We are trying a peice of code and lets see if it break or not\n", 125 | " raise NameError(\"HI There we have manually kept this error to occour\")\n", 126 | " \n", 127 | "except Exception as e: # Catch the error and print something to conclude \n", 128 | " print(\"There was an error - \", e)\n", 129 | " \n", 130 | "finally: # Finally is going to run what ever may happen \n", 131 | " print(\"We are in Finally block\")\n", 132 | " file.close()" 133 | ] 134 | }, 135 | { 136 | "cell_type": "code", 137 | "execution_count": 23, 138 | "metadata": {}, 139 | "outputs": [ 140 | { 141 | "name": "stdout", 142 | "output_type": "stream", 143 | "text": [ 144 | "OK\n", 145 | "We are in Finally block\n" 146 | ] 147 | } 148 | ], 149 | "source": [ 150 | "try: # We are trying a peice of code and lets see if it break or not\n", 151 | " googleFormVer = 4\n", 152 | " if googleFormVer == 4:\n", 153 | " print(\"OK\")\n", 154 | " else:\n", 155 | " raise NameError(\"HI There we have to update the Google Form to Version 4\")\n", 156 | " \n", 157 | "except Exception as e: # Catch the error and print something to conclude \n", 158 | " print(\"There was an error - \", e)\n", 159 | " \n", 160 | "finally: # Finally is going to run what ever may happen \n", 161 | " print(\"We are in Finally block\")\n" 162 | ] 163 | }, 164 | { 165 | "cell_type": "code", 166 | "execution_count": 24, 167 | "metadata": {}, 168 | "outputs": [], 169 | "source": [ 170 | "# Try \n", 171 | "#. - Raise\n", 172 | "# Except \n", 173 | "#. - Exception\n", 174 | "#finally " 175 | ] 176 | }, 177 | { 178 | "cell_type": "markdown", 179 | "metadata": {}, 180 | "source": [ 181 | "# Testing ??\n" 182 | ] 183 | }, 184 | { 185 | "cell_type": "code", 186 | "execution_count": 25, 187 | "metadata": {}, 188 | "outputs": [], 189 | "source": [ 190 | "# When u code a peice of big program, u want many things as like is \n", 191 | "# this code gonna work excatly the way it has to " 192 | ] 193 | }, 194 | { 195 | "cell_type": "code", 196 | "execution_count": 26, 197 | "metadata": {}, 198 | "outputs": [], 199 | "source": [ 200 | "# Linting ?\n", 201 | "# Linting is used to find out is ur code industry standards yes or no \n", 202 | "# PyLint - Install ?\n", 203 | "# pip install pylint\n", 204 | "\n", 205 | "# unit testing ?\n", 206 | "# To test a particualr module is working and giving in the desired yes or no\n" 207 | ] 208 | }, 209 | { 210 | "cell_type": "markdown", 211 | "metadata": {}, 212 | "source": [ 213 | " # PyLint" 214 | ] 215 | }, 216 | { 217 | "cell_type": "code", 218 | "execution_count": 27, 219 | "metadata": {}, 220 | "outputs": [ 221 | { 222 | "name": "stdout", 223 | "output_type": "stream", 224 | "text": [ 225 | "Requirement already satisfied: pylint in /opt/anaconda3/lib/python3.7/site-packages (2.4.2)\n", 226 | "Requirement already satisfied: mccabe<0.7,>=0.6 in /opt/anaconda3/lib/python3.7/site-packages (from pylint) (0.6.1)\n", 227 | "Requirement already satisfied: isort<5,>=4.2.5 in /opt/anaconda3/lib/python3.7/site-packages (from pylint) (4.3.21)\n", 228 | "Requirement already satisfied: astroid<2.4,>=2.3.0 in /opt/anaconda3/lib/python3.7/site-packages (from pylint) (2.3.1)\n", 229 | "Requirement already satisfied: wrapt==1.11.* in /opt/anaconda3/lib/python3.7/site-packages (from astroid<2.4,>=2.3.0->pylint) (1.11.2)\n", 230 | "Requirement already satisfied: typed-ast<1.5,>=1.4.0; implementation_name == \"cpython\" and python_version < \"3.8\" in /opt/anaconda3/lib/python3.7/site-packages (from astroid<2.4,>=2.3.0->pylint) (1.4.1)\n", 231 | "Requirement already satisfied: six==1.12 in /opt/anaconda3/lib/python3.7/site-packages (from astroid<2.4,>=2.3.0->pylint) (1.12.0)\n", 232 | "Requirement already satisfied: lazy-object-proxy==1.4.* in /opt/anaconda3/lib/python3.7/site-packages (from astroid<2.4,>=2.3.0->pylint) (1.4.2)\n", 233 | "\u001b[33mWARNING: You are using pip version 20.0.2; however, version 20.1.1 is available.\n", 234 | "You should consider upgrading via the '/opt/anaconda3/bin/python -m pip install --upgrade pip' command.\u001b[0m\n" 235 | ] 236 | } 237 | ], 238 | "source": [ 239 | "!pip install pylint" 240 | ] 241 | }, 242 | { 243 | "cell_type": "code", 244 | "execution_count": 34, 245 | "metadata": {}, 246 | "outputs": [ 247 | { 248 | "name": "stdout", 249 | "output_type": "stream", 250 | "text": [ 251 | "Overwriting some.py\n" 252 | ] 253 | } 254 | ], 255 | "source": [ 256 | "%%writefile some.py\n", 257 | "'''\n", 258 | "this is the docstring for some.py\n", 259 | "'''\n", 260 | "A = 10\n", 261 | "B = 15\n", 262 | "C = A + B\n", 263 | "print(C)" 264 | ] 265 | }, 266 | { 267 | "cell_type": "code", 268 | "execution_count": 35, 269 | "metadata": { 270 | "scrolled": true 271 | }, 272 | "outputs": [ 273 | { 274 | "name": "stdout", 275 | "output_type": "stream", 276 | "text": [ 277 | "\r\n", 278 | "----------------------------------------------------------------------\r\n", 279 | "Your code has been rated at 10.00/10 (previous run: -15.00/10, +25.00)\r\n", 280 | "\r\n" 281 | ] 282 | } 283 | ], 284 | "source": [ 285 | "! pylint some.py" 286 | ] 287 | }, 288 | { 289 | "cell_type": "markdown", 290 | "metadata": {}, 291 | "source": [ 292 | "factorial of a number = 10\n", 293 | "\n", 294 | "10 * 9 * 8* 7 * 6 * 5 * 4 * 3 * 2 * 1 " 295 | ] 296 | }, 297 | { 298 | "cell_type": "code", 299 | "execution_count": 57, 300 | "metadata": {}, 301 | "outputs": [ 302 | { 303 | "name": "stdout", 304 | "output_type": "stream", 305 | "text": [ 306 | "Overwriting factorial.py\n" 307 | ] 308 | } 309 | ], 310 | "source": [ 311 | "%%writefile factorial.py\n", 312 | "\"\"\"\n", 313 | "This is a Python program for gettting factorial Numbers\n", 314 | "\"\"\"\n", 315 | "NUM = 10\n", 316 | "def factorial_function(number):\n", 317 | " '''\n", 318 | " This is a function for factorial\n", 319 | " '''\n", 320 | " fact = 1\n", 321 | " for i in range(1, number+1):\n", 322 | " fact = fact * i\n", 323 | " return fact\n", 324 | "\n", 325 | "FCT = factorial_function(NUM)\n", 326 | "print(FCT)" 327 | ] 328 | }, 329 | { 330 | "cell_type": "code", 331 | "execution_count": 58, 332 | "metadata": {}, 333 | "outputs": [ 334 | { 335 | "name": "stdout", 336 | "output_type": "stream", 337 | "text": [ 338 | "\r\n", 339 | "-------------------------------------------------------------------\r\n", 340 | "Your code has been rated at 10.00/10 (previous run: 8.75/10, +1.25)\r\n", 341 | "\r\n" 342 | ] 343 | } 344 | ], 345 | "source": [ 346 | "! pylint factorial.py" 347 | ] 348 | }, 349 | { 350 | "cell_type": "code", 351 | "execution_count": 59, 352 | "metadata": {}, 353 | "outputs": [ 354 | { 355 | "name": "stdout", 356 | "output_type": "stream", 357 | "text": [ 358 | "3628800\r\n" 359 | ] 360 | } 361 | ], 362 | "source": [ 363 | "! python factorial.py" 364 | ] 365 | }, 366 | { 367 | "cell_type": "markdown", 368 | "metadata": {}, 369 | "source": [ 370 | "# Unit Testing - \n", 371 | "\n", 372 | "Testing of modules working properly yes or no" 373 | ] 374 | }, 375 | { 376 | "cell_type": "code", 377 | "execution_count": 60, 378 | "metadata": {}, 379 | "outputs": [], 380 | "source": [ 381 | "##UnitTesting \n", 382 | "def cap_text(text):\n", 383 | " return text.title()" 384 | ] 385 | }, 386 | { 387 | "cell_type": "code", 388 | "execution_count": 62, 389 | "metadata": {}, 390 | "outputs": [ 391 | { 392 | "data": { 393 | "text/plain": [ 394 | "'Hi People I Love Teaching And Letsupgrade Too'" 395 | ] 396 | }, 397 | "execution_count": 62, 398 | "metadata": {}, 399 | "output_type": "execute_result" 400 | } 401 | ], 402 | "source": [ 403 | "cap_text(\"hi people i love teaching and letsupgrade too\")" 404 | ] 405 | }, 406 | { 407 | "cell_type": "code", 408 | "execution_count": 64, 409 | "metadata": {}, 410 | "outputs": [ 411 | { 412 | "name": "stdout", 413 | "output_type": "stream", 414 | "text": [ 415 | "Writing cap.py\n" 416 | ] 417 | } 418 | ], 419 | "source": [ 420 | "%%writefile cap.py\n", 421 | "def cap_text(text):\n", 422 | " return text.title()" 423 | ] 424 | }, 425 | { 426 | "cell_type": "code", 427 | "execution_count": 80, 428 | "metadata": {}, 429 | "outputs": [ 430 | { 431 | "name": "stdout", 432 | "output_type": "stream", 433 | "text": [ 434 | "Overwriting test_cap.py\n" 435 | ] 436 | } 437 | ], 438 | "source": [ 439 | "%%writefile test_cap.py\n", 440 | "\n", 441 | "import unittest\n", 442 | "import cap\n", 443 | "\n", 444 | "class TestCapital(unittest.TestCase):\n", 445 | " def testsingleword(self):\n", 446 | " some_text = \"letsupgrade\"\n", 447 | " result = cap.cap_text(some_text)\n", 448 | " self.assertEqual(result,\"Letsupgrade\")\n", 449 | " def testMultipleWord(self):\n", 450 | " some_text = \"sorry for the buffer\"\n", 451 | " result = cap.cap_text(some_text)\n", 452 | " self.assertEqual(result,\"Sorry For The Buffer\")\n", 453 | " def testTenWords(self):\n", 454 | " some_text = \"i welcome you all to letsupgrade, a freedom providing startup in education\"\n", 455 | " result = cap.cap_text(some_text)\n", 456 | " self.assertEqual(result,\"I Welcome You All To Letsupgrade, A Freedom Providing Startup In Education\")\n", 457 | " \n", 458 | "\n", 459 | "if __name__ == \"__main__\":\n", 460 | " unittest.main()" 461 | ] 462 | }, 463 | { 464 | "cell_type": "code", 465 | "execution_count": 81, 466 | "metadata": {}, 467 | "outputs": [ 468 | { 469 | "name": "stdout", 470 | "output_type": "stream", 471 | "text": [ 472 | "...\r\n", 473 | "----------------------------------------------------------------------\r\n", 474 | "Ran 3 tests in 0.000s\r\n", 475 | "\r\n", 476 | "OK\r\n" 477 | ] 478 | } 479 | ], 480 | "source": [ 481 | "! python test_cap.py" 482 | ] 483 | }, 484 | { 485 | "cell_type": "code", 486 | "execution_count": null, 487 | "metadata": {}, 488 | "outputs": [], 489 | "source": [] 490 | } 491 | ], 492 | "metadata": { 493 | "kernelspec": { 494 | "display_name": "Python 3", 495 | "language": "python", 496 | "name": "python3" 497 | }, 498 | "language_info": { 499 | "codemirror_mode": { 500 | "name": "ipython", 501 | "version": 3 502 | }, 503 | "file_extension": ".py", 504 | "mimetype": "text/x-python", 505 | "name": "python", 506 | "nbconvert_exporter": "python", 507 | "pygments_lexer": "ipython3", 508 | "version": "3.7.4" 509 | } 510 | }, 511 | "nbformat": 4, 512 | "nbformat_minor": 2 513 | } 514 | -------------------------------------------------------------------------------- /Batch-4/Day-8/Assignment Day 8.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-4/Day-8/Assignment Day 8.pdf -------------------------------------------------------------------------------- /Batch-5/Day-2/Day 2 Assignment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-5/Day-2/Day 2 Assignment.pdf -------------------------------------------------------------------------------- /Batch-5/Day-3/Assignment Day 3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-5/Day-3/Assignment Day 3.pdf -------------------------------------------------------------------------------- /Batch-5/Day-4/Assignment Day 4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-5/Day-4/Assignment Day 4.pdf -------------------------------------------------------------------------------- /Batch-5/Day-4/Day 4 Notes.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# File Handling ... \n", 8 | "\n", 9 | "\n", 10 | "in computer/ smart phones all the bytes are stored in contrainers, \n", 11 | "\n", 12 | "which can be accessed any point of time whenever we need them \n", 13 | "\n", 14 | "and yes we can store multiple containers together in a bundles. \n", 15 | "\n", 16 | "now what are they ??\n", 17 | "\n", 18 | "1. Containers are files ?\n", 19 | "2. Bundles are Folders ?\n", 20 | "\n", 21 | "\n", 22 | "# what all things we can do with File Handling ?\n", 23 | "\n", 24 | "1. read \n", 25 | "2. write \n", 26 | "3. create new file \n", 27 | "4. modify the file \n", 28 | "\n", 29 | "\n", 30 | "Now lets go ahead and learn how to handle files in Python .... \n", 31 | "\n" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": 4, 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [ 40 | "# Create a file ?\n", 41 | "\n", 42 | "file = open(\"fantasticFive.txt\",\"w\")\n", 43 | "\n", 44 | "file.close()\n", 45 | "\n", 46 | "#VaribaleName = open(FileName,Mode)" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": 5, 52 | "metadata": {}, 53 | "outputs": [], 54 | "source": [ 55 | "# Write data to File \n", 56 | "\n", 57 | "file = open(\"fantasticFive.txt\",\"w\")\n", 58 | "\n", 59 | "file.write(\"HI Guys we are writing inside a file\")\n", 60 | "\n", 61 | "file.close()" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": 20, 67 | "metadata": {}, 68 | "outputs": [ 69 | { 70 | "name": "stdout", 71 | "output_type": "stream", 72 | "text": [ 73 | "OYEEE\n", 74 | "\n", 75 | "rafda\n", 76 | "\n", 77 | "hey guys i hope u are not sleeping right now !!\n" 78 | ] 79 | } 80 | ], 81 | "source": [ 82 | "# Reading a file from the Computer \n", 83 | "\n", 84 | "file = open(\"fantasticFive.txt\",\"r\")\n", 85 | "someText = file.read()\n", 86 | "print(someText)\n", 87 | "#file.write(\"OYEEE\") this will give error \n", 88 | "file.close()" 89 | ] 90 | }, 91 | { 92 | "cell_type": "code", 93 | "execution_count": 10, 94 | "metadata": {}, 95 | "outputs": [], 96 | "source": [ 97 | "# Add some lines to the File \n", 98 | "\n", 99 | "file = open(\"fantasticFive.txt\",\"a\")\n", 100 | "\n", 101 | "file.write(\"\\n\\nThis is some more data!!\")\n", 102 | "\n", 103 | "file.close()" 104 | ] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "execution_count": 12, 109 | "metadata": {}, 110 | "outputs": [ 111 | { 112 | "name": "stdout", 113 | "output_type": "stream", 114 | "text": [ 115 | "HI Guys we are writing inside a file\n", 116 | "\n", 117 | "This is some more data!!\n" 118 | ] 119 | } 120 | ], 121 | "source": [ 122 | "# r+ mode, reading and writing both \n", 123 | "\n", 124 | "file = open(\"fantasticFive.txt\",\"r+\")\n", 125 | "print(file.read())\n", 126 | "file.write(\"\\n\\nThanks guys for trusting me \")\n", 127 | "file.close()" 128 | ] 129 | }, 130 | { 131 | "cell_type": "code", 132 | "execution_count": 13, 133 | "metadata": {}, 134 | "outputs": [ 135 | { 136 | "name": "stdout", 137 | "output_type": "stream", 138 | "text": [ 139 | "HI Guys we are writing inside a file\n", 140 | "\n", 141 | "This is some more data!!\n", 142 | "\n", 143 | "Thanks guys for trusting me \n" 144 | ] 145 | } 146 | ], 147 | "source": [ 148 | "# Reading a file from the Computer \n", 149 | "\n", 150 | "file = open(\"fantasticFive.txt\",\"r\")\n", 151 | "someText = file.read()\n", 152 | "print(someText)\n", 153 | "#file.write(\"OYEEE\") this will give error \n", 154 | "file.close()" 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "execution_count": 14, 160 | "metadata": {}, 161 | "outputs": [], 162 | "source": [ 163 | "# Reading a file from the Computer \n", 164 | "\n", 165 | "file = open(\"fantasticFive.txt\",\"w\")\n", 166 | "file.write(\"OYEEE\") #this will give error \n", 167 | "file.close()" 168 | ] 169 | }, 170 | { 171 | "cell_type": "markdown", 172 | "metadata": {}, 173 | "source": [ 174 | "# With function in File Handling \n", 175 | "\n" 176 | ] 177 | }, 178 | { 179 | "cell_type": "code", 180 | "execution_count": 19, 181 | "metadata": {}, 182 | "outputs": [ 183 | { 184 | "name": "stdout", 185 | "output_type": "stream", 186 | "text": [ 187 | "Hey guys lets enter something herehey guys i hope u are not sleeping right now !!\n" 188 | ] 189 | } 190 | ], 191 | "source": [ 192 | "with open(\"fantasticFive.txt\",\"a\") as file: \n", 193 | " someInput = input(\"Hey guys lets enter something here\")\n", 194 | " file.write(\"\\n\\n\"+someInput) " 195 | ] 196 | }, 197 | { 198 | "cell_type": "markdown", 199 | "metadata": {}, 200 | "source": [ 201 | "# Methods ??\n", 202 | "\n", 203 | "Functions which are by default in Python and Functions which are inside objects are knows as methods \n", 204 | "\n", 205 | "and we have already seen together List and its methods\n", 206 | "\n", 207 | "\n", 208 | "# Functions ??\n", 209 | "\n", 210 | "Functions are the resuale coding block, which are user defined for making sure the code repeatablity is encontered and reduced" 211 | ] 212 | }, 213 | { 214 | "cell_type": "code", 215 | "execution_count": 24, 216 | "metadata": {}, 217 | "outputs": [ 218 | { 219 | "data": { 220 | "text/plain": [ 221 | "3" 222 | ] 223 | }, 224 | "execution_count": 24, 225 | "metadata": {}, 226 | "output_type": "execute_result" 227 | } 228 | ], 229 | "source": [ 230 | "lst = [1,2,4,5,6]\n", 231 | "# Methods \n", 232 | "lst.index(5)" 233 | ] 234 | }, 235 | { 236 | "cell_type": "markdown", 237 | "metadata": {}, 238 | "source": [ 239 | "- How to write functions ?\n", 240 | "- what all things we can do with functions?" 241 | ] 242 | }, 243 | { 244 | "cell_type": "code", 245 | "execution_count": 25, 246 | "metadata": {}, 247 | "outputs": [ 248 | { 249 | "name": "stdout", 250 | "output_type": "stream", 251 | "text": [ 252 | " HI Deepak\n", 253 | " HI Akash\n", 254 | " HI Krishnaveni\n", 255 | " HI Gayatri\n", 256 | " HI Bharat\n", 257 | " HI Carla\n" 258 | ] 259 | } 260 | ], 261 | "source": [ 262 | "print(\" HI\", \"Deepak\")\n", 263 | "print(\" HI\", \"Akash\")\n", 264 | "print(\" HI\", \"Krishnaveni\")\n", 265 | "print(\" HI\", \"Gayatri\")\n", 266 | "print(\" HI\", \"Bharat\")\n", 267 | "print(\" HI\", \"Carla\")" 268 | ] 269 | }, 270 | { 271 | "cell_type": "code", 272 | "execution_count": 79, 273 | "metadata": {}, 274 | "outputs": [], 275 | "source": [ 276 | "#Defining a code block inside function in Python\n", 277 | "\n", 278 | "def someFunctionName(argument):\n", 279 | " print(\"-------------\")\n", 280 | " print(\"Hi\",argument)\n", 281 | " print(\"-------------\")" 282 | ] 283 | }, 284 | { 285 | "cell_type": "code", 286 | "execution_count": 80, 287 | "metadata": {}, 288 | "outputs": [ 289 | { 290 | "name": "stdout", 291 | "output_type": "stream", 292 | "text": [ 293 | "-------------\n", 294 | "Hi Deepak\n", 295 | "-------------\n" 296 | ] 297 | } 298 | ], 299 | "source": [ 300 | "someFunctionName(\"Deepak\")" 301 | ] 302 | }, 303 | { 304 | "cell_type": "code", 305 | "execution_count": 29, 306 | "metadata": {}, 307 | "outputs": [], 308 | "source": [ 309 | "lst = [\"deepak\",\"carla\",\" het\", \" muneer\", \" vivek\"]" 310 | ] 311 | }, 312 | { 313 | "cell_type": "code", 314 | "execution_count": 32, 315 | "metadata": {}, 316 | "outputs": [ 317 | { 318 | "name": "stdout", 319 | "output_type": "stream", 320 | "text": [ 321 | "-------------\n", 322 | "Hi deepak\n", 323 | "-------------\n", 324 | "-------------\n", 325 | "Hi carla\n", 326 | "-------------\n", 327 | "-------------\n", 328 | "Hi het\n", 329 | "-------------\n", 330 | "-------------\n", 331 | "Hi muneer\n", 332 | "-------------\n", 333 | "-------------\n", 334 | "Hi vivek\n", 335 | "-------------\n" 336 | ] 337 | } 338 | ], 339 | "source": [ 340 | "for item in lst:\n", 341 | " someFunctionName(item)" 342 | ] 343 | }, 344 | { 345 | "cell_type": "code", 346 | "execution_count": 34, 347 | "metadata": {}, 348 | "outputs": [], 349 | "source": [ 350 | "# Where we use Return Keyword ???\n", 351 | "\n", 352 | "\n", 353 | "# when ever you want to process some kind of data in function \n", 354 | "# and return that final value from your function that time \n", 355 | "# we use Return keyword" 356 | ] 357 | }, 358 | { 359 | "cell_type": "code", 360 | "execution_count": 42, 361 | "metadata": {}, 362 | "outputs": [], 363 | "source": [ 364 | "# function to return if my number is odd or even \n", 365 | "\n", 366 | "def oddEvenFun(num):\n", 367 | " if num%2 == 0 :\n", 368 | " text = str(num) + \" is Even\"\n", 369 | " return text\n", 370 | " else:\n", 371 | " text = str(num) + \" is Odd\"\n", 372 | " return text" 373 | ] 374 | }, 375 | { 376 | "cell_type": "code", 377 | "execution_count": 45, 378 | "metadata": {}, 379 | "outputs": [ 380 | { 381 | "name": "stdout", 382 | "output_type": "stream", 383 | "text": [ 384 | "1 is Odd\n", 385 | "2 is Even\n", 386 | "3 is Odd\n", 387 | "4 is Even\n", 388 | "5 is Odd\n", 389 | "6 is Even\n", 390 | "7 is Odd\n", 391 | "8 is Even\n", 392 | "9 is Odd\n" 393 | ] 394 | } 395 | ], 396 | "source": [ 397 | "for item in range(1,10):\n", 398 | " print(oddEvenFun(item))" 399 | ] 400 | }, 401 | { 402 | "cell_type": "code", 403 | "execution_count": 71, 404 | "metadata": {}, 405 | "outputs": [], 406 | "source": [ 407 | "# args*\n", 408 | "\n", 409 | "# kwargs**\n" 410 | ] 411 | }, 412 | { 413 | "cell_type": "code", 414 | "execution_count": 72, 415 | "metadata": {}, 416 | "outputs": [], 417 | "source": [ 418 | "def greeting(*name):\n", 419 | " for i in name:\n", 420 | " print(\"Hi \",i)" 421 | ] 422 | }, 423 | { 424 | "cell_type": "code", 425 | "execution_count": 73, 426 | "metadata": {}, 427 | "outputs": [ 428 | { 429 | "name": "stdout", 430 | "output_type": "stream", 431 | "text": [ 432 | "Hi saikiran\n" 433 | ] 434 | } 435 | ], 436 | "source": [ 437 | "greeting(\"saikiran\")" 438 | ] 439 | }, 440 | { 441 | "cell_type": "code", 442 | "execution_count": 74, 443 | "metadata": {}, 444 | "outputs": [], 445 | "source": [ 446 | "#**Kwargs ?" 447 | ] 448 | }, 449 | { 450 | "cell_type": "code", 451 | "execution_count": 75, 452 | "metadata": {}, 453 | "outputs": [], 454 | "source": [ 455 | "def amigo(**kwargs):\n", 456 | " for key,value in kwargs.items():\n", 457 | " print(key,\" \", value)\n", 458 | " print(\" \")\n", 459 | " print(\" \")\n", 460 | " print(kwargs.get(\"location\"))" 461 | ] 462 | }, 463 | { 464 | "cell_type": "code", 465 | "execution_count": 76, 466 | "metadata": {}, 467 | "outputs": [ 468 | { 469 | "name": "stdout", 470 | "output_type": "stream", 471 | "text": [ 472 | "name Saikiran\n", 473 | "age 65\n", 474 | "location Navi Mumbai\n", 475 | " \n", 476 | " \n", 477 | "Navi Mumbai\n" 478 | ] 479 | } 480 | ], 481 | "source": [ 482 | "amigo(name = \"Saikiran\", age=\"65\", location = \"Navi Mumbai\")" 483 | ] 484 | }, 485 | { 486 | "cell_type": "code", 487 | "execution_count": 85, 488 | "metadata": {}, 489 | "outputs": [], 490 | "source": [ 491 | "def printingPaper(*papers):\n", 492 | " for paper in papers:\n", 493 | " print(paper)" 494 | ] 495 | }, 496 | { 497 | "cell_type": "code", 498 | "execution_count": 90, 499 | "metadata": {}, 500 | "outputs": [ 501 | { 502 | "name": "stdout", 503 | "output_type": "stream", 504 | "text": [ 505 | "a41\n", 506 | "a46\n", 507 | "a49\n" 508 | ] 509 | } 510 | ], 511 | "source": [ 512 | "printingPaper(\"a41\",\"a46\",\"a49\")" 513 | ] 514 | }, 515 | { 516 | "cell_type": "code", 517 | "execution_count": null, 518 | "metadata": {}, 519 | "outputs": [], 520 | "source": [] 521 | } 522 | ], 523 | "metadata": { 524 | "kernelspec": { 525 | "display_name": "Python 3", 526 | "language": "python", 527 | "name": "python3" 528 | }, 529 | "language_info": { 530 | "codemirror_mode": { 531 | "name": "ipython", 532 | "version": 3 533 | }, 534 | "file_extension": ".py", 535 | "mimetype": "text/x-python", 536 | "name": "python", 537 | "nbconvert_exporter": "python", 538 | "pygments_lexer": "ipython3", 539 | "version": "3.7.4" 540 | } 541 | }, 542 | "nbformat": 4, 543 | "nbformat_minor": 2 544 | } 545 | -------------------------------------------------------------------------------- /Batch-5/Day-5/Assignment Day 5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-5/Day-5/Assignment Day 5.pdf -------------------------------------------------------------------------------- /Batch-5/Day-5/Day 5 Notes.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# MAP, Filter and Lambda \n", 8 | "\n" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "metadata": {}, 14 | "source": [ 15 | "# Why MAP ?\n", 16 | "\n", 17 | "You are having a list of elements, you want to itereate through and pass that particular element into function, and generate another list of results \n", 18 | "\n", 19 | "Step 1 - You all are having a iterable List \n", 20 | "Step 2 - You have to send each element of the list to functions \n", 21 | "step 3 - collect all the outputs from the function and store in new list \n" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": 1, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "#Demo Function\n", 31 | "def getPowerFive(num):\n", 32 | " return num * num * num * num * num " 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": null, 38 | "metadata": {}, 39 | "outputs": [], 40 | "source": [] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 3, 45 | "metadata": {}, 46 | "outputs": [], 47 | "source": [ 48 | "# iterable Object LIST \n", 49 | "lst = [1,2,3,4,5,6,7,8,9,10]" 50 | ] 51 | }, 52 | { 53 | "cell_type": "code", 54 | "execution_count": 4, 55 | "metadata": {}, 56 | "outputs": [], 57 | "source": [ 58 | "#Approch Number 1 Trad. \n", 59 | "newLst = []\n", 60 | "for item in lst:\n", 61 | " temp = getPowerFive(item)\n", 62 | " newLst.append(temp)" 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": 5, 68 | "metadata": { 69 | "scrolled": true 70 | }, 71 | "outputs": [ 72 | { 73 | "data": { 74 | "text/plain": [ 75 | "[1, 32, 243, 1024, 3125, 7776, 16807, 32768, 59049, 100000]" 76 | ] 77 | }, 78 | "execution_count": 5, 79 | "metadata": {}, 80 | "output_type": "execute_result" 81 | } 82 | ], 83 | "source": [ 84 | "newLst" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": 6, 90 | "metadata": {}, 91 | "outputs": [], 92 | "source": [ 93 | "# Using Maps - Approch 2 \n", 94 | "newMappedList = map(getPowerFive, lst)" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "execution_count": 7, 100 | "metadata": {}, 101 | "outputs": [ 102 | { 103 | "data": { 104 | "text/plain": [ 105 | "" 106 | ] 107 | }, 108 | "execution_count": 7, 109 | "metadata": {}, 110 | "output_type": "execute_result" 111 | } 112 | ], 113 | "source": [ 114 | "newMappedList" 115 | ] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "execution_count": 8, 120 | "metadata": {}, 121 | "outputs": [ 122 | { 123 | "data": { 124 | "text/plain": [ 125 | "[1, 32, 243, 1024, 3125, 7776, 16807, 32768, 59049, 100000]" 126 | ] 127 | }, 128 | "execution_count": 8, 129 | "metadata": {}, 130 | "output_type": "execute_result" 131 | } 132 | ], 133 | "source": [ 134 | "list(newMappedList)" 135 | ] 136 | }, 137 | { 138 | "cell_type": "markdown", 139 | "metadata": {}, 140 | "source": [ 141 | "Map is used for generating new list based on old list and a function which you want to use for generating new list items, \n", 142 | "\n", 143 | "you dont need to write whole for loop and temp code, just Use Map to get all the elements of the old list mapped with function output in the new list" 144 | ] 145 | }, 146 | { 147 | "cell_type": "markdown", 148 | "metadata": {}, 149 | "source": [ 150 | "# Filter" 151 | ] 152 | }, 153 | { 154 | "cell_type": "markdown", 155 | "metadata": {}, 156 | "source": [ 157 | "Question ?? \n", 158 | "\n", 159 | "- Step 1 - you all have some iteratable object \n", 160 | "- Step 2 - You want to make a new list which contains of all the elements from first list which returns TRUE when passed to a Function \n", 161 | "- Step 3 - print that new list with only filtered elements " 162 | ] 163 | }, 164 | { 165 | "cell_type": "code", 166 | "execution_count": 13, 167 | "metadata": {}, 168 | "outputs": [], 169 | "source": [ 170 | "def isOdd(num):\n", 171 | " if num%2 == 1:\n", 172 | " return True \n", 173 | " else: \n", 174 | " return False" 175 | ] 176 | }, 177 | { 178 | "cell_type": "code", 179 | "execution_count": 15, 180 | "metadata": {}, 181 | "outputs": [], 182 | "source": [ 183 | "numList = [34,56,91,24,56,78,74,68,83,71,67,34,54,21]" 184 | ] 185 | }, 186 | { 187 | "cell_type": "code", 188 | "execution_count": 23, 189 | "metadata": {}, 190 | "outputs": [], 191 | "source": [ 192 | "#Approch number 1 - for filtering all the ODD Numbers from the List\n", 193 | "subList = []\n", 194 | "for item in numList:\n", 195 | " if isOdd(item) == True:\n", 196 | " subList.append(item) " 197 | ] 198 | }, 199 | { 200 | "cell_type": "code", 201 | "execution_count": 24, 202 | "metadata": {}, 203 | "outputs": [ 204 | { 205 | "data": { 206 | "text/plain": [ 207 | "[91, 83, 71, 67, 21]" 208 | ] 209 | }, 210 | "execution_count": 24, 211 | "metadata": {}, 212 | "output_type": "execute_result" 213 | } 214 | ], 215 | "source": [ 216 | "subList" 217 | ] 218 | }, 219 | { 220 | "cell_type": "code", 221 | "execution_count": 25, 222 | "metadata": {}, 223 | "outputs": [], 224 | "source": [ 225 | "# Approh 2 - Filtering all the odd numbers from the list \n", 226 | "subFilterList = filter(isOdd,numList)" 227 | ] 228 | }, 229 | { 230 | "cell_type": "code", 231 | "execution_count": 22, 232 | "metadata": {}, 233 | "outputs": [ 234 | { 235 | "data": { 236 | "text/plain": [ 237 | "[91, 83, 71, 67, 21]" 238 | ] 239 | }, 240 | "execution_count": 22, 241 | "metadata": {}, 242 | "output_type": "execute_result" 243 | } 244 | ], 245 | "source": [ 246 | "list(subFilterList)" 247 | ] 248 | }, 249 | { 250 | "cell_type": "markdown", 251 | "metadata": {}, 252 | "source": [ 253 | "# Lambda Exp. " 254 | ] 255 | }, 256 | { 257 | "cell_type": "markdown", 258 | "metadata": {}, 259 | "source": [ 260 | "- Lambda Expressions are annonymous functions \n", 261 | "- they can be written in one line \n", 262 | "- and these are the functions which can be used for on-the go job \n", 263 | "- you dont require to change anything in the backend for using Inline function " 264 | ] 265 | }, 266 | { 267 | "cell_type": "code", 268 | "execution_count": 26, 269 | "metadata": {}, 270 | "outputs": [], 271 | "source": [ 272 | "def isEven(num):\n", 273 | " if num%2==0:\n", 274 | " return True \n", 275 | " else:\n", 276 | " return False" 277 | ] 278 | }, 279 | { 280 | "cell_type": "code", 281 | "execution_count": 27, 282 | "metadata": {}, 283 | "outputs": [], 284 | "source": [ 285 | "def getPowerSeven(num):\n", 286 | " return num ** 7" 287 | ] 288 | }, 289 | { 290 | "cell_type": "code", 291 | "execution_count": 28, 292 | "metadata": {}, 293 | "outputs": [ 294 | { 295 | "data": { 296 | "text/plain": [ 297 | "823543" 298 | ] 299 | }, 300 | "execution_count": 28, 301 | "metadata": {}, 302 | "output_type": "execute_result" 303 | } 304 | ], 305 | "source": [ 306 | "getPowerSeven(7)" 307 | ] 308 | }, 309 | { 310 | "cell_type": "code", 311 | "execution_count": 30, 312 | "metadata": {}, 313 | "outputs": [], 314 | "source": [ 315 | "getPowerSevenV2 = lambda num: num ** 7" 316 | ] 317 | }, 318 | { 319 | "cell_type": "code", 320 | "execution_count": 31, 321 | "metadata": {}, 322 | "outputs": [ 323 | { 324 | "data": { 325 | "text/plain": [ 326 | "823543" 327 | ] 328 | }, 329 | "execution_count": 31, 330 | "metadata": {}, 331 | "output_type": "execute_result" 332 | } 333 | ], 334 | "source": [ 335 | "getPowerSevenV2(7)" 336 | ] 337 | }, 338 | { 339 | "cell_type": "code", 340 | "execution_count": 32, 341 | "metadata": {}, 342 | "outputs": [], 343 | "source": [ 344 | "lst = [45,55,65,75,85,95,15,25,35]" 345 | ] 346 | }, 347 | { 348 | "cell_type": "code", 349 | "execution_count": 33, 350 | "metadata": {}, 351 | "outputs": [], 352 | "source": [ 353 | "newSquareList = list(map(lambda num: num*num, lst))" 354 | ] 355 | }, 356 | { 357 | "cell_type": "code", 358 | "execution_count": 34, 359 | "metadata": {}, 360 | "outputs": [ 361 | { 362 | "data": { 363 | "text/plain": [ 364 | "[2025, 3025, 4225, 5625, 7225, 9025, 225, 625, 1225]" 365 | ] 366 | }, 367 | "execution_count": 34, 368 | "metadata": {}, 369 | "output_type": "execute_result" 370 | } 371 | ], 372 | "source": [ 373 | "newSquareList" 374 | ] 375 | }, 376 | { 377 | "cell_type": "code", 378 | "execution_count": 35, 379 | "metadata": {}, 380 | "outputs": [], 381 | "source": [ 382 | "numList = [34,56,91,24,56,78,74,68,83,71,67,34,54,21] " 383 | ] 384 | }, 385 | { 386 | "cell_type": "code", 387 | "execution_count": 39, 388 | "metadata": {}, 389 | "outputs": [], 390 | "source": [ 391 | "isEven = lambda num : num%2==0\n", 392 | "newFilterdEvenList=list(filter(isEven, numList))" 393 | ] 394 | }, 395 | { 396 | "cell_type": "code", 397 | "execution_count": 40, 398 | "metadata": {}, 399 | "outputs": [ 400 | { 401 | "data": { 402 | "text/plain": [ 403 | "[34, 56, 24, 56, 78, 74, 68, 34, 54]" 404 | ] 405 | }, 406 | "execution_count": 40, 407 | "metadata": {}, 408 | "output_type": "execute_result" 409 | } 410 | ], 411 | "source": [ 412 | "newFilterdEvenList" 413 | ] 414 | }, 415 | { 416 | "cell_type": "code", 417 | "execution_count": 41, 418 | "metadata": {}, 419 | "outputs": [ 420 | { 421 | "data": { 422 | "text/plain": [ 423 | "False" 424 | ] 425 | }, 426 | "execution_count": 41, 427 | "metadata": {}, 428 | "output_type": "execute_result" 429 | } 430 | ], 431 | "source": [ 432 | "isEven(97)" 433 | ] 434 | }, 435 | { 436 | "cell_type": "code", 437 | "execution_count": null, 438 | "metadata": {}, 439 | "outputs": [], 440 | "source": [] 441 | } 442 | ], 443 | "metadata": { 444 | "kernelspec": { 445 | "display_name": "Python 3", 446 | "language": "python", 447 | "name": "python3" 448 | }, 449 | "language_info": { 450 | "codemirror_mode": { 451 | "name": "ipython", 452 | "version": 3 453 | }, 454 | "file_extension": ".py", 455 | "mimetype": "text/x-python", 456 | "name": "python", 457 | "nbconvert_exporter": "python", 458 | "pygments_lexer": "ipython3", 459 | "version": "3.7.4" 460 | } 461 | }, 462 | "nbformat": 4, 463 | "nbformat_minor": 2 464 | } 465 | -------------------------------------------------------------------------------- /Batch-5/Day-6/Assignment Day 6.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-5/Day-6/Assignment Day 6.pdf -------------------------------------------------------------------------------- /Batch-5/Day-7/Assignment Day 7.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-5/Day-7/Assignment Day 7.pdf -------------------------------------------------------------------------------- /Batch-5/Day-7/Day 7 Notes.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Error handling " 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 1, 13 | "metadata": {}, 14 | "outputs": [ 15 | { 16 | "name": "stdout", 17 | "output_type": "stream", 18 | "text": [ 19 | "sai\n" 20 | ] 21 | }, 22 | { 23 | "ename": "TypeError", 24 | "evalue": "can only concatenate str (not \"int\") to str", 25 | "output_type": "error", 26 | "traceback": [ 27 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 28 | "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", 29 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"sai\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0madd\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"sai\"\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"sai\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 30 | "\u001b[0;31mTypeError\u001b[0m: can only concatenate str (not \"int\") to str" 31 | ] 32 | } 33 | ], 34 | "source": [ 35 | "print(\"sai\")\n", 36 | "\n", 37 | "add = \"sai\" + 2\n", 38 | "\n", 39 | "print(\"sai\")" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 2, 45 | "metadata": { 46 | "scrolled": true 47 | }, 48 | "outputs": [ 49 | { 50 | "ename": "ZeroDivisionError", 51 | "evalue": "division by zero", 52 | "output_type": "error", 53 | "traceback": [ 54 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 55 | "\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", 56 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdiv\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m67\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 57 | "\u001b[0;31mZeroDivisionError\u001b[0m: division by zero" 58 | ] 59 | } 60 | ], 61 | "source": [ 62 | "div = 67/0" 63 | ] 64 | }, 65 | { 66 | "cell_type": "markdown", 67 | "metadata": {}, 68 | "source": [ 69 | "# Exceptions handling \n" 70 | ] 71 | }, 72 | { 73 | "cell_type": "code", 74 | "execution_count": 15, 75 | "metadata": {}, 76 | "outputs": [ 77 | { 78 | "name": "stdout", 79 | "output_type": "stream", 80 | "text": [ 81 | "sai\n", 82 | "There was an error !!- unsupported operand type(s) for +: 'int' and 'str'\n", 83 | "sai\n" 84 | ] 85 | } 86 | ], 87 | "source": [ 88 | "print(\"sai\")\n", 89 | "\n", 90 | "try:\n", 91 | " add = 3 + \"sai\"\n", 92 | " print(add)\n", 93 | "except Exception as e:\n", 94 | " print(\"There was an error !!- \", e)\n", 95 | "\n", 96 | "print(\"sai\")" 97 | ] 98 | }, 99 | { 100 | "cell_type": "code", 101 | "execution_count": 12, 102 | "metadata": {}, 103 | "outputs": [ 104 | { 105 | "name": "stdout", 106 | "output_type": "stream", 107 | "text": [ 108 | "There was an error in the file handling \n", 109 | "Error was - not writable\n", 110 | "Hey guys, rate the session as of right now\n" 111 | ] 112 | } 113 | ], 114 | "source": [ 115 | "# WAP for writing a file\n", 116 | "\n", 117 | "file = open(\"fantasticFive.txt\",\"r\")\n", 118 | "\n", 119 | "try:\n", 120 | " file.write(\"HI Guys\")\n", 121 | "except Exception as e:\n", 122 | " print(\"There was an error in the file handling \")\n", 123 | " print(\"Error was - \", e)\n", 124 | "finally:\n", 125 | " file.close()\n", 126 | " \n", 127 | "print(\"Hey guys, rate the session as of right now\")\n" 128 | ] 129 | }, 130 | { 131 | "cell_type": "markdown", 132 | "metadata": {}, 133 | "source": [ 134 | "# Unit Testing !!!" 135 | ] 136 | }, 137 | { 138 | "cell_type": "markdown", 139 | "metadata": {}, 140 | "source": [ 141 | "- Testing is a part of software development, in which your each simple module is tested. \n", 142 | "\n", 143 | "- To make sure it is enacting the same way for it was designed \n", 144 | "\n", 145 | "- and also to make sure that our code is industry standard" 146 | ] 147 | }, 148 | { 149 | "cell_type": "markdown", 150 | "metadata": {}, 151 | "source": [ 152 | "# PyLint - \n", 153 | "\n", 154 | "for what reason Pylint is been used, ?\n", 155 | "\n", 156 | "Pylint is a Python static code analysis tool which looks for programming errors, helps enforcing a coding standard, sniffs for code smells and offers simple refactoring suggestions." 157 | ] 158 | }, 159 | { 160 | "cell_type": "code", 161 | "execution_count": 17, 162 | "metadata": {}, 163 | "outputs": [ 164 | { 165 | "name": "stdout", 166 | "output_type": "stream", 167 | "text": [ 168 | "Requirement already satisfied: pylint in /opt/anaconda3/lib/python3.7/site-packages (2.4.2)\n", 169 | "Requirement already satisfied: isort<5,>=4.2.5 in /opt/anaconda3/lib/python3.7/site-packages (from pylint) (4.3.21)\n", 170 | "Requirement already satisfied: astroid<2.4,>=2.3.0 in /opt/anaconda3/lib/python3.7/site-packages (from pylint) (2.3.1)\n", 171 | "Requirement already satisfied: mccabe<0.7,>=0.6 in /opt/anaconda3/lib/python3.7/site-packages (from pylint) (0.6.1)\n", 172 | "Requirement already satisfied: lazy-object-proxy==1.4.* in /opt/anaconda3/lib/python3.7/site-packages (from astroid<2.4,>=2.3.0->pylint) (1.4.2)\n", 173 | "Requirement already satisfied: wrapt==1.11.* in /opt/anaconda3/lib/python3.7/site-packages (from astroid<2.4,>=2.3.0->pylint) (1.11.2)\n", 174 | "Requirement already satisfied: typed-ast<1.5,>=1.4.0; implementation_name == \"cpython\" and python_version < \"3.8\" in /opt/anaconda3/lib/python3.7/site-packages (from astroid<2.4,>=2.3.0->pylint) (1.4.1)\n", 175 | "Requirement already satisfied: six==1.12 in /opt/anaconda3/lib/python3.7/site-packages (from astroid<2.4,>=2.3.0->pylint) (1.12.0)\n", 176 | "\u001b[33mWARNING: You are using pip version 20.0.2; however, version 20.1.1 is available.\n", 177 | "You should consider upgrading via the '/opt/anaconda3/bin/python -m pip install --upgrade pip' command.\u001b[0m\n" 178 | ] 179 | } 180 | ], 181 | "source": [ 182 | "!pip install pylint" 183 | ] 184 | }, 185 | { 186 | "cell_type": "code", 187 | "execution_count": 19, 188 | "metadata": {}, 189 | "outputs": [], 190 | "source": [ 191 | "# We will use Magic Function -- " 192 | ] 193 | }, 194 | { 195 | "cell_type": "code", 196 | "execution_count": 36, 197 | "metadata": {}, 198 | "outputs": [ 199 | { 200 | "name": "stdout", 201 | "output_type": "stream", 202 | "text": [ 203 | "Overwriting treebox.py\n" 204 | ] 205 | } 206 | ], 207 | "source": [ 208 | "%%writefile treebox.py\n", 209 | "'''\n", 210 | "A Simple Python program for our testing purpose\n", 211 | "'''\n", 212 | "\n", 213 | "A = 1\n", 214 | "B = 2\n", 215 | "\n", 216 | "def add(num1, num2):\n", 217 | " '''\n", 218 | " this is a Addition function, which prints the addition of two numbers\n", 219 | " '''\n", 220 | " addition = num1 + num2\n", 221 | " print(addition)\n", 222 | "\n", 223 | "add(A, B)\n" 224 | ] 225 | }, 226 | { 227 | "cell_type": "code", 228 | "execution_count": 35, 229 | "metadata": {}, 230 | "outputs": [ 231 | { 232 | "name": "stdout", 233 | "output_type": "stream", 234 | "text": [ 235 | "\r\n", 236 | "-------------------------------------------------------------------\r\n", 237 | "Your code has been rated at 10.00/10 (previous run: 8.33/10, +1.67)\r\n", 238 | "\r\n" 239 | ] 240 | } 241 | ], 242 | "source": [ 243 | "! Pylint treebox.py" 244 | ] 245 | }, 246 | { 247 | "cell_type": "code", 248 | "execution_count": 37, 249 | "metadata": {}, 250 | "outputs": [ 251 | { 252 | "name": "stdout", 253 | "output_type": "stream", 254 | "text": [ 255 | "************* Module myCode\n", 256 | "myCode.py:1:0: C0103: Module name \"myCode\" doesn't conform to snake_case naming style (invalid-name)\n", 257 | "\n", 258 | "-----------------------------------\n", 259 | "Your code has been rated at 8.33/10\n", 260 | "\n" 261 | ] 262 | } 263 | ], 264 | "source": [ 265 | "! Pylint myCode.py" 266 | ] 267 | }, 268 | { 269 | "cell_type": "markdown", 270 | "metadata": {}, 271 | "source": [ 272 | "# Unittesting " 273 | ] 274 | }, 275 | { 276 | "cell_type": "markdown", 277 | "metadata": {}, 278 | "source": [ 279 | "# What is unit testing ?\n", 280 | "\n", 281 | "- unit are the smallest possible block of our program, \n", 282 | "\n", 283 | "- like functions and other stuff, \n", 284 | "\n", 285 | "- we want to test them that they are performing the same manner what we want them to do \n", 286 | "\n", 287 | "- Then we use unit testing -- \n", 288 | "\n", 289 | "\n", 290 | "- AGENDA - to Learn How UNIT TESTIN Works !!!\n", 291 | "\n", 292 | "\n", 293 | "- Step 1 - Create a new Python File - AreaOfCircle\n", 294 | "- Step 2 - Create a UNIT-TESTING file which can test your AreaOfCircle\n", 295 | "- Step 3 - \n", 296 | "\n" 297 | ] 298 | }, 299 | { 300 | "cell_type": "code", 301 | "execution_count": null, 302 | "metadata": {}, 303 | "outputs": [], 304 | "source": [] 305 | }, 306 | { 307 | "cell_type": "code", 308 | "execution_count": 44, 309 | "metadata": {}, 310 | "outputs": [ 311 | { 312 | "name": "stdout", 313 | "output_type": "stream", 314 | "text": [ 315 | "Overwriting area_of_circle.py\n" 316 | ] 317 | } 318 | ], 319 | "source": [ 320 | "%%writefile area_of_circle.py\n", 321 | "'''\n", 322 | "this is a small python file which is used for area of circle\n", 323 | "'''\n", 324 | "def areaCircle(radius):\n", 325 | " '''\n", 326 | " this is a function for area of circle\n", 327 | " '''\n", 328 | " return 3.14*radius * radius\n" 329 | ] 330 | }, 331 | { 332 | "cell_type": "code", 333 | "execution_count": 59, 334 | "metadata": {}, 335 | "outputs": [ 336 | { 337 | "name": "stdout", 338 | "output_type": "stream", 339 | "text": [ 340 | "Overwriting circle_area_testing.py\n" 341 | ] 342 | } 343 | ], 344 | "source": [ 345 | "%%writefile circle_area_testing.py\n", 346 | "\n", 347 | "import unittest\n", 348 | "import area_of_circle\n", 349 | "\n", 350 | "class CircleTesting(unittest.TestCase):\n", 351 | " def testRadius(self): # TestCase 1\n", 352 | " temp_radius = 4\n", 353 | " result = area_of_circle.areaCircle(temp_radius)\n", 354 | " #Important line\n", 355 | " self.assertAlmostEqual(result,50.24)\n", 356 | " # THe above line checks your result from function is equal to \n", 357 | " # the manully given result, \n", 358 | " # if yes then it says test passed \n", 359 | " # if no then it says test failed\n", 360 | " \n", 361 | " def testRadiusTwo(self): # TestCase 2\n", 362 | " temp_radius = 101\n", 363 | " result = area_of_circle.areaCircle(temp_radius)\n", 364 | " self.assertAlmostEqual(result,32031.14)\n", 365 | " \n", 366 | "if __name__ == \"__main__\":\n", 367 | " unittest.main()" 368 | ] 369 | }, 370 | { 371 | "cell_type": "code", 372 | "execution_count": 60, 373 | "metadata": {}, 374 | "outputs": [ 375 | { 376 | "name": "stdout", 377 | "output_type": "stream", 378 | "text": [ 379 | "..\r\n", 380 | "----------------------------------------------------------------------\r\n", 381 | "Ran 2 tests in 0.000s\r\n", 382 | "\r\n", 383 | "OK\r\n" 384 | ] 385 | } 386 | ], 387 | "source": [ 388 | "! python circle_area_testing.py" 389 | ] 390 | }, 391 | { 392 | "cell_type": "code", 393 | "execution_count": 56, 394 | "metadata": {}, 395 | "outputs": [ 396 | { 397 | "data": { 398 | "text/plain": [ 399 | "50.24" 400 | ] 401 | }, 402 | "execution_count": 56, 403 | "metadata": {}, 404 | "output_type": "execute_result" 405 | } 406 | ], 407 | "source": [ 408 | "import area_of_circle\n", 409 | "\n", 410 | "area_of_circle.areaCircle(4)" 411 | ] 412 | }, 413 | { 414 | "cell_type": "code", 415 | "execution_count": null, 416 | "metadata": {}, 417 | "outputs": [], 418 | "source": [] 419 | } 420 | ], 421 | "metadata": { 422 | "kernelspec": { 423 | "display_name": "Python 3", 424 | "language": "python", 425 | "name": "python3" 426 | }, 427 | "language_info": { 428 | "codemirror_mode": { 429 | "name": "ipython", 430 | "version": 3 431 | }, 432 | "file_extension": ".py", 433 | "mimetype": "text/x-python", 434 | "name": "python", 435 | "nbconvert_exporter": "python", 436 | "pygments_lexer": "ipython3", 437 | "version": "3.7.4" 438 | } 439 | }, 440 | "nbformat": 4, 441 | "nbformat_minor": 2 442 | } 443 | -------------------------------------------------------------------------------- /Batch-5/Day-8/Assignment Day 8.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-5/Day-8/Assignment Day 8.pdf -------------------------------------------------------------------------------- /Batch-6/Day-2/Assignment Day 2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-6/Day-2/Assignment Day 2.pdf -------------------------------------------------------------------------------- /Batch-6/Day-3/Assignment Day 3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-6/Day-3/Assignment Day 3.pdf -------------------------------------------------------------------------------- /Batch-6/Day-4/Day 4 Assignment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-6/Day-4/Day 4 Assignment.pdf -------------------------------------------------------------------------------- /Batch-6/Day-5/Day 5 Assignment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-6/Day-5/Day 5 Assignment.pdf -------------------------------------------------------------------------------- /Batch-6/Day-6/Day 6 Assignment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-6/Day-6/Day 6 Assignment.pdf -------------------------------------------------------------------------------- /Batch-6/Day-7/Day 7 Assignment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-6/Day-7/Day 7 Assignment.pdf -------------------------------------------------------------------------------- /Batch-7/Day-2/Assignment/Day 2 Assignment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-7/Day-2/Assignment/Day 2 Assignment.pdf -------------------------------------------------------------------------------- /Batch-7/Day-3/Assignment/Day 3 Assignment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-7/Day-3/Assignment/Day 3 Assignment.pdf -------------------------------------------------------------------------------- /Batch-7/Day-4/Assignment/Day 4 Assignment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-7/Day-4/Assignment/Day 4 Assignment.pdf -------------------------------------------------------------------------------- /Batch-7/Day-4/Notes/Day 4 Notes.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "# while Loop " 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 3, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "# while loops are used for itretating thorugh the particular Conditions is not met true " 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 4, 24 | "metadata": {}, 25 | "outputs": [ 26 | { 27 | "name": "stdout", 28 | "output_type": "stream", 29 | "text": [ 30 | "Hey i am - 1\n", 31 | "Hey i am - 2\n", 32 | "Hey i am - 3\n", 33 | "Hey i am - 4\n", 34 | "Hey i am - 5\n", 35 | "Hey i am - 6\n", 36 | "Hey i am - 7\n", 37 | "Hey i am - 8\n", 38 | "Hey i am - 9\n" 39 | ] 40 | } 41 | ], 42 | "source": [ 43 | "i = 1\n", 44 | "\n", 45 | "while i<10:\n", 46 | " print(\"Hey i am -\", i)\n", 47 | " i = i+ 1" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": 7, 53 | "metadata": {}, 54 | "outputs": [ 55 | { 56 | "name": "stdout", 57 | "output_type": "stream", 58 | "text": [ 59 | "Even Number - 2\n", 60 | "Even Number - 4\n", 61 | "Even Number - 6\n", 62 | "Even Number - 8\n", 63 | "Even Number - 10\n", 64 | "Even Number - 12\n", 65 | "Even Number - 14\n", 66 | "Even Number - 16\n", 67 | "Even Number - 18\n", 68 | "Even Number - 20\n", 69 | "Even Number - 22\n", 70 | "Even Number - 24\n", 71 | "Even Number - 26\n", 72 | "Even Number - 28\n", 73 | "Even Number - 30\n", 74 | "Even Number - 32\n", 75 | "Even Number - 34\n", 76 | "Even Number - 36\n", 77 | "Even Number - 38\n", 78 | "Even Number - 40\n", 79 | "Even Number - 42\n", 80 | "Even Number - 44\n", 81 | "Even Number - 46\n", 82 | "Even Number - 48\n", 83 | "Even Number - 50\n", 84 | "Even Number - 52\n", 85 | "Even Number - 54\n", 86 | "Even Number - 56\n", 87 | "Even Number - 58\n", 88 | "Even Number - 60\n", 89 | "Even Number - 62\n", 90 | "Even Number - 64\n", 91 | "Even Number - 66\n", 92 | "Even Number - 68\n", 93 | "Even Number - 70\n", 94 | "Even Number - 72\n", 95 | "Even Number - 74\n", 96 | "Even Number - 76\n", 97 | "Even Number - 78\n", 98 | "Even Number - 80\n", 99 | "Even Number - 82\n", 100 | "Even Number - 84\n", 101 | "Even Number - 86\n", 102 | "Even Number - 88\n", 103 | "Even Number - 90\n", 104 | "Even Number - 92\n", 105 | "Even Number - 94\n", 106 | "Even Number - 96\n", 107 | "Even Number - 98\n" 108 | ] 109 | } 110 | ], 111 | "source": [ 112 | "i = 1\n", 113 | "\n", 114 | "while i < 100:\n", 115 | " if i%2==0:\n", 116 | " print(\"Even Number - \", i)\n", 117 | " i = i +1" 118 | ] 119 | }, 120 | { 121 | "cell_type": "code", 122 | "execution_count": 9, 123 | "metadata": {}, 124 | "outputs": [], 125 | "source": [ 126 | "# Break, Pass & Continue" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": 10, 132 | "metadata": {}, 133 | "outputs": [ 134 | { 135 | "name": "stdout", 136 | "output_type": "stream", 137 | "text": [ 138 | "Object `used` not found.\n" 139 | ] 140 | } 141 | ], 142 | "source": [ 143 | "# Break - \n", 144 | "\n", 145 | "#Where is BREAK Keyword used?\n", 146 | "\n", 147 | "#Break is used for breaking a particular loop " 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": 17, 153 | "metadata": {}, 154 | "outputs": [ 155 | { 156 | "name": "stdout", 157 | "output_type": "stream", 158 | "text": [ 159 | "Enter the input Yes or NO (y/n)-f\n", 160 | "KEep on asking for holiday\n", 161 | "Enter the input Yes or NO (y/n)-n\n", 162 | "KEep on asking for holiday\n", 163 | "Enter the input Yes or NO (y/n)-n\n", 164 | "KEep on asking for holiday\n", 165 | "Enter the input Yes or NO (y/n)-n\n", 166 | "KEep on asking for holiday\n", 167 | "Enter the input Yes or NO (y/n)-n\n", 168 | "KEep on asking for holiday\n", 169 | "Enter the input Yes or NO (y/n)-n\n", 170 | "KEep on asking for holiday\n", 171 | "Enter the input Yes or NO (y/n)-n\n", 172 | "KEep on asking for holiday\n", 173 | "Enter the input Yes or NO (y/n)-y\n", 174 | "KEep on asking for holiday\n", 175 | "Done approved \n" 176 | ] 177 | } 178 | ], 179 | "source": [ 180 | "char = \"n\"\n", 181 | "\n", 182 | "char.lower()\n", 183 | "\n", 184 | "while char.lower() != 'y':\n", 185 | " char = input(\"Enter the input Yes or NO (y/n)-\")\n", 186 | " print(\"KEep on asking for holiday\")\n", 187 | "else:\n", 188 | " print(\"Done approved \")" 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": 18, 194 | "metadata": {}, 195 | "outputs": [], 196 | "source": [ 197 | "#break is used for breaking the loop \n", 198 | "\n" 199 | ] 200 | }, 201 | { 202 | "cell_type": "code", 203 | "execution_count": 19, 204 | "metadata": {}, 205 | "outputs": [ 206 | { 207 | "name": "stdout", 208 | "output_type": "stream", 209 | "text": [ 210 | "1\n", 211 | "2\n", 212 | "3\n", 213 | "4\n", 214 | "5\n" 215 | ] 216 | } 217 | ], 218 | "source": [ 219 | "for i in range(1,10):\n", 220 | " print(i)\n", 221 | " if i== 5:\n", 222 | " break" 223 | ] 224 | }, 225 | { 226 | "cell_type": "code", 227 | "execution_count": 20, 228 | "metadata": {}, 229 | "outputs": [ 230 | { 231 | "name": "stdout", 232 | "output_type": "stream", 233 | "text": [ 234 | "1\n", 235 | "HEY I AM SAI And teaching u guys python \n", 236 | "2\n", 237 | "HEY I AM SAI And teaching u guys python \n", 238 | "3\n", 239 | "HEY I AM SAI And teaching u guys python \n", 240 | "4\n", 241 | "HEY I AM SAI And teaching u guys python \n", 242 | "5\n", 243 | "6\n", 244 | "HEY I AM SAI And teaching u guys python \n", 245 | "7\n", 246 | "HEY I AM SAI And teaching u guys python \n", 247 | "8\n", 248 | "HEY I AM SAI And teaching u guys python \n", 249 | "9\n", 250 | "HEY I AM SAI And teaching u guys python \n" 251 | ] 252 | } 253 | ], 254 | "source": [ 255 | "# Continue - is used for skipping the closed Loop \n", 256 | "for i in range(1,10):\n", 257 | " print(i)\n", 258 | " if i== 5:\n", 259 | " continue\n", 260 | " print(\"HEY I AM SAI And teaching u guys python \")" 261 | ] 262 | }, 263 | { 264 | "cell_type": "code", 265 | "execution_count": 24, 266 | "metadata": {}, 267 | "outputs": [], 268 | "source": [ 269 | "# pass: Does nothing at all nd is been used as placeholder \n", 270 | "\n", 271 | "i = 10 \n", 272 | "\n", 273 | "for i in range(100):\n", 274 | " pass" 275 | ] 276 | }, 277 | { 278 | "cell_type": "markdown", 279 | "metadata": {}, 280 | "source": [ 281 | "# File Handling ?" 282 | ] 283 | }, 284 | { 285 | "cell_type": "code", 286 | "execution_count": 42, 287 | "metadata": {}, 288 | "outputs": [], 289 | "source": [ 290 | "# Create a File, Open that File and Write to that file \n", 291 | "file = open(\"letsupgrade.txt\",\"w\")\n", 292 | "file.write(\"Hey Guys I Hope you will meet me on Monday\")\n", 293 | "file.close()" 294 | ] 295 | }, 296 | { 297 | "cell_type": "code", 298 | "execution_count": 43, 299 | "metadata": {}, 300 | "outputs": [ 301 | { 302 | "name": "stdout", 303 | "output_type": "stream", 304 | "text": [ 305 | "Hey Guys I Hope you will meet me on Monday\n" 306 | ] 307 | } 308 | ], 309 | "source": [ 310 | "# Read fromt the File we created \n", 311 | "\n", 312 | "file = open(\"letsupgrade.txt\",\"r\")\n", 313 | "fileData = file.read()\n", 314 | "print(fileData)\n", 315 | "file.close()" 316 | ] 317 | }, 318 | { 319 | "cell_type": "code", 320 | "execution_count": 44, 321 | "metadata": {}, 322 | "outputs": [], 323 | "source": [ 324 | "# Lets Append data to the File \n", 325 | "\n", 326 | "file = open(\"letsupgrade.txt\",\"a\")\n", 327 | "file.write(\"\\nRate today class as compared to rest out of 5\")\n", 328 | "file.close()" 329 | ] 330 | }, 331 | { 332 | "cell_type": "code", 333 | "execution_count": 39, 334 | "metadata": {}, 335 | "outputs": [], 336 | "source": [ 337 | "# For reading and writing together we use r+\n", 338 | "file = open(\"letsupgrade.txt\",\"r+\")\n", 339 | "file.write(\"Hey Guys !!!\")\n", 340 | "file.close()" 341 | ] 342 | }, 343 | { 344 | "cell_type": "code", 345 | "execution_count": null, 346 | "metadata": {}, 347 | "outputs": [], 348 | "source": [] 349 | } 350 | ], 351 | "metadata": { 352 | "kernelspec": { 353 | "display_name": "Python 3", 354 | "language": "python", 355 | "name": "python3" 356 | }, 357 | "language_info": { 358 | "codemirror_mode": { 359 | "name": "ipython", 360 | "version": 3 361 | }, 362 | "file_extension": ".py", 363 | "mimetype": "text/x-python", 364 | "name": "python", 365 | "nbconvert_exporter": "python", 366 | "pygments_lexer": "ipython3", 367 | "version": "3.7.4" 368 | } 369 | }, 370 | "nbformat": 4, 371 | "nbformat_minor": 2 372 | } 373 | -------------------------------------------------------------------------------- /Batch-7/Day-5/Assignment/Day 5 Assignment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-7/Day-5/Assignment/Day 5 Assignment.pdf -------------------------------------------------------------------------------- /Batch-7/Day-6/Assignments/Assignment Day 6.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-7/Day-6/Assignments/Assignment Day 6.pdf -------------------------------------------------------------------------------- /Batch-7/Day-6/Notes/Day 6 .ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "data": { 10 | "text/plain": [ 11 | "'sai@letsupgrade.in'" 12 | ] 13 | }, 14 | "execution_count": 1, 15 | "metadata": {}, 16 | "output_type": "execute_result" 17 | } 18 | ], 19 | "source": [ 20 | "\"sai@letsupgrade.in\"" 21 | ] 22 | }, 23 | { 24 | "cell_type": "markdown", 25 | "metadata": {}, 26 | "source": [ 27 | "# OOPs" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": 3, 33 | "metadata": {}, 34 | "outputs": [], 35 | "source": [ 36 | "class animal():\n", 37 | " def __init__(self,name,animalType,legs,sound,eat):\n", 38 | " self.name = name \n", 39 | " self.animalType = animalType\n", 40 | " self.legs = legs\n", 41 | " self.sound = sound\n", 42 | " self.eat = eat\n", 43 | " \n", 44 | " def getDetails(self):\n", 45 | " print(\"name \",self.name)\n", 46 | " print(\"animal type\", self.animalType)\n", 47 | " print(\"legs \",self.legs)\n", 48 | " print(\"sound \",self.sound)\n", 49 | " print(\"eats - \",self.eat)" 50 | ] 51 | }, 52 | { 53 | "cell_type": "code", 54 | "execution_count": 4, 55 | "metadata": {}, 56 | "outputs": [], 57 | "source": [ 58 | "pug = animal(\"dolly\",\"pug - dog\", 4, \" Bow Bow\", \"veg + non veg\")" 59 | ] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "execution_count": 5, 64 | "metadata": {}, 65 | "outputs": [ 66 | { 67 | "name": "stdout", 68 | "output_type": "stream", 69 | "text": [ 70 | "name dolly\n", 71 | "animal type pug - dog\n", 72 | "legs 4\n", 73 | "sound Bow Bow\n", 74 | "eats - veg + non veg\n" 75 | ] 76 | } 77 | ], 78 | "source": [ 79 | "pug.getDetails()" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": 6, 85 | "metadata": {}, 86 | "outputs": [ 87 | { 88 | "data": { 89 | "text/plain": [ 90 | "'pug - dog'" 91 | ] 92 | }, 93 | "execution_count": 6, 94 | "metadata": {}, 95 | "output_type": "execute_result" 96 | } 97 | ], 98 | "source": [ 99 | "pug.animalType" 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "execution_count": 7, 105 | "metadata": {}, 106 | "outputs": [ 107 | { 108 | "data": { 109 | "text/plain": [ 110 | "'veg + non veg'" 111 | ] 112 | }, 113 | "execution_count": 7, 114 | "metadata": {}, 115 | "output_type": "execute_result" 116 | } 117 | ], 118 | "source": [ 119 | "pug.eat" 120 | ] 121 | }, 122 | { 123 | "cell_type": "markdown", 124 | "metadata": {}, 125 | "source": [ 126 | "# Errors & Exceptional Handling " 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": 9, 132 | "metadata": {}, 133 | "outputs": [ 134 | { 135 | "ename": "SyntaxError", 136 | "evalue": "EOL while scanning string literal (, line 1)", 137 | "output_type": "error", 138 | "traceback": [ 139 | "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m print(\"r\"\"t)\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m EOL while scanning string literal\n" 140 | ] 141 | } 142 | ], 143 | "source": [ 144 | "print(\"r\"\"t)" 145 | ] 146 | }, 147 | { 148 | "cell_type": "code", 149 | "execution_count": 13, 150 | "metadata": {}, 151 | "outputs": [ 152 | { 153 | "ename": "ZeroDivisionError", 154 | "evalue": "division by zero", 155 | "output_type": "error", 156 | "traceback": [ 157 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 158 | "\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", 159 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m9\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mb\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 160 | "\u001b[0;31mZeroDivisionError\u001b[0m: division by zero" 161 | ] 162 | } 163 | ], 164 | "source": [ 165 | "a = 0\n", 166 | "b = 9\n", 167 | "\n", 168 | "b/0" 169 | ] 170 | }, 171 | { 172 | "cell_type": "code", 173 | "execution_count": 14, 174 | "metadata": {}, 175 | "outputs": [ 176 | { 177 | "ename": "UnsupportedOperation", 178 | "evalue": "not writable", 179 | "output_type": "error", 180 | "traceback": [ 181 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 182 | "\u001b[0;31mUnsupportedOperation\u001b[0m Traceback (most recent call last)", 183 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mfile\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"letsupgrade.txt\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\"r\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mfile\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwrite\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"HI\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mfile\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mclose\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 184 | "\u001b[0;31mUnsupportedOperation\u001b[0m: not writable" 185 | ] 186 | } 187 | ], 188 | "source": [ 189 | "file = open(\"letsupgrade.txt\",\"r\")\n", 190 | "file.write(\"HI\")\n", 191 | "file.close()" 192 | ] 193 | }, 194 | { 195 | "cell_type": "markdown", 196 | "metadata": {}, 197 | "source": [ 198 | "# Exception Handling " 199 | ] 200 | }, 201 | { 202 | "cell_type": "code", 203 | "execution_count": 16, 204 | "metadata": {}, 205 | "outputs": [ 206 | { 207 | "name": "stdout", 208 | "output_type": "stream", 209 | "text": [ 210 | "Divide by ZERO\n" 211 | ] 212 | } 213 | ], 214 | "source": [ 215 | "try:\n", 216 | " 5/0\n", 217 | "except :\n", 218 | " print(\"Divide by ZERO\")" 219 | ] 220 | }, 221 | { 222 | "cell_type": "code", 223 | "execution_count": 19, 224 | "metadata": {}, 225 | "outputs": [ 226 | { 227 | "name": "stdout", 228 | "output_type": "stream", 229 | "text": [ 230 | "division by zero\n" 231 | ] 232 | } 233 | ], 234 | "source": [ 235 | "try :\n", 236 | " 5/0\n", 237 | "except Exception as e:\n", 238 | " print(e)" 239 | ] 240 | }, 241 | { 242 | "cell_type": "code", 243 | "execution_count": 25, 244 | "metadata": {}, 245 | "outputs": [ 246 | { 247 | "name": "stdout", 248 | "output_type": "stream", 249 | "text": [ 250 | "not writable\n", 251 | "HEY I WILL EXECUTE WHT so ever it may be \n" 252 | ] 253 | } 254 | ], 255 | "source": [ 256 | "try :\n", 257 | " file = open(\"letsupgrade.txt\",\"r\")\n", 258 | " file.write(\"HI\")\n", 259 | " file.close()\n", 260 | " print(\"Success\")\n", 261 | "except Exception as e:\n", 262 | " print(e)\n", 263 | "finally:\n", 264 | " print(\"HEY I WILL EXECUTE WHT so ever it may be \")" 265 | ] 266 | }, 267 | { 268 | "cell_type": "code", 269 | "execution_count": null, 270 | "metadata": {}, 271 | "outputs": [], 272 | "source": [] 273 | } 274 | ], 275 | "metadata": { 276 | "kernelspec": { 277 | "display_name": "Python 3", 278 | "language": "python", 279 | "name": "python3" 280 | }, 281 | "language_info": { 282 | "codemirror_mode": { 283 | "name": "ipython", 284 | "version": 3 285 | }, 286 | "file_extension": ".py", 287 | "mimetype": "text/x-python", 288 | "name": "python", 289 | "nbconvert_exporter": "python", 290 | "pygments_lexer": "ipython3", 291 | "version": "3.7.4" 292 | } 293 | }, 294 | "nbformat": 4, 295 | "nbformat_minor": 2 296 | } 297 | -------------------------------------------------------------------------------- /Batch-7/Day-6/Silver Project/Silver Project .ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 39, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "def takePlayerInput():\n", 10 | " player = \"blank\"\n", 11 | " while not( player.lower() == \"r\" or player.lower() == \"p\" or player.lower() == \"s\") :\n", 12 | " player = input(\"Please Enter your input out of - R | P | S = \")\n", 13 | " return player.lower()" 14 | ] 15 | }, 16 | { 17 | "cell_type": "code", 18 | "execution_count": 41, 19 | "metadata": {}, 20 | "outputs": [ 21 | { 22 | "name": "stdout", 23 | "output_type": "stream", 24 | "text": [ 25 | "Please Enter your input out of - R | P | S = q\n", 26 | "Please Enter your input out of - R | P | S = v\n", 27 | "Please Enter your input out of - R | P | S = r\n" 28 | ] 29 | }, 30 | { 31 | "data": { 32 | "text/plain": [ 33 | "'r'" 34 | ] 35 | }, 36 | "execution_count": 41, 37 | "metadata": {}, 38 | "output_type": "execute_result" 39 | } 40 | ], 41 | "source": [ 42 | "takePlayerInput()" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 42, 48 | "metadata": {}, 49 | "outputs": [], 50 | "source": [ 51 | "import random \n", 52 | "\n", 53 | "def getBotInput():\n", 54 | " lst = ['r','s','p']\n", 55 | " return random.choice(lst)" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": 45, 61 | "metadata": {}, 62 | "outputs": [ 63 | { 64 | "data": { 65 | "text/plain": [ 66 | "'r'" 67 | ] 68 | }, 69 | "execution_count": 45, 70 | "metadata": {}, 71 | "output_type": "execute_result" 72 | } 73 | ], 74 | "source": [ 75 | "getBotInput()" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": 22, 81 | "metadata": {}, 82 | "outputs": [], 83 | "source": [ 84 | "def checkWinner(player,bot):\n", 85 | " if player == 'r' and bot == \"r\":\n", 86 | " return \"draw\"\n", 87 | " elif player == \"r\" and bot == \"p\":\n", 88 | " return \"bot\"\n", 89 | " elif player == \"r\" and bot == \"s\":\n", 90 | " return \"player\"\n", 91 | " elif player == \"p\" and bot == \"s\":\n", 92 | " return \"bot\"\n", 93 | " elif player == \"p\" and bot == \"r\":\n", 94 | " return \"player\"\n", 95 | " elif player == \"p\" and bot == \"p\":\n", 96 | " return \"draw\"\n", 97 | " elif player == \"s\" and bot == \"r\":\n", 98 | " return \"bot\"\n", 99 | " elif player == \"s\" and bot == \"p\":\n", 100 | " return \"player\"\n", 101 | " elif player == \"s\" and bot == \"s\":\n", 102 | " return \"draw\"\n", 103 | " else:\n", 104 | " return \"draw\"" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": 27, 110 | "metadata": {}, 111 | "outputs": [ 112 | { 113 | "data": { 114 | "text/plain": [ 115 | "'bot'" 116 | ] 117 | }, 118 | "execution_count": 27, 119 | "metadata": {}, 120 | "output_type": "execute_result" 121 | } 122 | ], 123 | "source": [ 124 | "checkWinner(player = \"r\",bot = \"p\")" 125 | ] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "execution_count": 36, 130 | "metadata": {}, 131 | "outputs": [], 132 | "source": [ 133 | "def rockPaperScissor():\n", 134 | " endTheGame = \"n\"\n", 135 | " player_score = 0 \n", 136 | " bot_score = 0\n", 137 | " while endTheGame.lower() != \"y\":\n", 138 | " ply = takePlayerInput()\n", 139 | " bt = getBotInput()\n", 140 | " print('Bot Entered - ', bt)\n", 141 | " print(\" \")\n", 142 | " winner = checkWinner(player = ply, bot = bt)\n", 143 | " print(\" Winner is - \", winner)\n", 144 | " print(\" \")\n", 145 | " if winner == \"player\":\n", 146 | " player_score += 2\n", 147 | " elif winner == \"bot\":\n", 148 | " bot_score += 2\n", 149 | " else :\n", 150 | " player_score += 1\n", 151 | " bot_score += 1\n", 152 | " \n", 153 | " print(\"--Score board--\")\n", 154 | " print(\"PLAYER \",player_score)\n", 155 | " print(\"Bot ---\",bot_score)\n", 156 | " print(\" \")\n", 157 | " endTheGame = input(\"You want to end Y/N - \")\n", 158 | " " 159 | ] 160 | }, 161 | { 162 | "cell_type": "code", 163 | "execution_count": 37, 164 | "metadata": {}, 165 | "outputs": [ 166 | { 167 | "name": "stdout", 168 | "output_type": "stream", 169 | "text": [ 170 | "Please Enter your input out of - R | P | S = r\n", 171 | "Bot Entered - r\n", 172 | " \n", 173 | " Winner is - draw\n", 174 | " \n", 175 | "----Score board ----\n", 176 | "---PLAYER ----- 1\n", 177 | "---Bot -------- 1\n", 178 | " \n", 179 | "You want to end Y/N - n\n", 180 | "Please Enter your input out of - R | P | S = r\n", 181 | "Bot Entered - p\n", 182 | " \n", 183 | " Winner is - bot\n", 184 | " \n", 185 | "----Score board ----\n", 186 | "---PLAYER ----- 1\n", 187 | "---Bot -------- 3\n", 188 | " \n", 189 | "You want to end Y/N - y\n" 190 | ] 191 | } 192 | ], 193 | "source": [ 194 | "rockPaperScissor()" 195 | ] 196 | }, 197 | { 198 | "cell_type": "code", 199 | "execution_count": null, 200 | "metadata": {}, 201 | "outputs": [], 202 | "source": [] 203 | } 204 | ], 205 | "metadata": { 206 | "kernelspec": { 207 | "display_name": "Python 3", 208 | "language": "python", 209 | "name": "python3" 210 | }, 211 | "language_info": { 212 | "codemirror_mode": { 213 | "name": "ipython", 214 | "version": 3 215 | }, 216 | "file_extension": ".py", 217 | "mimetype": "text/x-python", 218 | "name": "python", 219 | "nbconvert_exporter": "python", 220 | "pygments_lexer": "ipython3", 221 | "version": "3.7.4" 222 | } 223 | }, 224 | "nbformat": 4, 225 | "nbformat_minor": 2 226 | } 227 | -------------------------------------------------------------------------------- /Batch-7/Day-7/Notes/Day 7 - Python .ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Day 7 Agenda \n", 8 | "\n", 9 | "1. OOPs - inheritance and Polymorphism\n", 10 | "2. Libraries and Packages \n" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 37, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "# Parent Class \n", 20 | "class animal():\n", 21 | " def __init__(self,eat, talk, breed):\n", 22 | " self.eat = eat\n", 23 | " self.talk = talk\n", 24 | " self.breed = breed\n", 25 | " def getAnimal(self):\n", 26 | " print(\"Breed - \", self.breed)\n", 27 | " print(\"Eats - \", self.eat)\n", 28 | " print(\"Talks - \",self.talk)\n", 29 | " \n", 30 | " def setLegs(self):\n", 31 | " raise NotImplementedError(\"Hey We need you to implement Set Legs in Child Class \")" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": 42, 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [ 40 | "# Child Class \n", 41 | "class dog(animal):\n", 42 | " def __init__(self, name):\n", 43 | " animal.__init__(self,\"Carnivores\", \"Bow Bow\",\"Dog - Bulldog\")\n", 44 | " self.name = name\n", 45 | " def getName(self):\n", 46 | " print(self.name)\n", 47 | " def setLegs(self):\n", 48 | " print(\"Dog has 4 legs\")" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 43, 54 | "metadata": {}, 55 | "outputs": [], 56 | "source": [ 57 | "tommy = dog(\"Tommy\")" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 44, 63 | "metadata": {}, 64 | "outputs": [ 65 | { 66 | "name": "stdout", 67 | "output_type": "stream", 68 | "text": [ 69 | "Dog has 4 legs\n" 70 | ] 71 | } 72 | ], 73 | "source": [ 74 | "tommy.setLegs()" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": 45, 80 | "metadata": {}, 81 | "outputs": [], 82 | "source": [ 83 | "class cat(animal):\n", 84 | " def __init__(self,name):\n", 85 | " animal.__init__(self,\"Fish\",\"Meow\",\"cat\" )\n", 86 | " self.name = name \n", 87 | " def getCatName(self):\n", 88 | " print(self.name)\n", 89 | " def setLegs(self):\n", 90 | " print(\"Cat has 4 Legs\")" 91 | ] 92 | }, 93 | { 94 | "cell_type": "code", 95 | "execution_count": 46, 96 | "metadata": {}, 97 | "outputs": [], 98 | "source": [ 99 | "mino = cat(\"mino\")" 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "execution_count": 47, 105 | "metadata": {}, 106 | "outputs": [ 107 | { 108 | "name": "stdout", 109 | "output_type": "stream", 110 | "text": [ 111 | "Breed - cat\n", 112 | "Eats - Fish\n", 113 | "Talks - Meow\n" 114 | ] 115 | } 116 | ], 117 | "source": [ 118 | "mino.getAnimal()" 119 | ] 120 | }, 121 | { 122 | "cell_type": "code", 123 | "execution_count": 48, 124 | "metadata": {}, 125 | "outputs": [ 126 | { 127 | "name": "stdout", 128 | "output_type": "stream", 129 | "text": [ 130 | "Cat has 4 Legs\n" 131 | ] 132 | } 133 | ], 134 | "source": [ 135 | "mino.setLegs()" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": 24, 141 | "metadata": {}, 142 | "outputs": [], 143 | "source": [ 144 | "# Polymorphism " 145 | ] 146 | }, 147 | { 148 | "cell_type": "code", 149 | "execution_count": 27, 150 | "metadata": {}, 151 | "outputs": [], 152 | "source": [ 153 | "# Same name but different tasks \n" 154 | ] 155 | }, 156 | { 157 | "cell_type": "code", 158 | "execution_count": 28, 159 | "metadata": {}, 160 | "outputs": [ 161 | { 162 | "name": "stdout", 163 | "output_type": "stream", 164 | "text": [ 165 | "Jambo African Elephant Says D. Trump\n", 166 | "Alexandar percheron Says Tarun\n" 167 | ] 168 | } 169 | ], 170 | "source": [ 171 | "class Animal():\n", 172 | " def __init__(self,name,breed):\n", 173 | " self.name = name \n", 174 | " self.breed = breed\n", 175 | " \n", 176 | " def speak(self):\n", 177 | " raise NotImplementedError(\"Sub Class Must Implement Speak Method\")\n", 178 | " \n", 179 | "\n", 180 | "class Elephant(Animal):\n", 181 | " def speak(self):\n", 182 | " return self.name + self.breed + ' Says D. Trump'\n", 183 | "\n", 184 | "\n", 185 | "class Horse(Animal):\n", 186 | " def speak(self):\n", 187 | " return self.name + self.breed+ ' Says Tarun'\n", 188 | " \n", 189 | "Jambo = Elephant('Jambo',' African Elephant')\n", 190 | "Alexandar = Horse('Alexandar',' percheron')\n", 191 | "\n", 192 | "print(Jambo.speak())\n", 193 | "print(Alexandar.speak())" 194 | ] 195 | }, 196 | { 197 | "cell_type": "code", 198 | "execution_count": 29, 199 | "metadata": {}, 200 | "outputs": [], 201 | "source": [ 202 | "class Animal():\n", 203 | " def __init__(self,name,breed):\n", 204 | " self.name = name \n", 205 | " self.breed = breed\n", 206 | " \n", 207 | " def speak(self):\n", 208 | " raise NotImplementedError(\"Sub Class Must Implement Speak Method\")" 209 | ] 210 | }, 211 | { 212 | "cell_type": "code", 213 | "execution_count": 58, 214 | "metadata": {}, 215 | "outputs": [], 216 | "source": [ 217 | "class shape():\n", 218 | " def __init__(self, name):\n", 219 | " self.name = name\n", 220 | " def area(self):\n", 221 | " raise NotImplementedError(\"Hey Define a Area function for this class\")" 222 | ] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "execution_count": 63, 227 | "metadata": {}, 228 | "outputs": [], 229 | "source": [ 230 | "class circle(shape):\n", 231 | " def __init__ (self, radius):\n", 232 | " shape.__init__(self,\"circle\")\n", 233 | " self.radius = radius\n", 234 | " def area(self):\n", 235 | " print(\"Area of Circle - \", 3.14*self.radius*self.radius)" 236 | ] 237 | }, 238 | { 239 | "cell_type": "code", 240 | "execution_count": 68, 241 | "metadata": {}, 242 | "outputs": [], 243 | "source": [ 244 | "class square(shape):\n", 245 | " def __init__ (self, sides):\n", 246 | " shape.__init__(self,\"Square\")\n", 247 | " self.sides = sides\n", 248 | " def area(self):\n", 249 | " print(\"Area of Square - \", self.sides*self.sides)" 250 | ] 251 | }, 252 | { 253 | "cell_type": "code", 254 | "execution_count": 69, 255 | "metadata": {}, 256 | "outputs": [], 257 | "source": [ 258 | "abc = square(4)" 259 | ] 260 | }, 261 | { 262 | "cell_type": "code", 263 | "execution_count": 70, 264 | "metadata": {}, 265 | "outputs": [ 266 | { 267 | "name": "stdout", 268 | "output_type": "stream", 269 | "text": [ 270 | "Area of Square - 16\n" 271 | ] 272 | } 273 | ], 274 | "source": [ 275 | "abc.area()" 276 | ] 277 | }, 278 | { 279 | "cell_type": "markdown", 280 | "metadata": {}, 281 | "source": [ 282 | "# Modules And Packages " 283 | ] 284 | }, 285 | { 286 | "cell_type": "code", 287 | "execution_count": null, 288 | "metadata": {}, 289 | "outputs": [], 290 | "source": [] 291 | } 292 | ], 293 | "metadata": { 294 | "kernelspec": { 295 | "display_name": "Python 3", 296 | "language": "python", 297 | "name": "python3" 298 | }, 299 | "language_info": { 300 | "codemirror_mode": { 301 | "name": "ipython", 302 | "version": 3 303 | }, 304 | "file_extension": ".py", 305 | "mimetype": "text/x-python", 306 | "name": "python", 307 | "nbconvert_exporter": "python", 308 | "pygments_lexer": "ipython3", 309 | "version": "3.7.4" 310 | } 311 | }, 312 | "nbformat": 4, 313 | "nbformat_minor": 2 314 | } 315 | -------------------------------------------------------------------------------- /Batch-7/Day-8/Assignment/Assignment Day 8.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-7/Day-8/Assignment/Assignment Day 8.pdf -------------------------------------------------------------------------------- /Batch-7/Day-9/Assignment/Assignment Day 9.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LetsUpgrade/Python-Essentials/94a49e7ba959e005afc9f19e4ca8d72c2d8468b1/Batch-7/Day-9/Assignment/Assignment Day 9.pdf -------------------------------------------------------------------------------- /Batch-7/Day-9/Notes/Day 9 Notes.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Unit testing ?" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "LetsUpgrade.in/hack" 15 | ] 16 | }, 17 | { 18 | "cell_type": "raw", 19 | "metadata": {}, 20 | "source": [ 21 | "Unit testing means, testing a peice of code before it is going live in \n", 22 | "any place, and testing it with different use cases, \n" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": 1, 28 | "metadata": {}, 29 | "outputs": [], 30 | "source": [ 31 | "# PyLint " 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": 2, 37 | "metadata": {}, 38 | "outputs": [ 39 | { 40 | "name": "stdout", 41 | "output_type": "stream", 42 | "text": [ 43 | "Requirement already satisfied: pylint in /opt/anaconda3/lib/python3.7/site-packages (2.4.2)\n", 44 | "Requirement already satisfied: isort<5,>=4.2.5 in /opt/anaconda3/lib/python3.7/site-packages (from pylint) (4.3.21)\n", 45 | "Requirement already satisfied: mccabe<0.7,>=0.6 in /opt/anaconda3/lib/python3.7/site-packages (from pylint) (0.6.1)\n", 46 | "Requirement already satisfied: astroid<2.4,>=2.3.0 in /opt/anaconda3/lib/python3.7/site-packages (from pylint) (2.3.1)\n", 47 | "Requirement already satisfied: lazy-object-proxy==1.4.* in /opt/anaconda3/lib/python3.7/site-packages (from astroid<2.4,>=2.3.0->pylint) (1.4.2)\n", 48 | "Requirement already satisfied: typed-ast<1.5,>=1.4.0; implementation_name == \"cpython\" and python_version < \"3.8\" in /opt/anaconda3/lib/python3.7/site-packages (from astroid<2.4,>=2.3.0->pylint) (1.4.1)\n", 49 | "Requirement already satisfied: wrapt==1.11.* in /opt/anaconda3/lib/python3.7/site-packages (from astroid<2.4,>=2.3.0->pylint) (1.11.2)\n", 50 | "Requirement already satisfied: six==1.12 in /opt/anaconda3/lib/python3.7/site-packages (from astroid<2.4,>=2.3.0->pylint) (1.12.0)\n", 51 | "\u001b[33mWARNING: You are using pip version 20.0.2; however, version 20.2.3 is available.\n", 52 | "You should consider upgrading via the '/opt/anaconda3/bin/python -m pip install --upgrade pip' command.\u001b[0m\n" 53 | ] 54 | } 55 | ], 56 | "source": [ 57 | "! pip install pylint" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 25, 63 | "metadata": {}, 64 | "outputs": [ 65 | { 66 | "name": "stdout", 67 | "output_type": "stream", 68 | "text": [ 69 | "Overwriting some_code.py\n" 70 | ] 71 | } 72 | ], 73 | "source": [ 74 | "%%writefile some_code.py\n", 75 | "'''\n", 76 | "It is a peice of non-sense example code\n", 77 | "'''\n", 78 | "A = 1\n", 79 | "B = 2\n", 80 | "\n", 81 | "def addition(num1, num2):\n", 82 | " '''\n", 83 | " Hey this is a Simple Addition Fuction\n", 84 | " '''\n", 85 | " print(num1 + num2)\n", 86 | "\n", 87 | "addition(A, B)" 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": 26, 93 | "metadata": {}, 94 | "outputs": [ 95 | { 96 | "name": "stdout", 97 | "output_type": "stream", 98 | "text": [ 99 | "\r\n", 100 | "--------------------------------------------------------------------\r\n", 101 | "Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)\r\n", 102 | "\r\n" 103 | ] 104 | } 105 | ], 106 | "source": [ 107 | "! pylint \"some_code.py\"" 108 | ] 109 | }, 110 | { 111 | "cell_type": "markdown", 112 | "metadata": {}, 113 | "source": [ 114 | "# Steps \n", 115 | "\n", 116 | "1. YOU GUYS Develope a Program \n", 117 | "2. Now you want to test each function of the program \n", 118 | "3. How to test it ?\n", 119 | "4. We will use UNITTESTING to do that \n", 120 | "5. How to make unitesting ?\n", 121 | "6. Make another python file \n", 122 | "7. then run that Python file, so you will get it " 123 | ] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": 4, 128 | "metadata": {}, 129 | "outputs": [ 130 | { 131 | "name": "stdout", 132 | "output_type": "stream", 133 | "text": [ 134 | "Overwriting capitalizeText.py\n" 135 | ] 136 | } 137 | ], 138 | "source": [ 139 | "%%writefile capitalizeText.py\n", 140 | "\n", 141 | "def capText(string_To_Cap):\n", 142 | " return string_To_Cap.title()" 143 | ] 144 | }, 145 | { 146 | "cell_type": "code", 147 | "execution_count": 6, 148 | "metadata": {}, 149 | "outputs": [ 150 | { 151 | "data": { 152 | "text/plain": [ 153 | "'Sai'" 154 | ] 155 | }, 156 | "execution_count": 6, 157 | "metadata": {}, 158 | "output_type": "execute_result" 159 | } 160 | ], 161 | "source": [ 162 | "import capitalizeText\n", 163 | "\n", 164 | "capitalizeText.capText(\"sai\")\n" 165 | ] 166 | }, 167 | { 168 | "cell_type": "code", 169 | "execution_count": 20, 170 | "metadata": {}, 171 | "outputs": [ 172 | { 173 | "name": "stdout", 174 | "output_type": "stream", 175 | "text": [ 176 | "Overwriting testCapText.py\n" 177 | ] 178 | } 179 | ], 180 | "source": [ 181 | "%%writefile testCapText.py\n", 182 | "\n", 183 | "import unittest\n", 184 | "import capitalizeText\n", 185 | "\n", 186 | "class testCapTitle(unittest.TestCase):\n", 187 | " def testSingleWord(self):\n", 188 | " abc = \"sai\"\n", 189 | " result = capitalizeText.capText(abc)\n", 190 | " self.assertEquals(result, \"Sai\")\n", 191 | " \n", 192 | " def testingMultipleWords(self):\n", 193 | " xyz = \"manisha bhagat\"\n", 194 | " result = capitalizeText.capText(xyz)\n", 195 | " self.assertEquals(result,\"Manisha Bhagat\")\n", 196 | "\n", 197 | "if __name__ == \"__main__\":\n", 198 | " unittest.main()" 199 | ] 200 | }, 201 | { 202 | "cell_type": "code", 203 | "execution_count": 19, 204 | "metadata": {}, 205 | "outputs": [ 206 | { 207 | "name": "stdout", 208 | "output_type": "stream", 209 | "text": [ 210 | "testCapText.py:9: DeprecationWarning: Please use assertEqual instead.\r\n", 211 | " self.assertEquals(result, \"Sai\")\r\n", 212 | ".F\r\n", 213 | "======================================================================\r\n", 214 | "FAIL: testingMultipleWords (__main__.testCapTitle)\r\n", 215 | "----------------------------------------------------------------------\r\n", 216 | "Traceback (most recent call last):\r\n", 217 | " File \"testCapText.py\", line 14, in testingMultipleWords\r\n", 218 | " self.assertEquals(result,\"Manisha bhagat\")\r\n", 219 | "AssertionError: 'Manisha Bhagat' != 'Manisha bhagat'\r\n", 220 | "- Manisha Bhagat\r\n", 221 | "? ^\r\n", 222 | "+ Manisha bhagat\r\n", 223 | "? ^\r\n", 224 | "\r\n", 225 | "\r\n", 226 | "----------------------------------------------------------------------\r\n", 227 | "Ran 2 tests in 0.001s\r\n", 228 | "\r\n", 229 | "FAILED (failures=1)\r\n" 230 | ] 231 | } 232 | ], 233 | "source": [ 234 | "! python testCapText.py" 235 | ] 236 | }, 237 | { 238 | "cell_type": "markdown", 239 | "metadata": {}, 240 | "source": [ 241 | "# Generators" 242 | ] 243 | }, 244 | { 245 | "cell_type": "code", 246 | "execution_count": 30, 247 | "metadata": {}, 248 | "outputs": [], 249 | "source": [ 250 | "def getCloseByEvenNumber(lst):\n", 251 | " for item in lst:\n", 252 | " if item%2==0:\n", 253 | " return item\n", 254 | " else:\n", 255 | " return item+1" 256 | ] 257 | }, 258 | { 259 | "cell_type": "code", 260 | "execution_count": 31, 261 | "metadata": {}, 262 | "outputs": [ 263 | { 264 | "data": { 265 | "text/plain": [ 266 | "6" 267 | ] 268 | }, 269 | "execution_count": 31, 270 | "metadata": {}, 271 | "output_type": "execute_result" 272 | } 273 | ], 274 | "source": [ 275 | "getCloseByEvenNumber([5])" 276 | ] 277 | }, 278 | { 279 | "cell_type": "code", 280 | "execution_count": 33, 281 | "metadata": {}, 282 | "outputs": [ 283 | { 284 | "data": { 285 | "text/plain": [ 286 | "4" 287 | ] 288 | }, 289 | "execution_count": 33, 290 | "metadata": {}, 291 | "output_type": "execute_result" 292 | } 293 | ], 294 | "source": [ 295 | "getCloseByEvenNumber([4])" 296 | ] 297 | }, 298 | { 299 | "cell_type": "code", 300 | "execution_count": 34, 301 | "metadata": {}, 302 | "outputs": [], 303 | "source": [ 304 | "lst = list(range(100))" 305 | ] 306 | }, 307 | { 308 | "cell_type": "code", 309 | "execution_count": 26, 310 | "metadata": {}, 311 | "outputs": [ 312 | { 313 | "name": "stdout", 314 | "output_type": "stream", 315 | "text": [ 316 | "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 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, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]\n" 317 | ] 318 | } 319 | ], 320 | "source": [ 321 | "print(lst)" 322 | ] 323 | }, 324 | { 325 | "cell_type": "code", 326 | "execution_count": 27, 327 | "metadata": {}, 328 | "outputs": [], 329 | "source": [ 330 | "# I have a List of 100 Numebrs, I want to pass all of them \n", 331 | "# into the getNearByEvenNumber() Function \n", 332 | "# THen I want to store those in a new List " 333 | ] 334 | }, 335 | { 336 | "cell_type": "code", 337 | "execution_count": 35, 338 | "metadata": {}, 339 | "outputs": [ 340 | { 341 | "data": { 342 | "text/plain": [ 343 | "0" 344 | ] 345 | }, 346 | "execution_count": 35, 347 | "metadata": {}, 348 | "output_type": "execute_result" 349 | } 350 | ], 351 | "source": [ 352 | "getCloseByEvenNumber(lst)" 353 | ] 354 | }, 355 | { 356 | "cell_type": "code", 357 | "execution_count": 36, 358 | "metadata": {}, 359 | "outputs": [], 360 | "source": [ 361 | "def getCloseByEvenNumber(lst):\n", 362 | " for item in lst:\n", 363 | " if item%2==0:\n", 364 | " return item\n", 365 | " else:\n", 366 | " return item+1" 367 | ] 368 | }, 369 | { 370 | "cell_type": "code", 371 | "execution_count": 37, 372 | "metadata": {}, 373 | "outputs": [ 374 | { 375 | "data": { 376 | "text/plain": [ 377 | "0" 378 | ] 379 | }, 380 | "execution_count": 37, 381 | "metadata": {}, 382 | "output_type": "execute_result" 383 | } 384 | ], 385 | "source": [ 386 | "getCloseByEvenNumber(lst)" 387 | ] 388 | }, 389 | { 390 | "cell_type": "code", 391 | "execution_count": 38, 392 | "metadata": {}, 393 | "outputs": [], 394 | "source": [ 395 | "def getCloseByEvenNumberGen(lst):\n", 396 | " for item in lst:\n", 397 | " if item%2==0:\n", 398 | " yield item\n", 399 | " else:\n", 400 | " yield item+1" 401 | ] 402 | }, 403 | { 404 | "cell_type": "code", 405 | "execution_count": 41, 406 | "metadata": {}, 407 | "outputs": [ 408 | { 409 | "name": "stdout", 410 | "output_type": "stream", 411 | "text": [ 412 | "[0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, 30, 30, 32, 32, 34, 34, 36, 36, 38, 38, 40, 40, 42, 42, 44, 44, 46, 46, 48, 48, 50, 50, 52, 52, 54, 54, 56, 56, 58, 58, 60, 60, 62, 62, 64, 64, 66, 66, 68, 68, 70, 70, 72, 72, 74, 74, 76, 76, 78, 78, 80, 80, 82, 82, 84, 84, 86, 86, 88, 88, 90, 90, 92, 92, 94, 94, 96, 96, 98, 98, 100]\n" 413 | ] 414 | } 415 | ], 416 | "source": [ 417 | "print(list(getCloseByEvenNumberGen(lst)))" 418 | ] 419 | }, 420 | { 421 | "cell_type": "code", 422 | "execution_count": null, 423 | "metadata": {}, 424 | "outputs": [], 425 | "source": [] 426 | } 427 | ], 428 | "metadata": { 429 | "kernelspec": { 430 | "display_name": "Python 3", 431 | "language": "python", 432 | "name": "python3" 433 | }, 434 | "language_info": { 435 | "codemirror_mode": { 436 | "name": "ipython", 437 | "version": 3 438 | }, 439 | "file_extension": ".py", 440 | "mimetype": "text/x-python", 441 | "name": "python", 442 | "nbconvert_exporter": "python", 443 | "pygments_lexer": "ipython3", 444 | "version": "3.7.4" 445 | } 446 | }, 447 | "nbformat": 4, 448 | "nbformat_minor": 2 449 | } 450 | --------------------------------------------------------------------------------