Skip to content

Commit 2c8c19f

Browse files
improved tutorial 3
1 parent afc02a9 commit 2c8c19f

25 files changed

+83
-48
lines changed
-6 Bytes
Binary file not shown.
-3 Bytes
Binary file not shown.

docs/part-02/lecture-control.html

Lines changed: 26 additions & 26 deletions
Large diffs are not rendered by default.

docs/part-02/lecture-control.pdf

-1 Bytes
Binary file not shown.

docs/part-02/tutorial-control.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ <h1>Introduction</h1>
304304
<section id="decoding-secret-messages-with-methods" class="level1">
305305
<h1>Decoding secret messages with methods</h1>
306306
<p>In this exercise, we’ll practice string manipulation and slicing. You’ll work with a secret message encoded using various string operations and learn how to apply some new methods like <code>title()</code>, <code>replace()</code> and <code>count()</code>. By following a series of steps, you’ll gradually decode the message. Let’s begin with the encoded message and work through each decoding step:</p>
307-
<div id="7a732846" class="cell" data-execution_count="1">
307+
<div id="7a732846" class="cell" data-execution_count="2">
308308
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Decode a secret message by following a series of instructions.</span></span>
309309
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="co"># Each instruction requires you to use different operations and methods.</span></span>
310310
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="co"># The encoded message is:</span></span>
@@ -347,7 +347,7 @@ <h1>Decoding secret messages with methods</h1>
347347
<section id="classifying-temperatures" class="level1">
348348
<h1>Classifying temperatures</h1>
349349
<p>In this exercise, we’ll practice using conditional statements to classify temperatures into different categories. We’ll create a program that takes a temperature input from the user and provides a classification based on the temperature range. This exercise will help you understand how to use if-elif-else statements, handle user input, and implement a simple loop for program repetition.</p>
350-
<div id="c9339acc" class="cell" data-execution_count="2">
350+
<div id="c9339acc" class="cell" data-execution_count="3">
351351
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Use if-elif-else statements to classify the temperature</span></span>
352352
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="co"># Below 0: "Freezing"</span></span>
353353
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="co"># 0-10: "Cold"</span></span>
@@ -369,7 +369,7 @@ <h1>Classifying temperatures</h1>
369369
<section id="number-guessing-game" class="level1">
370370
<h1>Number guessing game</h1>
371371
<p>In this exercise, we’ll create an interactive number guessing game for two players. This game will help you practice using loops, conditional statements, and user input handling. You’ll also learn how to implement a simple game logic and manage player turns. This exercise will reinforce your understanding of control structures and basic development concepts in Python.</p>
372-
<div id="ca9934a1" class="cell" data-execution_count="3">
372+
<div id="ca9934a1" class="cell" data-execution_count="4">
373373
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Create a number guessing game with 2 players. The first player is the game master and the second player is the guesser. </span></span>
374374
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="co"># Start by asking for their names. Then, ask the game master to input the secret number between 1 and 20. </span></span>
375375
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="co"># Make sure, that the number is not shown by adding at least 25 new lines after the input prompt. Then, ask the player to guess the number. </span></span>

docs/part-02/tutorial-control.pdf

1 Byte
Binary file not shown.

docs/part-03/lecture-functions-presentation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ <h2>Returning None</h2>
785785
</div>
786786
</div>
787787
<div class="fragment">
788-
<p><span class="task">&gt; Grouptask:</span> Come up with a function that checks whether a number is positive or negative. It returns <code>"positive"</code> for positive numbers and <code>"negative"</code> for negative numbers.</p>
788+
<p><span class="task">&gt; Grouptask:</span> Come up with a function that checks whether a number is positive or negative. It returns <code>"positive"</code> for positive numbers and <code>"negative"</code> for negative numbers. If the number is zero, it returns <code>None</code>.</p>
789789
</div>
790790
<div class="fragment">
791791
<div class="callout callout-tip callout-titled callout-style-default">

