The volume of a sphere is given as $$\\frac{4}{3} πr^3$$
" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 1, 18 | "metadata": { 19 | "collapsed": true, 20 | "jupyter": { 21 | "outputs_hidden": true 22 | } 23 | }, 24 | "outputs": [], 25 | "source": [ 26 | "def vol(rad):\n", 27 | " pass" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": 2, 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "data": { 37 | "text/plain": [ 38 | "33.49333333333333" 39 | ] 40 | }, 41 | "execution_count": 2, 42 | "metadata": {}, 43 | "output_type": "execute_result" 44 | } 45 | ], 46 | "source": [ 47 | "# Check\n", 48 | "vol(2)" 49 | ] 50 | }, 51 | { 52 | "cell_type": "markdown", 53 | "metadata": {}, 54 | "source": [ 55 | "___\n", 56 | "**Write a function that checks whether a number is in a given range (inclusive of high and low)**" 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": 3, 62 | "metadata": { 63 | "collapsed": true, 64 | "jupyter": { 65 | "outputs_hidden": true 66 | } 67 | }, 68 | "outputs": [], 69 | "source": [ 70 | "def ran_check(num,low,high):\n", 71 | " pass" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 4, 77 | "metadata": {}, 78 | "outputs": [ 79 | { 80 | "name": "stdout", 81 | "output_type": "stream", 82 | "text": [ 83 | "5 is in the range between 2 and 7\n" 84 | ] 85 | } 86 | ], 87 | "source": [ 88 | "# Check\n", 89 | "ran_check(5,2,7)" 90 | ] 91 | }, 92 | { 93 | "cell_type": "markdown", 94 | "metadata": {}, 95 | "source": [ 96 | "If you only wanted to return a boolean:" 97 | ] 98 | }, 99 | { 100 | "cell_type": "code", 101 | "execution_count": 5, 102 | "metadata": { 103 | "collapsed": true, 104 | "jupyter": { 105 | "outputs_hidden": true 106 | } 107 | }, 108 | "outputs": [], 109 | "source": [ 110 | "def ran_bool(num,low,high):\n", 111 | " pass" 112 | ] 113 | }, 114 | { 115 | "cell_type": "code", 116 | "execution_count": 6, 117 | "metadata": {}, 118 | "outputs": [ 119 | { 120 | "data": { 121 | "text/plain": [ 122 | "True" 123 | ] 124 | }, 125 | "execution_count": 6, 126 | "metadata": {}, 127 | "output_type": "execute_result" 128 | } 129 | ], 130 | "source": [ 131 | "ran_bool(3,1,10)" 132 | ] 133 | }, 134 | { 135 | "cell_type": "markdown", 136 | "metadata": {}, 137 | "source": [ 138 | "____\n", 139 | "**Write a Python function that accepts a string and calculates the number of upper case letters and lower case letters.**\n", 140 | "\n", 141 | " Sample String : 'Hello Mr. Rogers, how are you this fine Tuesday?'\n", 142 | " Expected Output : \n", 143 | " No. of Upper case characters : 4\n", 144 | " No. of Lower case Characters : 33\n", 145 | "\n", 146 | "HINT: Two string methods that might prove useful: **.isupper()** and **.islower()**\n", 147 | "\n", 148 | "If you feel ambitious, explore the Collections module to solve this problem!" 149 | ] 150 | }, 151 | { 152 | "cell_type": "code", 153 | "execution_count": 7, 154 | "metadata": { 155 | "collapsed": true, 156 | "jupyter": { 157 | "outputs_hidden": true 158 | } 159 | }, 160 | "outputs": [], 161 | "source": [ 162 | "def up_low(s):\n", 163 | " pass" 164 | ] 165 | }, 166 | { 167 | "cell_type": "code", 168 | "execution_count": 8, 169 | "metadata": {}, 170 | "outputs": [ 171 | { 172 | "name": "stdout", 173 | "output_type": "stream", 174 | "text": [ 175 | "Original String : Hello Mr. Rogers, how are you this fine Tuesday?\n", 176 | "No. of Upper case characters : 4\n", 177 | "No. of Lower case Characters : 33\n" 178 | ] 179 | } 180 | ], 181 | "source": [ 182 | "s = 'Hello Mr. Rogers, how are you this fine Tuesday?'\n", 183 | "up_low(s)" 184 | ] 185 | }, 186 | { 187 | "cell_type": "markdown", 188 | "metadata": {}, 189 | "source": [ 190 | "____\n", 191 | "**Write a Python function that takes a list and returns a new list with unique elements of the first list.**\n", 192 | "\n", 193 | " Sample List : [1,1,1,1,2,2,3,3,3,3,4,5]\n", 194 | " Unique List : [1, 2, 3, 4, 5]" 195 | ] 196 | }, 197 | { 198 | "cell_type": "code", 199 | "execution_count": 9, 200 | "metadata": { 201 | "collapsed": true, 202 | "jupyter": { 203 | "outputs_hidden": true 204 | } 205 | }, 206 | "outputs": [], 207 | "source": [ 208 | "def unique_list(lst):\n", 209 | " pass" 210 | ] 211 | }, 212 | { 213 | "cell_type": "code", 214 | "execution_count": 10, 215 | "metadata": {}, 216 | "outputs": [ 217 | { 218 | "data": { 219 | "text/plain": [ 220 | "[1, 2, 3, 4, 5]" 221 | ] 222 | }, 223 | "execution_count": 10, 224 | "metadata": {}, 225 | "output_type": "execute_result" 226 | } 227 | ], 228 | "source": [ 229 | "unique_list([1,1,1,1,2,2,3,3,3,3,4,5])" 230 | ] 231 | }, 232 | { 233 | "cell_type": "markdown", 234 | "metadata": {}, 235 | "source": [ 236 | "____\n", 237 | "**Write a Python function to multiply all the numbers in a list.**\n", 238 | "\n", 239 | " Sample List : [1, 2, 3, -4]\n", 240 | " Expected Output : -24" 241 | ] 242 | }, 243 | { 244 | "cell_type": "code", 245 | "execution_count": 11, 246 | "metadata": { 247 | "collapsed": true, 248 | "jupyter": { 249 | "outputs_hidden": true 250 | } 251 | }, 252 | "outputs": [], 253 | "source": [ 254 | "def multiply(numbers): \n", 255 | " pass" 256 | ] 257 | }, 258 | { 259 | "cell_type": "code", 260 | "execution_count": 12, 261 | "metadata": {}, 262 | "outputs": [ 263 | { 264 | "data": { 265 | "text/plain": [ 266 | "-24" 267 | ] 268 | }, 269 | "execution_count": 12, 270 | "metadata": {}, 271 | "output_type": "execute_result" 272 | } 273 | ], 274 | "source": [ 275 | "multiply([1,2,3,-4])" 276 | ] 277 | }, 278 | { 279 | "cell_type": "markdown", 280 | "metadata": {}, 281 | "source": [ 282 | "____\n", 283 | "**Write a Python function that checks whether a word or phrase is palindrome or not.**\n", 284 | "\n", 285 | "Note: A palindrome is word, phrase, or sequence that reads the same backward as forward, e.g., madam,kayak,racecar, or a phrase \"nurses run\". Hint: You may want to check out the .replace() method in a string to help out with dealing with spaces. Also google search how to reverse a string in Python, there are some clever ways to do it with slicing notation." 286 | ] 287 | }, 288 | { 289 | "cell_type": "code", 290 | "execution_count": 13, 291 | "metadata": { 292 | "collapsed": true, 293 | "jupyter": { 294 | "outputs_hidden": true 295 | } 296 | }, 297 | "outputs": [], 298 | "source": [ 299 | "def palindrome(s):\n", 300 | " pass" 301 | ] 302 | }, 303 | { 304 | "cell_type": "code", 305 | "execution_count": 14, 306 | "metadata": {}, 307 | "outputs": [ 308 | { 309 | "data": { 310 | "text/plain": [ 311 | "True" 312 | ] 313 | }, 314 | "execution_count": 14, 315 | "metadata": {}, 316 | "output_type": "execute_result" 317 | } 318 | ], 319 | "source": [ 320 | "palindrome('helleh')" 321 | ] 322 | }, 323 | { 324 | "cell_type": "markdown", 325 | "metadata": {}, 326 | "source": [ 327 | "____\n", 328 | "#### Hard:\n", 329 | "\n", 330 | "**Write a Python function to check whether a string is pangram or not. (Assume the string passed in does not have any punctuation)**\n", 331 | "\n", 332 | " Note : Pangrams are words or sentences containing every letter of the alphabet at least once.\n", 333 | " For example : \"The quick brown fox jumps over the lazy dog\"\n", 334 | "\n", 335 | "Hint: You may want to use .replace() method to get rid of spaces.\n", 336 | "\n", 337 | "Hint: Look at the [string module](https://stackoverflow.com/questions/16060899/alphabet-range-in-python)\n", 338 | "\n", 339 | "Hint: In case you want to use [set comparisons](https://medium.com/better-programming/a-visual-guide-to-set-comparisons-in-python-6ab7edb9ec41)" 340 | ] 341 | }, 342 | { 343 | "cell_type": "code", 344 | "execution_count": 15, 345 | "metadata": { 346 | "collapsed": true, 347 | "jupyter": { 348 | "outputs_hidden": true 349 | } 350 | }, 351 | "outputs": [], 352 | "source": [ 353 | "import string\n", 354 | "\n", 355 | "def ispangram(str1, alphabet=string.ascii_lowercase):\n", 356 | " pass" 357 | ] 358 | }, 359 | { 360 | "cell_type": "code", 361 | "execution_count": 16, 362 | "metadata": {}, 363 | "outputs": [ 364 | { 365 | "data": { 366 | "text/plain": [ 367 | "True" 368 | ] 369 | }, 370 | "execution_count": 16, 371 | "metadata": {}, 372 | "output_type": "execute_result" 373 | } 374 | ], 375 | "source": [ 376 | "ispangram(\"The quick brown fox jumps over the lazy dog\")" 377 | ] 378 | }, 379 | { 380 | "cell_type": "code", 381 | "execution_count": 17, 382 | "metadata": {}, 383 | "outputs": [ 384 | { 385 | "data": { 386 | "text/plain": [ 387 | "'abcdefghijklmnopqrstuvwxyz'" 388 | ] 389 | }, 390 | "execution_count": 17, 391 | "metadata": {}, 392 | "output_type": "execute_result" 393 | } 394 | ], 395 | "source": [ 396 | "string.ascii_lowercase" 397 | ] 398 | } 399 | ], 400 | "metadata": { 401 | "kernelspec": { 402 | "display_name": "Python 3 (ipykernel)", 403 | "language": "python", 404 | "name": "python3" 405 | }, 406 | "language_info": { 407 | "codemirror_mode": { 408 | "name": "ipython", 409 | "version": 3 410 | }, 411 | "file_extension": ".py", 412 | "mimetype": "text/x-python", 413 | "name": "python", 414 | "nbconvert_exporter": "python", 415 | "pygments_lexer": "ipython3", 416 | "version": "3.10.11" 417 | } 418 | }, 419 | "nbformat": 4, 420 | "nbformat_minor": 4 421 | } 422 | -------------------------------------------------------------------------------- /practices/guessing_game_challenge.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Guessing Game Challenge\n", 8 | "\n", 9 | "Let's use `while` loops to create a guessing game.\n", 10 | "\n", 11 | "The Challenge:\n", 12 | "\n", 13 | "Write a program that picks a random integer from 1 to 100, and has players guess the number. The rules are:\n", 14 | "\n", 15 | "1. If a player's guess is less than 1 or greater than 100, say \"OUT OF BOUNDS\"\n", 16 | "2. On a player's first turn, if their guess is\n", 17 | " * within 10 of the number, return \"WARM!\"\n", 18 | " * further than 10 away from the number, return \"COLD!\"\n", 19 | "3. On all subsequent turns, if a guess is \n", 20 | " * closer to the number than the previous guess return \"WARMER!\"\n", 21 | " * farther from the number than the previous guess, return \"COLDER!\"\n", 22 | "4. When the player's guess equals the number, tell them they've guessed correctly *and* how many guesses it took!\n", 23 | "\n", 24 | "You can try this from scratch, or follow the steps outlined below. A separate Solution notebook has been provided. Good luck!\n" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": {}, 30 | "source": [ 31 | "#### First, pick a random integer from 1 to 100 using the random module and assign it to a variable\n", 32 | "\n", 33 | "Note: `random.randint(a,b)` returns a random integer in range `[a, b]`, including both end points." 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": null, 39 | "metadata": { 40 | "collapsed": true, 41 | "jupyter": { 42 | "outputs_hidden": true 43 | } 44 | }, 45 | "outputs": [], 46 | "source": [] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "metadata": {}, 51 | "source": [ 52 | "#### Next, print an introduction to the game and explain the rules" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": null, 58 | "metadata": { 59 | "collapsed": true, 60 | "jupyter": { 61 | "outputs_hidden": true 62 | } 63 | }, 64 | "outputs": [], 65 | "source": [] 66 | }, 67 | { 68 | "cell_type": "markdown", 69 | "metadata": {}, 70 | "source": [ 71 | "#### Create a list to store guesses\n", 72 | "\n", 73 | "Hint: zero is a good placeholder value. It's useful because it evaluates to \"False\"" 74 | ] 75 | }, 76 | { 77 | "cell_type": "code", 78 | "execution_count": null, 79 | "metadata": { 80 | "collapsed": true, 81 | "jupyter": { 82 | "outputs_hidden": true 83 | } 84 | }, 85 | "outputs": [], 86 | "source": [] 87 | }, 88 | { 89 | "cell_type": "markdown", 90 | "metadata": {}, 91 | "source": [ 92 | "#### Write a `while` loop that asks for a valid guess. Test it a few times to make sure it works." 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": null, 98 | "metadata": { 99 | "collapsed": true, 100 | "jupyter": { 101 | "outputs_hidden": true 102 | } 103 | }, 104 | "outputs": [], 105 | "source": [ 106 | "while True:\n", 107 | " \n", 108 | " pass" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "metadata": {}, 114 | "source": [ 115 | "#### Write a `while` loop that compares the player's guess to our number. If the player guesses correctly, break from the loop. Otherwise, tell the player if they're warmer or colder, and continue asking for guesses.\n", 116 | "\n", 117 | "Some hints:\n", 118 | "* it may help to sketch out all possible combinations on paper first!\n", 119 | "* you can use the `abs()` function to find the positive difference between two numbers\n", 120 | "* if you append all new guesses to the list, then the previous guess is given as `guesses[-2]`" 121 | ] 122 | }, 123 | { 124 | "cell_type": "code", 125 | "execution_count": null, 126 | "metadata": { 127 | "collapsed": true, 128 | "jupyter": { 129 | "outputs_hidden": true 130 | } 131 | }, 132 | "outputs": [], 133 | "source": [ 134 | "while True:\n", 135 | "\n", 136 | " # we can copy the code from above to take an input\n", 137 | "\n", 138 | " pass" 139 | ] 140 | }, 141 | { 142 | "cell_type": "markdown", 143 | "metadata": {}, 144 | "source": [ 145 | "That's it! You've just programmed your first game!\n", 146 | "\n", 147 | "In the next section we'll learn how to turn some of these repetitive actions into *functions* that can be called whenever we need them." 148 | ] 149 | }, 150 | { 151 | "cell_type": "markdown", 152 | "metadata": {}, 153 | "source": [ 154 | "### Good Job!" 155 | ] 156 | } 157 | ], 158 | "metadata": { 159 | "kernelspec": { 160 | "display_name": "Python 3 (ipykernel)", 161 | "language": "python", 162 | "name": "python3" 163 | }, 164 | "language_info": { 165 | "codemirror_mode": { 166 | "name": "ipython", 167 | "version": 3 168 | }, 169 | "file_extension": ".py", 170 | "mimetype": "text/x-python", 171 | "name": "python", 172 | "nbconvert_exporter": "python", 173 | "pygments_lexer": "ipython3", 174 | "version": "3.10.11" 175 | } 176 | }, 177 | "nbformat": 4, 178 | "nbformat_minor": 4 179 | } 180 | -------------------------------------------------------------------------------- /practices/object_oriented_programming.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Object Oriented Programming Challenge\n", 8 | "\n", 9 | "For this challenge, create a bank account class that has two attributes:\n", 10 | "\n", 11 | "* owner\n", 12 | "* balance\n", 13 | "\n", 14 | "and two methods:\n", 15 | "\n", 16 | "* deposit\n", 17 | "* withdraw\n", 18 | "\n", 19 | "As an added requirement, withdrawals may not exceed the available balance.\n", 20 | "\n", 21 | "Instantiate your class, make several deposits and withdrawals, and test to make sure the account can't be overdrawn.\n", 22 | "\n", 23 | "Also you need to take care of \"__str__\" and \"__repr__\" dunder methods" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": 1, 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "class Account:\n", 33 | " pass" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 2, 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [ 42 | "# 1. Instantiate the class\n", 43 | "acct1 = Account('Ali',100)" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": 3, 49 | "metadata": {}, 50 | "outputs": [ 51 | { 52 | "name": "stdout", 53 | "output_type": "stream", 54 | "text": [ 55 | "Account owner: Jose\n", 56 | "Account balance: $100\n" 57 | ] 58 | } 59 | ], 60 | "source": [ 61 | "# 2. Print the object\n", 62 | "print(acct1)" 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": 4, 68 | "metadata": {}, 69 | "outputs": [ 70 | { 71 | "data": { 72 | "text/plain": [ 73 | "'Jose'" 74 | ] 75 | }, 76 | "execution_count": 4, 77 | "metadata": {}, 78 | "output_type": "execute_result" 79 | } 80 | ], 81 | "source": [ 82 | "# 3. Show the account owner attribute\n", 83 | "acct1.owner" 84 | ] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "execution_count": 5, 89 | "metadata": {}, 90 | "outputs": [ 91 | { 92 | "data": { 93 | "text/plain": [ 94 | "100" 95 | ] 96 | }, 97 | "execution_count": 5, 98 | "metadata": {}, 99 | "output_type": "execute_result" 100 | } 101 | ], 102 | "source": [ 103 | "# 4. Show the account balance attribute\n", 104 | "acct1.balance" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": 6, 110 | "metadata": {}, 111 | "outputs": [ 112 | { 113 | "name": "stdout", 114 | "output_type": "stream", 115 | "text": [ 116 | "Deposit Accepted\n" 117 | ] 118 | } 119 | ], 120 | "source": [ 121 | "# 5. Make a series of deposits and withdrawals\n", 122 | "acct1.deposit(50)" 123 | ] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": 7, 128 | "metadata": {}, 129 | "outputs": [ 130 | { 131 | "name": "stdout", 132 | "output_type": "stream", 133 | "text": [ 134 | "Withdrawal Accepted\n" 135 | ] 136 | } 137 | ], 138 | "source": [ 139 | "acct1.withdraw(75)" 140 | ] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "execution_count": 8, 145 | "metadata": {}, 146 | "outputs": [ 147 | { 148 | "name": "stdout", 149 | "output_type": "stream", 150 | "text": [ 151 | "Funds Unavailable!\n" 152 | ] 153 | } 154 | ], 155 | "source": [ 156 | "# 6. Make a withdrawal that exceeds the available balance\n", 157 | "acct1.withdraw(500)" 158 | ] 159 | } 160 | ], 161 | "metadata": { 162 | "kernelspec": { 163 | "display_name": "Python 3 (ipykernel)", 164 | "language": "python", 165 | "name": "python3" 166 | }, 167 | "language_info": { 168 | "codemirror_mode": { 169 | "name": "ipython", 170 | "version": 3 171 | }, 172 | "file_extension": ".py", 173 | "mimetype": "text/x-python", 174 | "name": "python", 175 | "nbconvert_exporter": "python", 176 | "pygments_lexer": "ipython3", 177 | "version": "3.10.11" 178 | } 179 | }, 180 | "nbformat": 4, 181 | "nbformat_minor": 4 182 | } 183 | -------------------------------------------------------------------------------- /practices/objects_and_data_structures.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Objects and Data Structures Assessment Test" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": { 13 | "collapsed": true, 14 | "jupyter": { 15 | "outputs_hidden": true 16 | } 17 | }, 18 | "source": [ 19 | "## Test your knowledge. \n", 20 | "\n", 21 | "** Answer the following questions **" 22 | ] 23 | }, 24 | { 25 | "cell_type": "markdown", 26 | "metadata": { 27 | "collapsed": true, 28 | "jupyter": { 29 | "outputs_hidden": true 30 | } 31 | }, 32 | "source": [ 33 | "Write (or just say out loud to yourself) a brief description of all the following Object Types and Data Structures we've learned about. You can edit the cell below by double clicking on it. Really this is just to test if you know the difference between these, so feel free to just think about it, since your answers are self-graded." 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "Double Click HERE to edit this markdown cell and write answers.\n", 41 | "\n", 42 | "Numbers:\n", 43 | "\n", 44 | "Strings:\n", 45 | "\n", 46 | "Lists:\n", 47 | "\n", 48 | "Tuples:\n", 49 | "\n", 50 | "Dictionaries:\n" 51 | ] 52 | }, 53 | { 54 | "cell_type": "markdown", 55 | "metadata": {}, 56 | "source": [ 57 | "## Numbers\n", 58 | "\n", 59 | "Write an equation that uses multiplication, division, an exponent, addition, and subtraction that is equal to 100.25.\n", 60 | "\n", 61 | "Hint: This is just to test your memory of the basic arithmetic commands, work backwards from 100.25" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": null, 67 | "metadata": { 68 | "collapsed": true, 69 | "jupyter": { 70 | "outputs_hidden": true 71 | } 72 | }, 73 | "outputs": [], 74 | "source": [] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "metadata": {}, 79 | "source": [ 80 | "Answer these 3 questions without typing code. Then type code to check your answer.\n", 81 | "\n", 82 | " What is the value of the expression 4 * (6 + 5)\n", 83 | " \n", 84 | " What is the value of the expression 4 * 6 + 5 \n", 85 | " \n", 86 | " What is the value of the expression 4 + 6 * 5 " 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": null, 92 | "metadata": { 93 | "collapsed": true, 94 | "jupyter": { 95 | "outputs_hidden": true 96 | } 97 | }, 98 | "outputs": [], 99 | "source": [] 100 | }, 101 | { 102 | "cell_type": "markdown", 103 | "metadata": {}, 104 | "source": [ 105 | "What is the *type* of the result of the expression 3 + 1.5 + 4?Operator | Description | Example | \n", 479 | "
---|---|---|
== | \n", 482 | "If the values of two operands are equal, then the condition becomes true. | \n", 483 | "(a == b) is not true. | \n", 484 | "
!= | \n", 487 | "If values of two operands are not equal, then condition becomes true. | \n", 488 | "(a != b) is true. | \n", 489 | "
> | \n", 492 | "If the value of left operand is greater than the value of right operand, then condition becomes true. | \n", 493 | "(a > b) is not true. | \n", 494 | "
< | \n", 497 | "If the value of left operand is less than the value of right operand, then condition becomes true. | \n", 498 | "(a < b) is true. | \n", 499 | "
>= | \n", 502 | "If the value of left operand is greater than or equal to the value of right operand, then condition becomes true. | \n", 503 | "(a >= b) is not true. | \n", 504 | "
<= | \n", 507 | "If the value of left operand is less than or equal to the value of right operand, then condition becomes true. | \n", 508 | "(a <= b) is true. | \n", 509 | "
for
, .split(), and if
to create a Statement that will print out words that start with 's':**"
22 | ]
23 | },
24 | {
25 | "cell_type": "code",
26 | "execution_count": null,
27 | "metadata": {
28 | "collapsed": true,
29 | "jupyter": {
30 | "outputs_hidden": true
31 | }
32 | },
33 | "outputs": [],
34 | "source": [
35 | "st = 'Print only the words that start with s in this sentence'"
36 | ]
37 | },
38 | {
39 | "cell_type": "code",
40 | "execution_count": null,
41 | "metadata": {
42 | "collapsed": true,
43 | "jupyter": {
44 | "outputs_hidden": true
45 | }
46 | },
47 | "outputs": [],
48 | "source": [
49 | "#Code here"
50 | ]
51 | },
52 | {
53 | "cell_type": "markdown",
54 | "metadata": {},
55 | "source": [
56 | "______\n",
57 | "**Use range() to print all the even numbers from 0 to 10.**"
58 | ]
59 | },
60 | {
61 | "cell_type": "code",
62 | "execution_count": null,
63 | "metadata": {
64 | "collapsed": true,
65 | "jupyter": {
66 | "outputs_hidden": true
67 | }
68 | },
69 | "outputs": [],
70 | "source": [
71 | "#Code Here"
72 | ]
73 | },
74 | {
75 | "cell_type": "markdown",
76 | "metadata": {},
77 | "source": [
78 | "___\n",
79 | "**Use a List Comprehension to create a list of all numbers between 1 and 50 that are divisible by 3.**"
80 | ]
81 | },
82 | {
83 | "cell_type": "code",
84 | "execution_count": null,
85 | "metadata": {
86 | "collapsed": true,
87 | "jupyter": {
88 | "outputs_hidden": true
89 | }
90 | },
91 | "outputs": [],
92 | "source": [
93 | "#Code in this cell\n",
94 | "[]"
95 | ]
96 | },
97 | {
98 | "cell_type": "markdown",
99 | "metadata": {},
100 | "source": [
101 | "_____\n",
102 | "**Go through the string below and if the length of a word is even print \"even!\"**"
103 | ]
104 | },
105 | {
106 | "cell_type": "code",
107 | "execution_count": null,
108 | "metadata": {
109 | "collapsed": true,
110 | "jupyter": {
111 | "outputs_hidden": true
112 | }
113 | },
114 | "outputs": [],
115 | "source": [
116 | "st = 'Print every word in this sentence that has an even number of letters'"
117 | ]
118 | },
119 | {
120 | "cell_type": "code",
121 | "execution_count": null,
122 | "metadata": {
123 | "collapsed": true,
124 | "jupyter": {
125 | "outputs_hidden": true
126 | }
127 | },
128 | "outputs": [],
129 | "source": [
130 | "#Code in this cell"
131 | ]
132 | },
133 | {
134 | "cell_type": "markdown",
135 | "metadata": {},
136 | "source": [
137 | "____\n",
138 | "**Write a program that prints the integers from 1 to 100. But for multiples of three print \"Fizz\" instead of the number, and for the multiples of five print \"Buzz\". For numbers which are multiples of both three and five print \"FizzBuzz\".**"
139 | ]
140 | },
141 | {
142 | "cell_type": "code",
143 | "execution_count": null,
144 | "metadata": {
145 | "collapsed": true,
146 | "jupyter": {
147 | "outputs_hidden": true
148 | }
149 | },
150 | "outputs": [],
151 | "source": [
152 | "#Code in this cell"
153 | ]
154 | },
155 | {
156 | "cell_type": "markdown",
157 | "metadata": {},
158 | "source": [
159 | "____\n",
160 | "**Use List Comprehension to create a list of the first letters of every word in the string below:**"
161 | ]
162 | },
163 | {
164 | "cell_type": "code",
165 | "execution_count": null,
166 | "metadata": {
167 | "collapsed": true,
168 | "jupyter": {
169 | "outputs_hidden": true
170 | }
171 | },
172 | "outputs": [],
173 | "source": [
174 | "st = 'Create a list of the first letters of every word in this string'"
175 | ]
176 | },
177 | {
178 | "cell_type": "code",
179 | "execution_count": null,
180 | "metadata": {
181 | "collapsed": true,
182 | "jupyter": {
183 | "outputs_hidden": true
184 | }
185 | },
186 | "outputs": [],
187 | "source": [
188 | "#Code in this cell"
189 | ]
190 | },
191 | {
192 | "cell_type": "markdown",
193 | "metadata": {},
194 | "source": [
195 | "### Great Job!"
196 | ]
197 | }
198 | ],
199 | "metadata": {
200 | "kernelspec": {
201 | "display_name": "Python 3 (ipykernel)",
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.10.11"
216 | }
217 | },
218 | "nbformat": 4,
219 | "nbformat_minor": 4
220 | }
221 |
--------------------------------------------------------------------------------