From cf92d8fd476eda725ff6abab018b3b0ebce9d616 Mon Sep 17 00:00:00 2001 From: woose Date: Sun, 23 Feb 2025 11:14:46 +0300 Subject: [PATCH] Updated M module1.ipynb --- module1.ipynb | 123 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 120 insertions(+), 3 deletions(-) diff --git a/module1.ipynb b/module1.ipynb index 490df67..a2467dd 100644 --- a/module1.ipynb +++ b/module1.ipynb @@ -154,19 +154,136 @@ "\n", "     return True" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "\n", + "This reading contains the code used in the instructional videos from [**Applying Changes** Opens in a new tab](https://www.coursera.org/learn/introduction-git-github/lecture/qIzdp/applying-changes).\n", + "\n", + "## Introduction\n", + "\n", + "This follow-along reading is organized to match the content in the video that follows. It contains the same code shown in the next video. These code blocks will provide you with the opportunity to see how the code is written and can be used as a reference as you work through the course. \n", + "\n", + "You can follow along in the reading as the instructor discusses the code or review the code after watching the video.\n", + "\n", + "\n", + "\n", + "cat cpu\\_usage.py \n", + "\n", + "\n", + "\n", + "cat cpu\\_usage.py \n", + "\n", + "**Code output:**\n", + "\n", + "#!/usr/bin/env python3\n", + "\n", + "import psutil\n", + "\n", + "def check\\_cpu\\_usage(percent):\n", + "\n", + "    usage = psutil.cpu\\_percent()\n", + "\n", + "    return usage < percent\n", + "\n", + "if not check\\_cpu\\_usage(75):\n", + "\n", + "    print(\"ERROR! CPU is overloaded\")\n", + "\n", + "else:\n", + "\n", + "    print(\"Everything ok\")\n", + "\n", + "1\n", + "\n", + "cat cpu\\_usage.diff \n", + "\n", + "\n", + "\n", + "**Code output:**\n", + "\n", + "\\--- cpu\\_usage.py 2019-06-23 08:16:04.666457429 -0700\n", + "\n", + "+++ cpu\\_usage\\_fixed.py 2019-06-23 08:15:37.534370071 -0700\n", + "\n", + "@@ -2,7 +2,8 @@\n", + "\n", + " import psutil\n", + "\n", + " def check\\_cpu\\_usage(percent):\n", + "\n", + "\\-    usage = psutil.cpu\\_percent()\n", + "\n", + "+    usage = psutil.cpu\\_percent(1)\n", + "\n", + "+    print(\"DEBUG: usage: {}\".format(usage))\n", + "\n", + "     return usage < percent\n", + "\n", + " if not check\\_cpu\\_usage(75):\n", + "\n", + "1\n", + "\n", + "patch cpu\\_usage.py < cpu\\_usage.diff \n", + "\n", + "\n", + "\n", + "**Code output:**\n", + "\n", + "patching file cpu\\_usage.py\n", + "\n", + "1\n", + "\n", + "cat cpu\\_usage.py \n", + "\n", + "\n", + "\n", + "**Code output:**\n", + "\n", + "#!/usr/bin/env python3\n", + "\n", + "import psutil\n", + "\n", + "def check\\_cpu\\_usage(percent):\n", + "\n", + "    usage = psutil.cpu\\_percent(1)\n", + "\n", + "    print(\"DEBUG: usage: {}\".format(usage))\n", + "\n", + "    return usage < percent\n", + "\n", + "if not check\\_cpu\\_usage(75):\n", + "\n", + "    print(\"ERROR! CPU is overloaded\")\n", + "\n", + "else:\n", + "\n", + "    print(\"Everything ok\")" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", "name": "python", - "version": "3.12.3" + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.1" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 }