You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<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>
<divclass="sourceCode cell-code" id="cb1"><preclass="sourceCode python code-with-copy"><codeclass="sourceCode python"><spanid="cb1-1"><ahref="#cb1-1" aria-hidden="true" tabindex="-1"></a><spanclass="co"># Decode a secret message by following a series of instructions.</span></span>
309
309
<spanid="cb1-2"><ahref="#cb1-2" aria-hidden="true" tabindex="-1"></a><spanclass="co"># Each instruction requires you to use different operations and methods.</span></span>
310
310
<spanid="cb1-3"><ahref="#cb1-3" aria-hidden="true" tabindex="-1"></a><spanclass="co"># The encoded message is:</span></span>
@@ -347,7 +347,7 @@ <h1>Decoding secret messages with methods</h1>
<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>
<divclass="sourceCode cell-code" id="cb2"><preclass="sourceCode python code-with-copy"><codeclass="sourceCode python"><spanid="cb2-1"><ahref="#cb2-1" aria-hidden="true" tabindex="-1"></a><spanclass="co"># Use if-elif-else statements to classify the temperature</span></span>
<spanid="cb2-8"><ahref="#cb2-8" aria-hidden="true" tabindex="-1"></a><spanclass="co"># a) </span><spanclass="al">TODO</span><spanclass="co">: Formulate a small programm that asks the user for a temperature and then prints the corresponding classification.</span></span>
359
359
<spanid="cb2-9"><ahref="#cb2-9" aria-hidden="true" tabindex="-1"></a><spanclass="co"># Your code here</span></span>
<spanid="cb2-11"><ahref="#cb2-11" aria-hidden="true" tabindex="-1"></a><spanclass="co"># b) </span><spanclass="al">TODO</span><spanclass="co">: Test your function with -5, 15 and 35 as temperature</span></span>
362
-
<spanid="cb2-12"><ahref="#cb2-12" aria-hidden="true" tabindex="-1"></a><spanclass="co"># Your code here</span></span>
361
+
<spanid="cb2-11"><ahref="#cb2-11" aria-hidden="true" tabindex="-1"></a><spanclass="co"># b) </span><spanclass="al">TODO</span><spanclass="co">: Test your code with -5, 15 and 35 as temperature</span></span>
362
+
<spanid="cb2-12"><ahref="#cb2-12" aria-hidden="true" tabindex="-1"></a><spanclass="co"># Your code has to be placed above the code from the previous task</span></span>
<spanid="cb2-14"><ahref="#cb2-14" aria-hidden="true" tabindex="-1"></a><spanclass="co"># c) </span><spanclass="al">TODO</span><spanclass="co">: Add a feature that asks the user if they want to continue and then repeats the programm if they type "yes". </span></span>
365
365
<spanid="cb2-15"><ahref="#cb2-15" aria-hidden="true" tabindex="-1"></a><spanclass="co"># If the user does not want to continue, the programm should end.</span></span>
<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>
<divclass="sourceCode cell-code" id="cb3"><preclass="sourceCode python code-with-copy"><codeclass="sourceCode python"><spanid="cb3-1"><ahref="#cb3-1" aria-hidden="true" tabindex="-1"></a><spanclass="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>
374
374
<spanid="cb3-2"><ahref="#cb3-2" aria-hidden="true" tabindex="-1"></a><spanclass="co"># Start by asking for their names. Then, ask the game master to input the secret number between 1 and 20. </span></span>
375
375
<spanid="cb3-3"><ahref="#cb3-3" aria-hidden="true" tabindex="-1"></a><spanclass="co"># Make sure, that the number is not printed! Then, ask the player to guess the number. </span></span>
0 commit comments