docs/part-03/lecture-functions.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ <h2 class="anchored" data-anchor-id="returning-none">Returning None</h2>
683683
</div>
684684
</div>
685685
<p>. . .</p>
686-
<p><span class="task">&gt; Grouptask:</span> Come up with a function that checks whether a number is positive or negative. It returns <code>"positive"</code> for positive numbers and <code>"negative"</code> for negative numbers.</p>
686+
<p><span class="task">&gt; Grouptask:</span> Come up with a function that checks whether a number is positive or negative. It returns <code>"positive"</code> for positive numbers and <code>"negative"</code> for negative numbers. If the number is zero, it returns <code>None</code>.</p>
687687
<p>. . .</p>
688688
<div class="callout callout-style-default callout-tip callout-titled">
689689
<div class="callout-header d-flex align-content-center">

docs/part-03/lecture-functions.pdf

56 Bytes
Binary file not shown.

docs/part-03/tutorial-functions.html

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ <h1>Introduction</h1>
304304
<section id="small-functions-for-various-tasks" class="level1">
305305
<h1>Small Functions for various tasks</h1>
306306
<p>In this exercise, you will practice writing small functions for various tasks. You will also practice using the <code>return</code> statement to return a value from a function and the <code>global</code> keyword to modify a global variable.</p>
307-
<div id="3cb853f7" class="cell" data-execution_count="1">
307+
<div id="65aee5f2" class="cell" data-execution_count="1">
308308
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># a) </span><span class="al">TODO</span><span class="co">: Write a function that takes two numbers as input and returns their squared sum.</span></span>
309309
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="co"># Your code here</span></span>
310310
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a></span>
@@ -337,7 +337,7 @@ <h1>Small Functions for various tasks</h1>
337337
<section id="different-classes-for-different-tasks" class="level1">
338338
<h1>Different classes for different tasks</h1>
339339
<p>In this exercise, you will practice creating different classes for different tasks. You will create a class for a bank account, a class for a car, and a class for a computer.</p>
340-
<div id="07750367" class="cell" data-execution_count="2">
340+
<div id="73fe217c" class="cell" data-execution_count="2">
341341
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co"># a) # </span><span class="al">TODO</span><span class="co">: Create a class called 'Book' with the following specifications:</span></span>
342342
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="co"># - It should have attributes for 'title', 'author', and 'pages'</span></span>
343343
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="co"># - Include a method called 'display_info' that prints all the book's information</span></span>
@@ -363,11 +363,14 @@ <h1>Different classes for different tasks</h1>
363363
<section id="rebuild-the-number-guessing-game" class="level1">
364364
<h1>Rebuild the number guessing game</h1>
365365
<p>Remember the number guessing game from the previous tutorial? Well, it’s time to rebuild it. This time, we will use functions to organize the code and make it more reusable. You will learn how to use functions to modularize your code and make it more readable.</p>
366-
<div id="7552d01c" class="cell" data-execution_count="3">
367-
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># </span><span class="al">TODO</span><span class="co">: Start by looking at your code from the previous tutorial and think about the different steps that you implemented. </span></span>
368-
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="co"># a) Try to modularize each step of the game into a separate function. Name the functions appropriately, to make clear what they do.</span></span>
369-
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="co"># b) Enhance the game by adding difficulty levels as described in the bonus task from the previous tutorial. The difference here is that the difficulty level should be given as a parameter to a function. If no difficulty level is given, i.e. the game master just enters an empty input, the function should use a default value of "Medium".</span></span>
370-
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="co"># Your code here</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
366+
<div id="0b5aee9a" class="cell" data-execution_count="3">
367+
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Start by looking at your code from the previous tutorial and think about the different steps that you implemented. </span></span>
368+
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="co"># a) </span><span class="al">TODO</span><span class="co">: Try to modularize each step of the game into a separate function. </span></span>
369+
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="co"># - Name the functions appropriately, to make clear what they do.</span></span>
370+
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="co"># b) </span><span class="al">TODO</span><span class="co">: Enhance the game by adding difficulty levels as described in the bonus task from the previous tutorial. </span></span>
371+
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="co"># - The difference here is that the difficulty level should be given as a parameter to a function. </span></span>
372+
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a><span class="co"># - If no difficulty level is given, i.e. the game master just enters an empty input, the function should use a default value of "Medium".</span></span>
373+
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a><span class="co"># Your code here</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
371374
</div>
372375
</section>
373376
<section id="section" class="level1">

0 commit comments

Comments
 (0)