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
<li>The largest provider for git repositories owned by Microsoft. A lot of open source projects are hosted here and you can read the code.</li>
325
325
</ul></li>
326
+
<li><ahref="https://codewars.com">Codewars</a>
327
+
<ul>
328
+
<li>A platform to improve your coding skills by solving challenges. You can compete with others, see how other people solved the challenges and read and learn from the code.</li>
<p>In this exercise, we’ll explore basic string operations in Python. Strings are one of the most common data types in programming, and Python provides a variety of ways to manipulate them. We’ll practice concatenation (joining strings together), indexing (accessing individual characters), slicing (extracting portions of a string), finding the length of a string, and string repetition.</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"># a) Concatenation</span></span>
303
303
<spanid="cb1-2"><ahref="#cb1-2" aria-hidden="true" tabindex="-1"></a><spanclass="co"># </span><spanclass="al">TODO</span><spanclass="co">: Concatenate "Coffee" and " is fun!" in the 'text' variable</span></span>
304
304
<spanid="cb1-3"><ahref="#cb1-3" aria-hidden="true" tabindex="-1"></a><spanclass="co"># Print the result</span></span>
<spanid="cb1-20"><ahref="#cb1-20" aria-hidden="true" tabindex="-1"></a><spanclass="co"># Your code here</span></span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
322
322
</div>
323
323
</section>
@@ -334,10 +334,10 @@ <h1>Formatted Output</h1>
334
334
</div>
335
335
</div>
336
336
<divclass="callout-body-container callout-body">
337
-
<p>Use the <code>f-string</code> method to format the output. New is the <code>f"{your_variable:.2f}"</code> syntax, which you need to format the variable to two decimal places.</p>
337
+
<p>Use the <code>f-string</code> method to format the output. New is the <code>f"{your_variable:.2f}"</code> syntax, which you can use to format the variable to two decimal places and the <code>f"{your_variable:<20}"</code> syntax, which you can use to format the variable to left-aligned within 20 spaces.</p>
<p>In this exercise, we’ll practice using arithmetic operations in Python to solve several real-world problems. These calculations will help you understand how to apply basic mathematical operations in programming and how to use variables to store and manipulate numerical data. We’ll cover temperature conversion, geometric calculations, financial computations, and time calculations.</p>
<p>In this exercise, we’ll create a simple Body Mass Index (BMI) calculator. BMI is a measure that uses your height and weight to work out if your weight is healthy (although it has its limitations). The BMI is calculated by dividing a person’s weight (in kilograms) by the square of their height (in meters). This exercise will reinforce your understanding of arithmetic operations, user input, and string formatting while introducing you to a real-world health metric calculation.</p>
<spanid="cb4-2"><ahref="#cb4-2" aria-hidden="true" tabindex="-1"></a><spanclass="co"># - Ask for weight in kg</span></span>
415
415
<spanid="cb4-3"><ahref="#cb4-3" aria-hidden="true" tabindex="-1"></a><spanclass="co"># - Ask for height in meters</span></span>
@@ -422,7 +422,7 @@ <h1>BMI Calculator</h1>
422
422
</section>
423
423
<sectionid="thats-it" class="level1">
424
424
<h1>That’s it!</h1>
425
-
<p>You can’t find the solutions to these exercises online, but we will discuss them in today’s tutorial or next week. Alternatively, you can ask ChatGPT or Claude to explain them to you. Remember, the goal is not just to complete the exercises, but to understand the concepts and improve your programming abilities.</p>
425
+
<p>You can find the solutions to these exercises online in the associated GitHub repository, but we will also quickly go over them in next week’s tutorial. To access the solutions, click on the Guthub button on the lower right and search for the folder with today’s lecture and tutorial. Alternatively, you can ask ChatGPT or Claude to explain them to you. Remember, the goal is not just to complete the exercises, but to understand the concepts and improve your programming abilities.</p>
<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>
285
286
<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>
286
287
<spanid="cb1-3"><ahref="#cb1-3" aria-hidden="true" tabindex="-1"></a><spanclass="co"># The encoded message is:</span></span>
@@ -323,7 +324,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>
<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. Start by asking for their names. Then, ask the game master to input the secret number between 1 and 20. Make sure, that the number is not printed! Then, ask the player to guess the number. If the guess is too high or too low, provide feedback in order to help the player and let the player guess again. If the guess is correct, congratulate the player and end the game.</span></span>
<spanid="cb3-3"><ahref="#cb3-3" aria-hidden="true" tabindex="-1"></a><spanclass="co"># a) </span><spanclass="al">TODO</span><spanclass="co">: Your task list in more detail:</span></span>
<spanid="cb3-18"><ahref="#cb3-18" aria-hidden="true" tabindex="-1"></a><spanclass="co"># c) </span><spanclass="al">TODO</span><spanclass="co">: Play the game with someone sitting next to you.</span></span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
366
367
</div>
368
+
</section>
369
+
<sectionid="thats-it" class="level1">
370
+
<h1>That’s it!</h1>
371
+
<p>You can find the solutions to these exercises online in the associated GitHub repository, but we will also quickly go over them in next week’s tutorial. To access the solutions, click on the Guthub button on the lower right and search for the folder with today’s lecture and tutorial. Alternatively, you can ask ChatGPT or Claude to explain them to you. Remember, the goal is not just to complete the exercises, but to understand the concepts and improve your programming abilities.</p>
0 commit comments