<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>python-workout on jonah vairon</title>
    <link>https://58e1b19d.site-bk0.pages.dev/python-workout/</link>
    <description>Recent content in python-workout on jonah vairon</description>
    <generator>Hugo</generator>
    <language>en-uk</language>
    <copyright>© 2025 Jonah Vairon</copyright>
    <lastBuildDate>Fri, 30 Jan 2026 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://58e1b19d.site-bk0.pages.dev/python-workout/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>python workout: exercise 19</title>
      <link>https://58e1b19d.site-bk0.pages.dev/python-workout/python-workout-exercise-19/</link>
      <pubDate>Fri, 30 Jan 2026 00:00:00 +0000</pubDate>
      <guid>https://58e1b19d.site-bk0.pages.dev/python-workout/python-workout-exercise-19/</guid>
      <description>&lt;h2 id=&#34;problem&#34;&gt;problem&lt;/h2&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Write a function, &lt;code&gt;passwd_to_dict&lt;/code&gt;, that reads from a Unix-style &amp;ldquo;password file&amp;rdquo;,&#xA;commonly stored as &lt;code&gt;/etc/passwd&lt;/code&gt;, and returns a dict. The function should return a&#xA;dict based on &lt;code&gt;/etc/passwd&lt;/code&gt; in which the dict&amp;rsquo;s keys are usernames and the values&#xA;are the users&amp;rsquo; IDs (i.e the first and third fields in the comma-separated fields&#xA;of an &lt;code&gt;/etc/passwd&lt;/code&gt; entry).&lt;/p&gt;&lt;/blockquote&gt;&#xA;&lt;h3 id=&#34;attempts&#34;&gt;attempts&lt;/h3&gt;&#xA;&lt;p&gt;This should be straightforward. We can split each line on colons and extract the&#xA;first and third fields:&lt;/p&gt;</description>
    </item>
    <item>
      <title>python workout: exercise 18</title>
      <link>https://58e1b19d.site-bk0.pages.dev/python-workout/python-workout-exercise-18/</link>
      <pubDate>Wed, 28 Jan 2026 00:00:00 +0000</pubDate>
      <guid>https://58e1b19d.site-bk0.pages.dev/python-workout/python-workout-exercise-18/</guid>
      <description>&lt;h2 id=&#34;problem&#34;&gt;problem&lt;/h2&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Write a function (&lt;code&gt;get_final_line&lt;/code&gt;) that takes a filename as an argument. The&#xA;function should return that file&amp;rsquo;s final line on the screen.&lt;/p&gt;&lt;/blockquote&gt;&#xA;&lt;h3 id=&#34;attempts&#34;&gt;attempts&lt;/h3&gt;&#xA;&lt;h4 id=&#34;first&#34;&gt;first&lt;/h4&gt;&#xA;&lt;p&gt;My first thought is to just &lt;code&gt;readlines()&lt;/code&gt; and index into the last element with &lt;code&gt;-1&lt;/code&gt;.&#xA;But that seems to defeat the implied purpose of the exercise &amp;ndash; to explore hte&#xA;possibility that &amp;ldquo;I&amp;rsquo;m only interested in a single line&amp;rdquo;.&lt;/p&gt;&#xA;&lt;p&gt;Maybe it&amp;rsquo;s worth looking at the docs.&lt;/p&gt;</description>
    </item>
    <item>
      <title>python workout: exercise 17</title>
      <link>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-17/</link>
      <pubDate>Tue, 27 Jan 2026 00:00:00 +0000</pubDate>
      <guid>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-17/</guid>
      <description>&lt;h2 id=&#34;problem&#34;&gt;problem&lt;/h2&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Write a function, called &lt;code&gt;how_many_different_numbers&lt;/code&gt;, that takes a single list of&#xA;integers and returns the number of different integers it contains.&lt;/p&gt;&lt;/blockquote&gt;&#xA;&lt;h3 id=&#34;attempts&#34;&gt;attempts&lt;/h3&gt;&#xA;&lt;p&gt;The first thing that comes to mind is to just use a &lt;code&gt;set&lt;/code&gt; and get its length/size:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#c8d3f5;background-color:#222436;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#c099ff&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#82aaff&#34;&gt;how_many_different_numbers&lt;/span&gt;(numbers: &lt;span style=&#34;color:#c3e88d&#34;&gt;list&lt;/span&gt;[&lt;span style=&#34;color:#c3e88d&#34;&gt;int&lt;/span&gt;]) &lt;span style=&#34;color:#c3e88d;font-weight:bold&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#c3e88d&#34;&gt;int&lt;/span&gt;:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#c099ff&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#c3e88d&#34;&gt;len&lt;/span&gt;(&lt;span style=&#34;color:#c3e88d&#34;&gt;set&lt;/span&gt;(numbers))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;numbers &lt;span style=&#34;color:#c3e88d;font-weight:bold&#34;&gt;=&lt;/span&gt; [&lt;span style=&#34;color:#ffc777&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#ffc777&#34;&gt;2&lt;/span&gt;, &lt;span style=&#34;color:#ffc777&#34;&gt;3&lt;/span&gt;, &lt;span style=&#34;color:#ffc777&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#ffc777&#34;&gt;2&lt;/span&gt;, &lt;span style=&#34;color:#ffc777&#34;&gt;3&lt;/span&gt;, &lt;span style=&#34;color:#ffc777&#34;&gt;4&lt;/span&gt;, &lt;span style=&#34;color:#ffc777&#34;&gt;1&lt;/span&gt;]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#c3e88d&#34;&gt;print&lt;/span&gt;(how_many_different_numbers(numbers))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#c8d3f5;background-color:#222436;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;4&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;solution&#34;&gt;solution&lt;/h3&gt;&#xA;&lt;p&gt;The book&amp;rsquo;s implementation:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#c8d3f5;background-color:#222436;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#c099ff&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#82aaff&#34;&gt;how_many_different_numbers&lt;/span&gt;(numbers):&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    unique_numbers &lt;span style=&#34;color:#c3e88d;font-weight:bold&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#c3e88d&#34;&gt;set&lt;/span&gt;(numbers)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#c099ff&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#c3e88d&#34;&gt;len&lt;/span&gt;(unique_numbers)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Pretty much the same thing.&lt;/p&gt;&#xA;&lt;h3 id=&#34;beyond-the-exercise&#34;&gt;beyond the exercise&lt;/h3&gt;&#xA;&lt;h4 id=&#34;server-log-ip-addresses&#34;&gt;server log ip addresses&lt;/h4&gt;&#xA;&lt;!--list-separator--&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;problem&lt;/p&gt;</description>
    </item>
    <item>
      <title>python workout: exercise 16</title>
      <link>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-16/</link>
      <pubDate>Tue, 26 Aug 2025 00:00:00 +0100</pubDate>
      <guid>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-16/</guid>
      <description>&lt;h2 id=&#34;dictdiff&#34;&gt;dictdiff&lt;/h2&gt;&#xA;&lt;h3 id=&#34;problem&#34;&gt;problem&lt;/h3&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Write a function, &lt;code&gt;dictdiff&lt;/code&gt;, that takes two dicts as arguments. The function&#xA;returns a new dict that expresses the difference between the two dicts.&lt;/p&gt;&#xA;&lt;p&gt;If there are no differences between the dicts, &lt;code&gt;dictdiff&lt;/code&gt; returns an empty dict. For&#xA;each key-value pair that differs, the return value of &lt;code&gt;dictdiff&lt;/code&gt; will have a key-value pair&#xA;in which the value is a list containing the values from the two different dicts. If one of&#xA;the dicts doesn’t contain that key, it should contain &lt;code&gt;None&lt;/code&gt;. The following provides some&#xA;examples:&lt;/p&gt;</description>
    </item>
    <item>
      <title>python workout: exercise 15</title>
      <link>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-15/</link>
      <pubDate>Sat, 23 Aug 2025 00:00:00 +0100</pubDate>
      <guid>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-15/</guid>
      <description>&lt;h2 id=&#34;rainfall&#34;&gt;rainfall&lt;/h2&gt;&#xA;&lt;h3 id=&#34;problem&#34;&gt;problem&lt;/h3&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Another use for dicts is to accumulate data over the life of a program. In this exercise,&#xA;you’ll use a dict for just that.&#xA;Specifically, write a function, get_rainfall, that tracks rainfall in a number of cit-&#xA;ies. Users of your program will enter the name of a city; if the city name is blank, then&#xA;the function prints a report (which I’ll describe) before exiting.&#xA;If the city name isn’t blank, then the program should also ask the user how much&#xA;rain has fallen in that city (typically measured in millimeters). After the user enters&#xA;the quantity of rain, the program again asks them for a city name, rainfall amount,&#xA;and so on—until the user presses Enter instead of typing the name of a city.&#xA;When the user enters a blank city name, the program exits—but first, it reports&#xA;how much total rainfall there was in each city. Thus, if I enter&lt;/p&gt;</description>
    </item>
    <item>
      <title>python workout: exercise 14</title>
      <link>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-14/</link>
      <pubDate>Sun, 17 Aug 2025 00:00:00 +0100</pubDate>
      <guid>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-14/</guid>
      <description>&lt;h2 id=&#34;restaurant&#34;&gt;restaurant&lt;/h2&gt;&#xA;&lt;h3 id=&#34;problem&#34;&gt;problem&lt;/h3&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In this exercise, I want you to create a new constant dict, called &lt;code&gt;MENU&lt;/code&gt;, representing&#xA;the possible items you can order at a restaurant. The keys will be strings, and the val-&#xA;ues will be prices (i.e., integers). You should then write a function, &lt;code&gt;restaurant&lt;/code&gt;, that&#xA;asks the user to enter an order:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the user enters the name of a dish on the menu, the program prints the&#xA;price and the running total. It then asks the user again for their order.&lt;/li&gt;&#xA;&lt;li&gt;If the user enters the name of a dish not on the menu, the program scolds the&#xA;user (mildly). It then asks the user again for their order.&lt;/li&gt;&#xA;&lt;li&gt;If the user enters an empty string, the program stops prompting and prints the&#xA;total amount.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For example, a session with the user might look like this:&lt;/p&gt;</description>
    </item>
    <item>
      <title>python workout: exercise 13</title>
      <link>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-13/</link>
      <pubDate>Sat, 16 Aug 2025 00:00:00 +0100</pubDate>
      <guid>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-13/</guid>
      <description>&lt;h2 id=&#34;printing-tuple-records&#34;&gt;printing tuple records&lt;/h2&gt;&#xA;&lt;h3 id=&#34;problem&#34;&gt;problem&lt;/h3&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;For example, assume we’re in charge of an international summit in London. We&#xA;know how many hours it’ll take each of several world leaders to arrive:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#c8d3f5;background-color:#222436;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;PEOPLE &lt;span style=&#34;color:#c3e88d;font-weight:bold&#34;&gt;=&lt;/span&gt; [(&lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;Donald&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;Trump&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#ffc777&#34;&gt;7.85&lt;/span&gt;),&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;Vladimir&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;Putin&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#ffc777&#34;&gt;3.626&lt;/span&gt;),&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;Jinping&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;Xi&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#ffc777&#34;&gt;10.603&lt;/span&gt;)]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The planner for this summit needs to have a list of the world leaders who are coming,&#xA;along with the time it’ll take for them to arrive. However, this travel planner doesn’t&#xA;need the degree of precision that the computer has provided; it’s enough for us to&#xA;have two digits after the decimal point.&lt;/p&gt;</description>
    </item>
    <item>
      <title>python workout: exercise 12</title>
      <link>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-12/</link>
      <pubDate>Thu, 14 Aug 2025 00:00:00 +0100</pubDate>
      <guid>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-12/</guid>
      <description>&lt;h2 id=&#34;word-with-most-repeated-letters&#34;&gt;word with most repeated letters&lt;/h2&gt;&#xA;&lt;h3 id=&#34;problem&#34;&gt;problem&lt;/h3&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Write a function, &lt;code&gt;most_repeating_word&lt;/code&gt;, that takes a sequence of strings as input. The&#xA;function should return the string that contains the greatest number of repeated let-&#xA;ters. In other words&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For each word, find the letter that appears the most times.&lt;/li&gt;&#xA;&lt;li&gt;Find the word whose most-repeated letter appears more than any other.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;That is, if words is set to&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#c8d3f5;background-color:#222436;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;words &lt;span style=&#34;color:#c3e88d;font-weight:bold&#34;&gt;=&lt;/span&gt; [&lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;this&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;is&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;an&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;elementary&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;test&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;example&amp;#39;&lt;/span&gt;]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;then your function should return &lt;code&gt;elementary&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>python workout: exercise 11</title>
      <link>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-11/</link>
      <pubDate>Tue, 12 Aug 2025 00:00:00 +0100</pubDate>
      <guid>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-11/</guid>
      <description>&lt;h2 id=&#34;alphabetising-names&#34;&gt;alphabetising names&lt;/h2&gt;&#xA;&lt;h3 id=&#34;problem&#34;&gt;problem&lt;/h3&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Let’s assume you have phone book data in a list of dicts, as follows:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#c8d3f5;background-color:#222436;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;PEOPLE &lt;span style=&#34;color:#c3e88d;font-weight:bold&#34;&gt;=&lt;/span&gt; [{&lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;first&amp;#39;&lt;/span&gt;:&lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;Reuven&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;last&amp;#39;&lt;/span&gt;:&lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;Lerner&amp;#39;&lt;/span&gt;,&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           &lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;email&amp;#39;&lt;/span&gt;:&lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;reuven@lerner.co.il&amp;#39;&lt;/span&gt;},&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          {&lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;first&amp;#39;&lt;/span&gt;:&lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;Donald&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;last&amp;#39;&lt;/span&gt;:&lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;Trump&amp;#39;&lt;/span&gt;,&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           &lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;email&amp;#39;&lt;/span&gt;:&lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;president@whitehouse.gov&amp;#39;&lt;/span&gt;},&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          {&lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;first&amp;#39;&lt;/span&gt;:&lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;Vladimir&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;last&amp;#39;&lt;/span&gt;:&lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;Putin&amp;#39;&lt;/span&gt;,&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           &lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;email&amp;#39;&lt;/span&gt;:&lt;span style=&#34;color:#c3e88d&#34;&gt;&amp;#39;president@kremvax.ru&amp;#39;&lt;/span&gt;}]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;First of all, if these are the only people in your phone book, then you should&#xA;rethink whether Python programming is truly the best use of your time and&#xA;connections. Regardless, write a function, &lt;code&gt;alphabetize_names&lt;/code&gt;, that assumes the&#xA;existence of a &lt;code&gt;PEOPLE&lt;/code&gt; constant defined as shown in the code. The function should&#xA;return the list of dicts, but sorted by last name and then by first name.&lt;/p&gt;</description>
    </item>
    <item>
      <title>python workout: exercise 10</title>
      <link>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-10/</link>
      <pubDate>Sun, 10 Aug 2025 00:00:00 +0100</pubDate>
      <guid>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-10/</guid>
      <description>&lt;h2 id=&#34;summing-anything&#34;&gt;summing anything&lt;/h2&gt;&#xA;&lt;h3 id=&#34;problem&#34;&gt;problem&lt;/h3&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This challenge asks you to redefine the &lt;code&gt;mysum&lt;/code&gt; function we defined in chapter 1,&#xA;such that it can take any number of arguments. The arguments must all be of the&#xA;same type and know how to respond to the &lt;code&gt;+&lt;/code&gt; operator. (Thus, the function should&#xA;work with numbers, strings, lists, and tuples, but not with sets and dicts.)&lt;/p&gt;&#xA;&lt;p&gt;The result should be a new, longer sequence of the type provided by the&#xA;parameters. Thus, the result of &lt;code&gt;mysum(&#39;abc&#39;, &#39;def&#39;)&lt;/code&gt; will be the string &lt;code&gt;abcdef&lt;/code&gt;,&#xA;and the result of &lt;code&gt;mysum([1,2,3], [4,5,6])&lt;/code&gt; will be the six-element list&#xA;&lt;code&gt;[1,2,3,4,5,6]&lt;/code&gt;. Of course, it should also still return the integer &lt;code&gt;6&lt;/code&gt; if we invoke&#xA;&lt;code&gt;mysum(1,2,3)&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>python workout: exercise 9</title>
      <link>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-9/</link>
      <pubDate>Fri, 08 Aug 2025 00:00:00 +0100</pubDate>
      <guid>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-9/</guid>
      <description>&lt;h2 id=&#34;first-last&#34;&gt;first-last&lt;/h2&gt;&#xA;&lt;h3 id=&#34;problem&#34;&gt;problem&lt;/h3&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Write a function, &lt;code&gt;firstlast&lt;/code&gt;, that takes a sequence (string, list, or tuple) and&#xA;returns the first and last elements of that sequence, in a two-element sequence&#xA;of the same type. So &lt;code&gt;firstlast(&#39;abc&#39;)&lt;/code&gt; will return the string ac, while&#xA;&lt;code&gt;firstlast([1,2,3,4])&lt;/code&gt; will return the list &lt;code&gt;[1,4]&lt;/code&gt;.&lt;/p&gt;&lt;/blockquote&gt;&#xA;&lt;h3 id=&#34;attempts&#34;&gt;attempts&lt;/h3&gt;&#xA;&lt;p&gt;We can just use slices to get the first and last element, the real challenge to&#xA;me seems to be returning a sequence of the same type as the input.&lt;/p&gt;</description>
    </item>
    <item>
      <title>python workout: exercise 8</title>
      <link>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-8/</link>
      <pubDate>Thu, 07 Aug 2025 00:00:00 +0100</pubDate>
      <guid>https://58e1b19d.site-bk0.pages.dev/python-workout/exercise-8/</guid>
      <description>&lt;h2 id=&#34;sorting-a-string&#34;&gt;sorting a string&lt;/h2&gt;&#xA;&lt;h3 id=&#34;problem&#34;&gt;problem&lt;/h3&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In this exercise, you’ll explore this idea by writing a function, &lt;code&gt;strsort&lt;/code&gt;, that&#xA;takes a single string as its input and returns a string. The returned string&#xA;should contain the same characters as the input, except that its characters&#xA;should be sorted in order, from the lowest Unicode value to the highest Unicode&#xA;value. For example, the result of invoking &lt;code&gt;strsort(&#39;cba&#39;)&lt;/code&gt; will be the string&#xA;&lt;code&gt;abc&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
