diff --git a/f22/meena_lec_notes/lec-10/lec_10_Iteration_1.ipynb b/f22/meena_lec_notes/lec-10/lec_10_Iteration_1.ipynb index 9e5b6930262d0076c3c5ac9ae8765109b3b0f142..9d8dab9725c14a6f2ebf2bede3a882708008a89a 100644 --- a/f22/meena_lec_notes/lec-10/lec_10_Iteration_1.ipynb +++ b/f22/meena_lec_notes/lec-10/lec_10_Iteration_1.ipynb @@ -1,11 +1,17 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "id": "dd1c3a1b", "metadata": {}, "source": [ - "# Iteration 1" + "# Iteration 1\n", + "\n", + "## Readings:\n", + "\n", + "- Chapter 7 of Think Python\n", + "- Chapter 6.1 to 6.3 of Python for Everybody" ] }, { @@ -135,17 +141,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "How many seconds? 10\n", - "10 seconds left\n", - "9 seconds left\n", - "8 seconds left\n", - "7 seconds left\n", - "6 seconds left\n", + "How many seconds? 5\n", "5 seconds left\n", "4 seconds left\n", "3 seconds left\n", "2 seconds left\n", - "1 seconds left\n" + "1 seconds left\n", + "BEEP BEEP BEEP BEEP BEEP BEEP BEEP BEEP BEEP BEEP \n" ] } ], @@ -157,13 +159,18 @@ "remaining = start\n", "while remaining >= 1: # TODO: iterate from start to 1\n", " print(remaining, \"seconds left\")\n", - " # TODO: update loop control variable's value to make progress towards terminating the loop, \n", - " # that is turning loop condition to False\n", + " # TODO: update loop control variable's value to make progress towards terminating \n", + " # the loop, that is turning loop condition to False\n", " remaining -= 1\n", " # TODO: now run the cell to see the output. Didn't it go too fast?\n", " # TODO: call time module sleep function, by passing 1 as argument\n", " time.sleep(1)\n", "\n", + "# TODO: print \"BEEP BEEP BEEP ...\" (10 BEEPS) without typing BEEP 10 times\n", + "# What string operator can you use here?\n", + "print(\"BEEP \" * 10)\n", + "\n", + "# wake up call\n", "beeper.beep(10) # Only works on MAC laptops, sorry Windows users :(" ] }, @@ -517,13 +524,23 @@ "source": [ "print(\"Prime numbers:\")\n", "number = 2\n", - "while number <= 50: # TODO: comment out this while loop and write equivalent for loop using range\n", + "# TODO: comment out this while loop and write equivalent for loop using range\n", + "#while number <= 50: \n", + "for number in range(2, 51):\n", " if is_prime(number):\n", " print(number, \"is prime\")\n", " else:\n", " print(number, \"is not prime\")\n", " number += 1" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "aa37a65c", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -542,7 +559,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.7" + "version": "3.9.12" } }, "nbformat": 4, diff --git a/f22/meena_lec_notes/lec-10/lec_10_Iteration_1_template.ipynb b/f22/meena_lec_notes/lec-10/lec_10_Iteration_1_template.ipynb index 25e3ce581b81173b2c06a458f4299428c90655c5..e64eca32afb7dd374c7077c46a611a69a71c784e 100644 --- a/f22/meena_lec_notes/lec-10/lec_10_Iteration_1_template.ipynb +++ b/f22/meena_lec_notes/lec-10/lec_10_Iteration_1_template.ipynb @@ -5,7 +5,12 @@ "id": "dd1c3a1b", "metadata": {}, "source": [ - "# Iteration 1" + "# Iteration 1\n", + "\n", + "## Readings:\n", + "\n", + "- Chapter 7 of Think Python\n", + "- Chapter 6.1 to 6.3 of Python for Everybody" ] }, { @@ -116,12 +121,16 @@ "remaining = ???\n", "while ???: # TODO: iterate from start to 1\n", " print(remaining, \"seconds left\")\n", - " # TODO: update loop control variable's value to make progress towards terminating the loop, \n", - " # that is turning loop condition to False\n", + " # TODO: update loop control variable's value to make progress towards terminating \n", + " # the loop, that is turning loop condition to False\n", " remaining -= ???\n", " # TODO: now run the cell to see the output. Didn't it go too fast?\n", " # TODO: call time module sleep function, by passing 1 as argument\n", "\n", + "# TODO: print \"BEEP BEEP BEEP ...\" (10 BEEPS) without typing BEEP 10 times\n", + "# What string operator can you use here?\n", + "\n", + "\n", "# wake up call" ] }, @@ -338,7 +347,8 @@ "source": [ "print(\"Prime numbers:\")\n", "number = 2\n", - "while number <= 50: # TODO: comment out this while loop and write equivalent for loop using range\n", + "# TODO: comment out this while loop and write equivalent for loop using range\n", + "while number <= 50: \n", " if is_prime(number):\n", " print(number, \"is prime\")\n", " else:\n", @@ -363,7 +373,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.7" + "version": "3.9.12" } }, "nbformat": 4,