Skip to content

Commit b472371

Browse files
added f strings in lecture 1
1 parent 9dc4acd commit b472371

File tree

111 files changed

+394
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+394
-214
lines changed

docs/general/literature.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ <h2 class="anchored" data-anchor-id="resources-1">Resources</h2>
323323
<ul>
324324
<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>
325325
</ul></li>
326+
<li><a href="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>
329+
</ul></li>
326330
</ul>
327331

328332

docs/part-01/lecture-introduction.html

Lines changed: 107 additions & 89 deletions
Large diffs are not rendered by default.
1.04 KB
Binary file not shown.

docs/part-01/lecture-presentation.html

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

docs/part-01/tutorial-introduction.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ <h2 class="anchored" data-anchor-id="tutorials-vs-assignments">Tutorials vs Assi
298298
<section id="basic-string-operations" class="level1">
299299
<h1>Basic String Operations</h1>
300300
<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>
301-
<div id="330bdd4c" class="cell" data-execution_count="2">
301+
<div id="bb46de3d" class="cell" data-execution_count="2">
302302
<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) Concatenation</span></span>
303303
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="co"># </span><span class="al">TODO</span><span class="co">: Concatenate "Coffee" and " is fun!" in the 'text' variable</span></span>
304304
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="co"># Print the result</span></span>
@@ -317,7 +317,7 @@ <h1>Basic String Operations</h1>
317317
<span id="cb1-16"><a href="#cb1-16" aria-hidden="true" tabindex="-1"></a><span class="co"># Your code here</span></span>
318318
<span id="cb1-17"><a href="#cb1-17" aria-hidden="true" tabindex="-1"></a></span>
319319
<span id="cb1-18"><a href="#cb1-18" aria-hidden="true" tabindex="-1"></a><span class="co"># e) Repetition</span></span>
320-
<span id="cb1-19"><a href="#cb1-19" aria-hidden="true" tabindex="-1"></a><span class="co"># </span><span class="al">TODO</span><span class="co">: Print 'Python' repeated 3 times</span></span>
320+
<span id="cb1-19"><a href="#cb1-19" aria-hidden="true" tabindex="-1"></a><span class="co"># </span><span class="al">TODO</span><span class="co">: Print 'Coffee' repeated 3 times</span></span>
321321
<span id="cb1-20"><a href="#cb1-20" 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>
322322
</div>
323323
</section>
@@ -334,10 +334,10 @@ <h1>Formatted Output</h1>
334334
</div>
335335
</div>
336336
<div class="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:&lt;20}"</code> syntax, which you can use to format the variable to left-aligned within 20 spaces.</p>
338338
</div>
339339
</div>
340-
<div id="384020b9" class="cell" data-execution_count="3">
340+
<div id="3ee05cbe" class="cell" data-execution_count="3">
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"># Create a receipt for a coffee shop purchase</span></span>
342342
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="co"># Use the following information:</span></span>
343343
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>item1 <span class="op">=</span> <span class="st">"Cappuccino"</span></span>
@@ -379,7 +379,7 @@ <h1>Formatted Output</h1>
379379
<section id="arithmetic-operations" class="level1">
380380
<h1>Arithmetic Operations</h1>
381381
<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>
382-
<div id="d819f389" class="cell" data-execution_count="4">
382+
<div id="41c9a930" class="cell" data-execution_count="4">
383383
<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"># a) Temperature Converter</span></span>
384384
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="co"># </span><span class="al">TODO</span><span class="co">: Convert 98.6°Fahrenheit to Celsius</span></span>
385385
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="co"># Formula: (°F - 32) * 5/9</span></span>
@@ -409,7 +409,7 @@ <h1>Arithmetic Operations</h1>
409409
<section id="bmi-calculator" class="level1">
410410
<h1>BMI Calculator</h1>
411411
<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>
412-
<div id="e34a98f8" class="cell" data-execution_count="5">
412+
<div id="b28ef4ea" class="cell" data-execution_count="5">
413413
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="co"># </span><span class="al">TODO</span><span class="co">: Implement a BMI calculator</span></span>
414414
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="co"># - Ask for weight in kg</span></span>
415415
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="co"># - Ask for height in meters</span></span>
@@ -422,7 +422,7 @@ <h1>BMI Calculator</h1>
422422
</section>
423423
<section id="thats-it" class="level1">
424424
<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>
426426

427427

428428
</section>
570 Bytes
Binary file not shown.

docs/part-02/lecture-control.pdf

-1 Bytes
Binary file not shown.

docs/part-02/tutorial-control.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ <h2 id="toc-title">On this page</h2>
246246
<li><a href="#decoding-secret-messages-with-methods" id="toc-decoding-secret-messages-with-methods" class="nav-link" data-scroll-target="#decoding-secret-messages-with-methods">Decoding secret messages with methods</a></li>
247247
<li><a href="#classifying-temperatures" id="toc-classifying-temperatures" class="nav-link" data-scroll-target="#classifying-temperatures">Classifying temperatures</a></li>
248248
<li><a href="#number-guessing-game" id="toc-number-guessing-game" class="nav-link" data-scroll-target="#number-guessing-game">Number guessing game</a></li>
249+
<li><a href="#thats-it" id="toc-thats-it" class="nav-link" data-scroll-target="#thats-it">That’s it!</a></li>
249250
</ul>
250251
<div class="quarto-alternate-formats"><h2>Other Formats</h2><ul><li><a href="tutorial-control.pdf"><i class="bi bi-file-pdf"></i>PDF</a></li></ul></div></nav>
251252
</div>
@@ -280,7 +281,7 @@ <h1>Introduction</h1>
280281
<section id="decoding-secret-messages-with-methods" class="level1">
281282
<h1>Decoding secret messages with methods</h1>
282283
<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>
283-
<div id="5c9d3ac8" class="cell" data-execution_count="1">
284+
<div id="5c9d3ac8" class="cell" data-execution_count="2">
284285
<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>
285286
<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>
286287
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="co"># The encoded message is:</span></span>
@@ -323,7 +324,7 @@ <h1>Decoding secret messages with methods</h1>
323324
<section id="classifying-temperatures" class="level1">
324325
<h1>Classifying temperatures</h1>
325326
<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>
326-
<div id="9e3909ec" class="cell" data-execution_count="2">
327+
<div id="9e3909ec" class="cell" data-execution_count="3">
327328
<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>
328329
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="co"># Below 0: "Freezing"</span></span>
329330
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="co"># 0-10: "Cold"</span></span>
@@ -344,7 +345,7 @@ <h1>Classifying temperatures</h1>
344345
<section id="number-guessing-game" class="level1">
345346
<h1>Number guessing game</h1>
346347
<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>
347-
<div id="ca014ea0" class="cell" data-execution_count="3">
348+
<div id="ca014ea0" class="cell" data-execution_count="4">
348349
<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. 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>
349350
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a></span>
350351
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="co"># a) </span><span class="al">TODO</span><span class="co">: Your task list in more detail:</span></span>
@@ -364,6 +365,10 @@ <h1>Number guessing game</h1>
364365
<span id="cb3-17"><a href="#cb3-17" aria-hidden="true" tabindex="-1"></a></span>
365366
<span id="cb3-18"><a href="#cb3-18" aria-hidden="true" tabindex="-1"></a><span class="co"># c) </span><span class="al">TODO</span><span class="co">: Play the game with someone sitting next to you.</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
366367
</div>
368+
</section>
369+
<section id="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>
367372

368373

369374
</section>

docs/part-02/tutorial-control.pdf

1.63 KB
Binary file not shown.

docs/part-03/lecture-functions.pdf

2 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)