From 802fc2784326b5b1f8cdd87ae3f93969d135f36b Mon Sep 17 00:00:00 2001 From: Katia Gatt Date: Sat, 13 Sep 2025 18:53:50 +0200 Subject: [PATCH] fixed md --- book/live_exercises/014.md | 50 +++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/book/live_exercises/014.md b/book/live_exercises/014.md index b537a84..d788876 100644 --- a/book/live_exercises/014.md +++ b/book/live_exercises/014.md @@ -31,14 +31,14 @@ There are two ways you can try this exercise, depending on whether you have an I ```python print("Hello world!") ``` -````md +```` -3. With this setup, tags can be added by opening the cell metadata (in JupyterLab or Jupyter Notebook: `View → Cell Toolbar → Tags`). +With this setup, tags can be added by opening the cell metadata (in JupyterLab or Jupyter Notebook: `View → Cell Toolbar → Tags`). ### Option 2: Using Jupytext in Markdown -4. If you don’t have JupyterLab or VS Code installed, you can still add code by writing a Markdown file with a Jupytext header. At the very top of your file (e.g. `book/live_code_tags.md`), add: +3. If you don’t have JupyterLab or VS Code installed, you can still add code by writing a Markdown file with a Jupytext header. At the very top of your file (e.g. `book/live_code_tags.md`), add: ```yaml --- @@ -55,7 +55,7 @@ kernelspec: --- ``` -5. Now you can insert executable code cells with tags like this: +4. Now you can insert executable code cells with tags like this: ````md ```{code-cell} ipython3 @@ -63,7 +63,7 @@ print("Hello world!") ``` ```` -6. With this setup, tags can be added directly into the code cell using `:tags:`. +With this setup, tags can be added directly into the code cell using `:tags:`. @@ -74,7 +74,7 @@ Now that you know how to create executable code cells, let’s explore the diffe ### `disable-execution-cell` -7. This tag is useful when you want a particular code cell to display content without being executed by readers. For example, let’s set up a new cell that prints the current date and time only once: +5. This tag is useful when you want a particular code cell to display content without being executed by readers. For example, let’s set up a new cell that prints the current date and time only once: **Option 1: Using JupyterLab or VS Code** @@ -86,7 +86,7 @@ import datetime current_time = datetime.datetime.now() print("This notebook was last updated at:", current_time) ``` -````md +```` *Remember to add the tag `disable-execution-cell` locally via the cell metadata (`View → Cell Toolbar → Tags`).* @@ -103,15 +103,15 @@ import datetime current_time = datetime.datetime.now() print("This notebook was last updated at:", current_time) ``` -````md +```` -8. Commit and rebuild your book and visit the page — notice that this particular cell can no longer be run when live code is activated. +6. Commit and rebuild your book and visit the page — notice that this particular cell can no longer be run when live code is activated. ### `disable-execution-page` -9. This tag is useful when you want all code cells on a page to be non-executable. This is handy if the code is used to build the page or provide context, but you don’t want readers to run it themselves. Add the tag `disable-execution-page` to any of the code cells in your file. +7. This tag is useful when you want all code cells on a page to be non-executable. This is handy if the code is used to build the page or provide context, but you don’t want readers to run it themselves. Add the tag `disable-execution-page` to any of the code cells in your file. -10. Commit and rebuild your book and visit the page — none of the cells should be executable now. +8. Commit and rebuild your book and visit the page — none of the cells should be executable now. ```{note} Remove this tag again before continuing, otherwise the next tags won’t have any effect. @@ -119,7 +119,7 @@ Remove this tag again before continuing, otherwise the next tags won’t have an ### `auto-execute-page` -11. This tag is useful when you want live code to start running automatically as soon as the page is opened. This is particularly helpful when using visualizations or interactive widgets that should initialize immediately. For example, let's set up a plot: +9. This tag is useful when you want live code to start running automatically as soon as the page is opened. This is particularly helpful when using visualizations or interactive widgets that should initialize immediately. For example, let's set up a plot: **Option 1: Using JupyterLab or VS Code** @@ -135,7 +135,7 @@ plt.plot(x, y) plt.title("Sine wave") plt.show() ``` -````md +```` *Remember to add the tag `auto-execute-page` to one of the cells via the cell metadata (`View → Cell Toolbar → Tags`).* @@ -156,16 +156,16 @@ plt.plot(x, y) plt.title("Sine wave") plt.show() ``` -````md +```` -12. Commit and rebuild your book and visit the page — the plot should appear automatically without needing to click the “launch” button. +10. Commit and rebuild your book and visit the page — the plot should appear automatically without needing to click the “launch” button. ### `thebe-init` -13. The `thebe-init` tag is useful when you want a specific cell to run automatically as soon as live coding starts. This is especially helpful for initializing variables that other cells depend on. For example, let's initialize a dataset of student names and their scores: +11. The `thebe-init` tag is useful when you want a specific cell to run automatically as soon as live coding starts. This is especially helpful for initializing variables that other cells depend on. For example, let's initialize a dataset of student names and their scores: **Option 1: Using JupyterLab or VS Code** @@ -177,7 +177,7 @@ scores = [85, 92, 78, 90] print("Initialized dataset with students and scores") ``` -````md +```` *Remember to add the tag `thebe-init` locally via the cell metadata (`View → Cell Toolbar → Tags`).* @@ -194,25 +194,25 @@ scores = [85, 92, 78, 90] print("Initialized dataset with students and scores") ``` -````md +```` -14. Commit and rebuild your book and visit the page — as soon as live code starts, this cell will run by itself. +12. Commit and rebuild your book and visit the page — as soon as live code starts, this cell will run by itself. ### `thebe-remove-input-init` -15. This tag works similarly to `thebe-init`, but the input (code) is hidden from students, so they only see the output. This is useful when you want to initialize variables or datasets without showing implementation details. To try this, simply replace the previous tag `thebe-init` with `thebe-remove-input-init` in the same cell from the previous example. +13. This tag works similarly to `thebe-init`, but the input (code) is hidden from students, so they only see the output. This is useful when you want to initialize variables or datasets without showing implementation details. To try this, simply replace the previous tag `thebe-init` with `thebe-remove-input-init` in the same cell from the previous example. -16. Commit and rebuild your book and visit the page — the cell will **run automatically**, but students will only see the output, not the code. +14. Commit and rebuild your book and visit the page — the cell will **run automatically**, but students will only see the output, not the code. -17. When you are ready, commit your changes to the repository by clicking on the green `Commit changes` button. +15. When you are ready, commit your changes to the repository by clicking on the green `Commit changes` button. -18. Add a commit message. +16. Add a commit message. -19. To see your changes, go to {octicon}`play` `Actions` - The most recent workflow run `overview.md / the commit message of the commit you just made` - Wait for it to finish - In the summary, click on the link of your book shown in the table `Branches deployed` and under `Primary book at root` (getting bored of waiting? There'll be exercising on doing this locally which prevents you from waiting). +17. To see your changes, go to {octicon}`play` `Actions` - The most recent workflow run `overview.md / the commit message of the commit you just made` - Wait for it to finish - In the summary, click on the link of your book shown in the table `Branches deployed` and under `Primary book at root` (getting bored of waiting? There'll be exercising on doing this locally which prevents you from waiting). -20. Do you see your change? If you don't see it click `CTRL`+`F5`/`Control`+`F5`to refresh the page. +18. Do you see your change? If you don't see it click `CTRL`+`F5`/`Control`+`F5`to refresh the page. ```{admonition} Check your understanding