|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [], |
| 8 | + "source": [ |
| 9 | + "a = 10\n", |
| 10 | + "b = 20\n", |
| 11 | + "c = 25\n", |
| 12 | + "d = 25" |
| 13 | + ] |
| 14 | + }, |
| 15 | + { |
| 16 | + "cell_type": "markdown", |
| 17 | + "metadata": {}, |
| 18 | + "source": [ |
| 19 | + "# if condition" |
| 20 | + ] |
| 21 | + }, |
| 22 | + { |
| 23 | + "cell_type": "code", |
| 24 | + "execution_count": 3, |
| 25 | + "metadata": {}, |
| 26 | + "outputs": [ |
| 27 | + { |
| 28 | + "name": "stdout", |
| 29 | + "output_type": "stream", |
| 30 | + "text": [ |
| 31 | + "I am not in if statement\n" |
| 32 | + ] |
| 33 | + } |
| 34 | + ], |
| 35 | + "source": [ |
| 36 | + "if a > b:\n", |
| 37 | + " print(\"A is less than B\")\n", |
| 38 | + "\n", |
| 39 | + "print(\"I am not in if statement\")" |
| 40 | + ] |
| 41 | + }, |
| 42 | + { |
| 43 | + "cell_type": "markdown", |
| 44 | + "metadata": {}, |
| 45 | + "source": [ |
| 46 | + "# else if condition" |
| 47 | + ] |
| 48 | + }, |
| 49 | + { |
| 50 | + "cell_type": "code", |
| 51 | + "execution_count": 4, |
| 52 | + "metadata": {}, |
| 53 | + "outputs": [ |
| 54 | + { |
| 55 | + "name": "stdout", |
| 56 | + "output_type": "stream", |
| 57 | + "text": [ |
| 58 | + "A is less than b\n", |
| 59 | + "I am in else if statement\n" |
| 60 | + ] |
| 61 | + } |
| 62 | + ], |
| 63 | + "source": [ |
| 64 | + "if a > b:\n", |
| 65 | + " print(\"A is greater than b\")\n", |
| 66 | + " print(\"I am in if statement\")\n", |
| 67 | + "\n", |
| 68 | + "elif a < b:\n", |
| 69 | + " print(\"A is less than b\")\n", |
| 70 | + " print(\"I am in else if statement\")" |
| 71 | + ] |
| 72 | + }, |
| 73 | + { |
| 74 | + "cell_type": "markdown", |
| 75 | + "metadata": {}, |
| 76 | + "source": [ |
| 77 | + "# else condition " |
| 78 | + ] |
| 79 | + }, |
| 80 | + { |
| 81 | + "cell_type": "code", |
| 82 | + "execution_count": 5, |
| 83 | + "metadata": {}, |
| 84 | + "outputs": [ |
| 85 | + { |
| 86 | + "name": "stdout", |
| 87 | + "output_type": "stream", |
| 88 | + "text": [ |
| 89 | + "Error\n" |
| 90 | + ] |
| 91 | + } |
| 92 | + ], |
| 93 | + "source": [ |
| 94 | + "if a > b:\n", |
| 95 | + " print(\"A is greater than b\")\n", |
| 96 | + " print(\"I am in if statement\")\n", |
| 97 | + "\n", |
| 98 | + "elif a == b:\n", |
| 99 | + " print(\"A is less than b\")\n", |
| 100 | + " print(\"I am in else if statement\")\n", |
| 101 | + " \n", |
| 102 | + "else:\n", |
| 103 | + " print(\"Error\")" |
| 104 | + ] |
| 105 | + }, |
| 106 | + { |
| 107 | + "cell_type": "markdown", |
| 108 | + "metadata": {}, |
| 109 | + "source": [ |
| 110 | + "# nested conditon" |
| 111 | + ] |
| 112 | + }, |
| 113 | + { |
| 114 | + "cell_type": "code", |
| 115 | + "execution_count": 9, |
| 116 | + "metadata": {}, |
| 117 | + "outputs": [ |
| 118 | + { |
| 119 | + "name": "stdout", |
| 120 | + "output_type": "stream", |
| 121 | + "text": [ |
| 122 | + "A is less than b\n", |
| 123 | + "I am in else if statement\n", |
| 124 | + "C is equals to d\n" |
| 125 | + ] |
| 126 | + } |
| 127 | + ], |
| 128 | + "source": [ |
| 129 | + "if a > b:\n", |
| 130 | + " print(\"A is greater than b\")\n", |
| 131 | + " print(\"I am in if statement\")\n", |
| 132 | + "\n", |
| 133 | + "elif a < b:\n", |
| 134 | + " print(\"A is less than b\")\n", |
| 135 | + " print(\"I am in else if statement\")\n", |
| 136 | + " \n", |
| 137 | + " if c < d:\n", |
| 138 | + " print(\"C is less than d\")\n", |
| 139 | + " \n", |
| 140 | + " else:\n", |
| 141 | + " print(\"C is equals to d\")\n", |
| 142 | + " \n", |
| 143 | + "else:\n", |
| 144 | + " print(\"Error\")" |
| 145 | + ] |
| 146 | + }, |
| 147 | + { |
| 148 | + "cell_type": "markdown", |
| 149 | + "metadata": {}, |
| 150 | + "source": [ |
| 151 | + "# BMI Calculator" |
| 152 | + ] |
| 153 | + }, |
| 154 | + { |
| 155 | + "cell_type": "code", |
| 156 | + "execution_count": 18, |
| 157 | + "metadata": {}, |
| 158 | + "outputs": [ |
| 159 | + { |
| 160 | + "name": "stdout", |
| 161 | + "output_type": "stream", |
| 162 | + "text": [ |
| 163 | + "Enter Your Name: alok\n", |
| 164 | + "Enter Your Height in meter: 2\n", |
| 165 | + "Enter Your Weight in kg: 110\n" |
| 166 | + ] |
| 167 | + } |
| 168 | + ], |
| 169 | + "source": [ |
| 170 | + "name = raw_input(\"Enter Your Name: \")\n", |
| 171 | + "height = raw_input(\"Enter Your Height in meter: \")\n", |
| 172 | + "weight = raw_input(\"Enter Your Weight in kg: \")" |
| 173 | + ] |
| 174 | + }, |
| 175 | + { |
| 176 | + "cell_type": "code", |
| 177 | + "execution_count": 19, |
| 178 | + "metadata": {}, |
| 179 | + "outputs": [ |
| 180 | + { |
| 181 | + "name": "stdout", |
| 182 | + "output_type": "stream", |
| 183 | + "text": [ |
| 184 | + "27\n" |
| 185 | + ] |
| 186 | + } |
| 187 | + ], |
| 188 | + "source": [ |
| 189 | + "bmi = int(weight) / (int(height)**2)\n", |
| 190 | + "print bmi" |
| 191 | + ] |
| 192 | + }, |
| 193 | + { |
| 194 | + "cell_type": "code", |
| 195 | + "execution_count": 20, |
| 196 | + "metadata": {}, |
| 197 | + "outputs": [ |
| 198 | + { |
| 199 | + "name": "stdout", |
| 200 | + "output_type": "stream", |
| 201 | + "text": [ |
| 202 | + "alok\n", |
| 203 | + "is overweight\n" |
| 204 | + ] |
| 205 | + } |
| 206 | + ], |
| 207 | + "source": [ |
| 208 | + "if bmi < 25:\n", |
| 209 | + " print(name)\n", |
| 210 | + " print('is not overweight')\n", |
| 211 | + " \n", |
| 212 | + "else:\n", |
| 213 | + " print(name)\n", |
| 214 | + " print('is overweight')" |
| 215 | + ] |
| 216 | + }, |
| 217 | + { |
| 218 | + "cell_type": "code", |
| 219 | + "execution_count": null, |
| 220 | + "metadata": {}, |
| 221 | + "outputs": [], |
| 222 | + "source": [] |
| 223 | + } |
| 224 | + ], |
| 225 | + "metadata": { |
| 226 | + "kernelspec": { |
| 227 | + "display_name": "Python 2", |
| 228 | + "language": "python", |
| 229 | + "name": "python2" |
| 230 | + }, |
| 231 | + "language_info": { |
| 232 | + "codemirror_mode": { |
| 233 | + "name": "ipython", |
| 234 | + "version": 2 |
| 235 | + }, |
| 236 | + "file_extension": ".py", |
| 237 | + "mimetype": "text/x-python", |
| 238 | + "name": "python", |
| 239 | + "nbconvert_exporter": "python", |
| 240 | + "pygments_lexer": "ipython2", |
| 241 | + "version": "2.7.16" |
| 242 | + } |
| 243 | + }, |
| 244 | + "nbformat": 4, |
| 245 | + "nbformat_minor": 2 |
| 246 | +} |
0 commit comments