├── 23-web-development ├── ChatApp │ ├── runtime.txt │ ├── Procfile │ ├── requirements.txt │ ├── static │ │ ├── index.html │ │ └── main.js │ └── app.py └── .DS_Store ├── .DS_Store ├── 16-randomness.pdf ├── README.md ├── 15-functional-programming.pdf ├── Web-Development-Notes ├── .DS_Store ├── Web Development.html.resources │ ├── image.png │ ├── image_1.png │ ├── B312387C-26EF-4971-8FDD-D44A9B25274F.png │ ├── B781EDEE-0968-4048-8420-8721D90C53E9.png │ ├── C64253C0-038A-49F3-8EB1-38B5ED7A298D.png │ └── EA105921-FC50-4D41-A5BE-4636C1DD83B1.png └── Web Development.html ├── heaps-hashtable ├── Whiteboard[10]-01.png ├── Whiteboard[1]-01.png ├── Whiteboard[2]-01.png ├── Whiteboard[3]-01.png ├── Whiteboard[4]-01.png ├── Whiteboard[5]-01.png ├── Whiteboard[6]-01.png ├── Whiteboard[7]-01.png ├── Whiteboard[8]-01.png └── Whiteboard[9]-01.png ├── trees-and-graphs ├── Whiteboard[1]-01.png ├── Whiteboard[2]-01.png ├── Whiteboard[3]-01.png ├── Whiteboard[4]-01.png ├── Whiteboard[5]-01.png ├── Whiteboard[6]-01.png ├── Whiteboard[7]-01.png ├── Whiteboard[8]-01.png └── Whiteboard[9]-01.png ├── .ipynb_checkpoints ├── 23-Web-Development-checkpoint.ipynb ├── 14-heaps-hash-table-checkpoint.ipynb ├── TreesAndGraphs-checkpoint.ipynb ├── 13-trees-and-graphs-checkpoint.ipynb ├── 12-stacks-queues-linkedlist-checkpoint.ipynb └── StacksAndQueues-checkpoint.ipynb ├── 14-heaps-hash-table.ipynb ├── 03-loops.py ├── 02-conditions.py ├── 04-functions.py ├── 04b-functions-practice.ipynb ├── 22-web-automation.ipynb ├── 13-trees-and-graphs.ipynb ├── 12-stacks-queues-linkedlist.ipynb ├── 09-recursion.ipynb ├── 07-strings.ipynb ├── 08-searching-Swapping-Sorting.ipynb ├── 05-memory.ipynb ├── 06-lists.ipynb ├── 10-tuples-dictionary-sets.ipynb └── 11-classes-and-objects.ipynb /23-web-development/ChatApp/runtime.txt: -------------------------------------------------------------------------------- 1 | python-3.6.6 2 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/.DS_Store -------------------------------------------------------------------------------- /23-web-development/ChatApp/Procfile: -------------------------------------------------------------------------------- 1 | web: gunicorn --worker-class eventlet -w 1 module:app -------------------------------------------------------------------------------- /16-randomness.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/16-randomness.pdf -------------------------------------------------------------------------------- /23-web-development/ChatApp/requirements.txt: -------------------------------------------------------------------------------- 1 | Flask 2 | Flask-SocketIO 3 | gunicorn 4 | eventlet -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # python-lectures' code 2 | 3 | Do not make any changes to this repository! 4 | -------------------------------------------------------------------------------- /15-functional-programming.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/15-functional-programming.pdf -------------------------------------------------------------------------------- /23-web-development/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/23-web-development/.DS_Store -------------------------------------------------------------------------------- /Web-Development-Notes/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/Web-Development-Notes/.DS_Store -------------------------------------------------------------------------------- /heaps-hashtable/Whiteboard[10]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/heaps-hashtable/Whiteboard[10]-01.png -------------------------------------------------------------------------------- /heaps-hashtable/Whiteboard[1]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/heaps-hashtable/Whiteboard[1]-01.png -------------------------------------------------------------------------------- /heaps-hashtable/Whiteboard[2]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/heaps-hashtable/Whiteboard[2]-01.png -------------------------------------------------------------------------------- /heaps-hashtable/Whiteboard[3]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/heaps-hashtable/Whiteboard[3]-01.png -------------------------------------------------------------------------------- /heaps-hashtable/Whiteboard[4]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/heaps-hashtable/Whiteboard[4]-01.png -------------------------------------------------------------------------------- /heaps-hashtable/Whiteboard[5]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/heaps-hashtable/Whiteboard[5]-01.png -------------------------------------------------------------------------------- /heaps-hashtable/Whiteboard[6]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/heaps-hashtable/Whiteboard[6]-01.png -------------------------------------------------------------------------------- /heaps-hashtable/Whiteboard[7]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/heaps-hashtable/Whiteboard[7]-01.png -------------------------------------------------------------------------------- /heaps-hashtable/Whiteboard[8]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/heaps-hashtable/Whiteboard[8]-01.png -------------------------------------------------------------------------------- /heaps-hashtable/Whiteboard[9]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/heaps-hashtable/Whiteboard[9]-01.png -------------------------------------------------------------------------------- /trees-and-graphs/Whiteboard[1]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/trees-and-graphs/Whiteboard[1]-01.png -------------------------------------------------------------------------------- /trees-and-graphs/Whiteboard[2]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/trees-and-graphs/Whiteboard[2]-01.png -------------------------------------------------------------------------------- /trees-and-graphs/Whiteboard[3]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/trees-and-graphs/Whiteboard[3]-01.png -------------------------------------------------------------------------------- /trees-and-graphs/Whiteboard[4]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/trees-and-graphs/Whiteboard[4]-01.png -------------------------------------------------------------------------------- /trees-and-graphs/Whiteboard[5]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/trees-and-graphs/Whiteboard[5]-01.png -------------------------------------------------------------------------------- /trees-and-graphs/Whiteboard[6]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/trees-and-graphs/Whiteboard[6]-01.png -------------------------------------------------------------------------------- /trees-and-graphs/Whiteboard[7]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/trees-and-graphs/Whiteboard[7]-01.png -------------------------------------------------------------------------------- /trees-and-graphs/Whiteboard[8]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/trees-and-graphs/Whiteboard[8]-01.png -------------------------------------------------------------------------------- /trees-and-graphs/Whiteboard[9]-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/trees-and-graphs/Whiteboard[9]-01.png -------------------------------------------------------------------------------- /.ipynb_checkpoints/23-Web-Development-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [], 3 | "metadata": {}, 4 | "nbformat": 4, 5 | "nbformat_minor": 4 6 | } 7 | -------------------------------------------------------------------------------- /Web-Development-Notes/Web Development.html.resources/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/Web-Development-Notes/Web Development.html.resources/image.png -------------------------------------------------------------------------------- /Web-Development-Notes/Web Development.html.resources/image_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/Web-Development-Notes/Web Development.html.resources/image_1.png -------------------------------------------------------------------------------- /Web-Development-Notes/Web Development.html.resources/B312387C-26EF-4971-8FDD-D44A9B25274F.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/Web-Development-Notes/Web Development.html.resources/B312387C-26EF-4971-8FDD-D44A9B25274F.png -------------------------------------------------------------------------------- /Web-Development-Notes/Web Development.html.resources/B781EDEE-0968-4048-8420-8721D90C53E9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/Web-Development-Notes/Web Development.html.resources/B781EDEE-0968-4048-8420-8721D90C53E9.png -------------------------------------------------------------------------------- /Web-Development-Notes/Web Development.html.resources/C64253C0-038A-49F3-8EB1-38B5ED7A298D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/Web-Development-Notes/Web Development.html.resources/C64253C0-038A-49F3-8EB1-38B5ED7A298D.png -------------------------------------------------------------------------------- /Web-Development-Notes/Web Development.html.resources/EA105921-FC50-4D41-A5BE-4636C1DD83B1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anant15/python-lectures/HEAD/Web-Development-Notes/Web Development.html.resources/EA105921-FC50-4D41-A5BE-4636C1DD83B1.png -------------------------------------------------------------------------------- /23-web-development/ChatApp/static/index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |" + data + "
" 24 | 25 | }) 26 | 27 | // Now, we want Javascript to create fetching like calls. 28 | function fetchUsers() 29 | { 30 | fetch('/users').then(function(res) 31 | { 32 | res.json().then( 33 | function(data) 34 | { 35 | console.log(data) 36 | } 37 | ) 38 | }) 39 | } 40 | 41 | // var x = 5 42 | 43 | // if (x>2) 44 | // { 45 | // console.log("greater") 46 | // } 47 | // else 48 | // { 49 | // console.log("smaller") 50 | // } 51 | // function area(l, b) 52 | // { 53 | // var a = l * b 54 | // return a 55 | // } 56 | 57 | // a1 = area(4, 5) 58 | 59 | // for (var i=1; i<=5; i+=1) 60 | // { 61 | // console.log(i) 62 | // } 63 | -------------------------------------------------------------------------------- /03-loops.py: -------------------------------------------------------------------------------- 1 | # For loops 2 | # 3 | # # print first 100 natural numbers 4 | # for i in range(1, 101): 5 | # if i < 100: 6 | # print(i, end=",") 7 | # else: 8 | # print(i) 9 | # 10 | # # print square of first 100 natural numbers 11 | # for num in range(1, 101): 12 | # print(num**2, end=",") 13 | # print() 14 | 15 | # # print "hello world" 10 times 16 | # for i in range(10): 17 | # print("Hello World") #This will print 'Hello World' 10x times and i from 0 to 9 as index initialize from 0 18 | # print(i) 19 | # 20 | # # print even numbers in [2, 100] 21 | # for i in range(2, 101): 22 | # if i % 2 == 0: 23 | # print(i, end=", ") 24 | # print() 25 | # 26 | # # multiples of 13 between [100, 200] 27 | # for num in range(100, 201): 28 | # if num % 13 == 0: 29 | # print(num, end=",") #We are using end="," to make the consecutive output in the same line and not next line 30 | # print() 31 | # print("-"*20) 32 | 33 | # check if a number is prime or not 34 | num = 7 35 | result = True 36 | for i in range(2, int(num**2)+1): 37 | if num % i == 0: 38 | result = False 39 | print(result) 40 | 41 | # how to take input from user 42 | output = int(input("Enter number: ")) 43 | print(output*2) 44 | 45 | output = int(input("Enter a number: ")) 46 | i = 0 47 | while i<=output: 48 | print(i) 49 | i = i + 1 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 | -------------------------------------------------------------------------------- /02-conditions.py: -------------------------------------------------------------------------------- 1 | # Conditional Flow 2 | 3 | # if-elif-else structure 4 | 5 | # if is mandatory, elif is optional [0, 1, ...N], else is optional [0, 1] 6 | age = 65 7 | # if age > 20: 8 | # if age > 60: 9 | # print("Senior") 10 | # print("Adult") 11 | # elif age > 5: 12 | # print("Kid") 13 | # else: 14 | # print("Baby") 15 | 16 | if age > 60: 17 | print("Senior") 18 | 19 | if age > 20: 20 | print("Adult") 21 | elif age > 5: 22 | print("Kid") 23 | else: 24 | print("Baby") 25 | 26 | # Odd, Even problem 27 | num = 6 28 | # print("Odd") 29 | # print("Even") 30 | if num % 2 == 0: 31 | print("Even") 32 | else: 33 | print("Odd") 34 | 35 | # Logical Operators - and, or and not 36 | a, b, c, d = 5, 4, 3, 8 37 | # Find the max - the easy way 38 | if a > b and a > c and a > d: 39 | print(a) 40 | elif b > a and b > c and b > d: 41 | print(b) 42 | elif c > a and c > b and c > d: 43 | print(c) 44 | else: 45 | print(d) 46 | 47 | # better way to calculate maximum 48 | max = b 49 | if a > max: 50 | max = a 51 | if c > max: 52 | max = c 53 | if d > max: 54 | max = d 55 | print(max) 56 | 57 | 58 | a, b, c = 6, 7, 8 59 | if (a+c>b) and (b+c>a) and (a+b>c): 60 | print("Valid") 61 | else: 62 | print("Invalid") 63 | 64 | # to check, whether a triangle is equilateral, isosceles, or scalene 65 | if a == b and b == c and c == a: 66 | print("e") 67 | elif a == b or b == c or c == a: 68 | print("i") 69 | else: 70 | print("s") 71 | 72 | # find the minimum of five numbers a, b, c, d, e 73 | min= b 74 | if a < min: 75 | min = a 76 | if c < min: 77 | min = c 78 | if d < min: 79 | min = d 80 | if e < min: 81 | min = e 82 | print(min) 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/TreesAndGraphs-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "class Node:\n", 10 | " def __init__(self, val):\n", 11 | " self.value = val\n", 12 | " self.left = None\n", 13 | " self.right = None" 14 | ] 15 | }, 16 | { 17 | "cell_type": "code", 18 | "execution_count": null, 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "class BST:\n", 23 | " def __init__(self):\n", 24 | " self.root = None\n", 25 | " \n", 26 | " def insert(self, val):\n", 27 | " new_node = Node(val)\n", 28 | " if self.root == None:\n", 29 | " self.root = new_node\n", 30 | " else:\n", 31 | " _insert(self.root, new_node)\n", 32 | " \n", 33 | " def _insert(self, start_node, new_node):\n", 34 | " # helper method\n", 35 | " if start_node.value == new_node.value:\n", 36 | " return None\n", 37 | " elif start_node > new_node.value:\n", 38 | " if start_node.left == None:\n", 39 | " start_node.left = new_node\n", 40 | " else:\n", 41 | " _insert(start_node.left, new_node)\n", 42 | " else:\n", 43 | " if start_node.right == None:\n", 44 | " start_node.right = new_node\n", 45 | " else:\n", 46 | " _insert(start_node.right, new_node)" 47 | ] 48 | } 49 | ], 50 | "metadata": { 51 | "kernelspec": { 52 | "display_name": "Python 3", 53 | "language": "python", 54 | "name": "python3" 55 | }, 56 | "language_info": { 57 | "codemirror_mode": { 58 | "name": "ipython", 59 | "version": 3 60 | }, 61 | "file_extension": ".py", 62 | "mimetype": "text/x-python", 63 | "name": "python", 64 | "nbconvert_exporter": "python", 65 | "pygments_lexer": "ipython3", 66 | "version": "3.7.6" 67 | } 68 | }, 69 | "nbformat": 4, 70 | "nbformat_minor": 4 71 | } 72 | -------------------------------------------------------------------------------- /04-functions.py: -------------------------------------------------------------------------------- 1 | # Functions 2 | 3 | # for i in range(5): 4 | # print(i) 5 | # for power in range(1, 4): 6 | # print(i**power, end = " ") 7 | # print() 8 | 9 | # Functions 10 | 11 | # def f(x): 12 | # y = x**2 + x + 2 13 | # return y 14 | # 15 | # print(f(4)) 16 | # print(f(5)) 17 | # print(f(10)) 18 | # 19 | # 20 | # def area(l, b): # parameters 21 | # a = l * b 22 | # return a 23 | # 24 | # var = area(5, 2) # arguments 25 | # var2 = area(3, 4) 26 | # print(var, var2) 27 | # 28 | # def hello(name): # parameter 29 | # print("Hello " + name) 30 | # 31 | # print(hello("Anant")) 32 | # hello("Rishi") 33 | # hello("Priya") 34 | 35 | 36 | def is_prime(num): 37 | for i in range(2, int(num**0.5+1)): 38 | if num % i == 0: 39 | return False 40 | return True 41 | 42 | # Python function can have multiple return statements 43 | # print(is_prime(2)) 44 | 45 | # def dummy(x): 46 | # print(x) 47 | # return None 48 | # print(x**2) 49 | # 50 | # dummy(3) 51 | 52 | # def print_primes(lower, upper): 53 | # for i in range(lower, upper+1): 54 | # if is_prime(i): 55 | # print(i) 56 | # 57 | # print_primes(2, 50) 58 | 59 | 60 | 61 | def minimum(a, b): 62 | if a > b: 63 | return b 64 | else: 65 | return a 66 | 67 | def hcf(a, b): 68 | smaller = minimum(a, b) 69 | result = 1 70 | for i in range(1, smaller+1): 71 | if a % i == 0 and b % i == 0: 72 | result = i 73 | return result 74 | 75 | print(hcf(12, 11)) 76 | 77 | 78 | # Euclid's Algorithm 79 | def hcf(a, b): 80 | while a != 0 and b != 0: 81 | if a > b: 82 | a = a - b 83 | else: 84 | b = b - a 85 | return a + b 86 | 87 | # Optimised Eulcid's algorithm 88 | def hcf(a, b): 89 | while a != 0 and b != 0: 90 | if a > b: 91 | a = a % b 92 | else: 93 | b = b % a 94 | return a + b 95 | 96 | # 39924 - count the number of digits 97 | def count(num, digit): 98 | count = 0 99 | while num > 0: 100 | d = num % 10 101 | num = num // 10 102 | if d == digit: 103 | count = count + 1 104 | return count 105 | 106 | # log 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /04b-functions-practice.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 12, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "def custom_sqrt(num):\n", 10 | " left = 0\n", 11 | " right = num\n", 12 | " mid = (left + right) / 2\n", 13 | " sq = mid * mid\n", 14 | " while abs(sq - num) > 1e-10: \n", 15 | " if sq < num:\n", 16 | " left = mid\n", 17 | " else:\n", 18 | " right = mid\n", 19 | " mid = (left + right)/2\n", 20 | " sq = mid * mid\n", 21 | " return mid" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": 13, 27 | "metadata": {}, 28 | "outputs": [ 29 | { 30 | "data": { 31 | "text/plain": [ 32 | "10.000000000002274" 33 | ] 34 | }, 35 | "execution_count": 13, 36 | "metadata": {}, 37 | "output_type": "execute_result" 38 | } 39 | ], 40 | "source": [ 41 | "custom_sqrt(100)" 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "execution_count": 17, 47 | "metadata": {}, 48 | "outputs": [ 49 | { 50 | "data": { 51 | "text/plain": [ 52 | "4" 53 | ] 54 | }, 55 | "execution_count": 17, 56 | "metadata": {}, 57 | "output_type": "execute_result" 58 | } 59 | ], 60 | "source": [ 61 | "def custom_log(x, b):\n", 62 | " count = 0\n", 63 | " while x > 1:\n", 64 | " x = x / b\n", 65 | " count += 1\n", 66 | " return count\n", 67 | "\n", 68 | "custom_log(8, 2)\n", 69 | "custom_log(2, 2)\n", 70 | "custom_log(27, 3)\n", 71 | "custom_log(28, 3)" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 27, 77 | "metadata": {}, 78 | "outputs": [ 79 | { 80 | "data": { 81 | "text/plain": [ 82 | "3.0331032563043436" 83 | ] 84 | }, 85 | "execution_count": 27, 86 | "metadata": {}, 87 | "output_type": "execute_result" 88 | } 89 | ], 90 | "source": [ 91 | "def newton_log(num, b):\n", 92 | " left = 0\n", 93 | " right = num\n", 94 | " mid = (left + right) / 2\n", 95 | " temp = b ** mid\n", 96 | " while abs(temp - num) > 1e-12: \n", 97 | " if temp < num:\n", 98 | " left = mid\n", 99 | " else:\n", 100 | " right = mid\n", 101 | " mid = (left + right)/2\n", 102 | " temp = b ** mid\n", 103 | " return mid\n", 104 | "\n", 105 | "newton_log(8, 2)\n", 106 | "newton_log(2, 2)\n", 107 | "newton_log(27, 3)\n", 108 | "newton_log(28, 3)" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "metadata": {}, 114 | "source": [ 115 | "### Bit, Binary, ASCII" 116 | ] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": null, 121 | "metadata": {}, 122 | "outputs": [], 123 | "source": [] 124 | } 125 | ], 126 | "metadata": { 127 | "kernelspec": { 128 | "display_name": "Python 3", 129 | "language": "python", 130 | "name": "python3" 131 | }, 132 | "language_info": { 133 | "codemirror_mode": { 134 | "name": "ipython", 135 | "version": 3 136 | }, 137 | "file_extension": ".py", 138 | "mimetype": "text/x-python", 139 | "name": "python", 140 | "nbconvert_exporter": "python", 141 | "pygments_lexer": "ipython3", 142 | "version": "3.7.2" 143 | } 144 | }, 145 | "nbformat": 4, 146 | "nbformat_minor": 2 147 | } 148 | -------------------------------------------------------------------------------- /23-web-development/ChatApp/app.py: -------------------------------------------------------------------------------- 1 | # # flask basics 2 | # from flask import Flask, jsonify, request 3 | # app = Flask(__name__, static_url_path="/static") 4 | # # If this file is getting directly run from the terminal, 5 | # # by default __name__ will be set to "__main__" . Otherwise, 6 | # # if we are importing this file in some other Python script, 7 | # # then it will different. We will get to see it's importance later. 8 | 9 | # # Function decorator 10 | # # @app.route("/") # "/" is one of the end-points 11 | # # def hello(): 12 | # # # function name can be anything 13 | # # return "Hello" 14 | 15 | # # # Example of creating our own API 16 | # users = [{'id':2, 'name':'Anne', 'age':20}, {'id':1, 'name':'Cathy', 'age':21}] 17 | 18 | # @app.route("/users/") 19 | # def get_users(): 20 | # return jsonify(users) # jsonify is used to convert the dict to string 21 | # # you can only send a string 22 | 23 | # # # Creating a dynamic route, search user by ID 24 | # @app.route("/users/id/




