<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title>Real Python</title>
  <link href="https://realpython.com/atom.xml" rel="self"/>
  <link href="https://realpython.com/"/>
  <updated>2024-07-19T12:00:00+00:00</updated>
  <id>https://realpython.com/</id>
  <author>
    <name>Real Python</name>
  </author>

  
    <entry>
      <title>The Real Python Podcast – Episode #213: Constraint Programming &amp; Exploring Python&#x27;s Built-in Functions</title>
      <id>https://realpython.com/podcasts/rpp/213/</id>
      <link href="https://realpython.com/podcasts/rpp/213/"/>
      <updated>2024-07-19T12:00:00+00:00</updated>
      <summary>What are discrete optimization problems? How do you solve them with constraint programming in Python? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects</summary>
      <content type="html">
        &lt;p&gt;What are discrete optimization problems? How do you solve them with constraint programming in Python? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Quiz: Python Strings and Character Data</title>
      <id>https://realpython.com/quizzes/python-strings-update/</id>
      <link href="https://realpython.com/quizzes/python-strings-update/"/>
      <updated>2024-07-19T12:00:00+00:00</updated>
      <summary>This quiz will evaluate your understanding of Python&#x27;s string data type and your knowledge about manipulating textual data with string objects. You&#x27;ll cover the basics of creating strings using literals and the `str()` function, applying string methods, using operators and built-in functions with strings, indexing and slicing strings, and more!</summary>
      <content type="html">
        &lt;p&gt;This quiz will evaluate your understanding of Python&amp;rsquo;s string data type and test your knowledge about manipulating textual data with string objects. You&amp;rsquo;ll cover the basics of creating strings using literals and the str() function, applying string methods, using operators and built-in functions with strings, indexing and slicing strings, and more!&lt;/p&gt;
&lt;p&gt;Take this quiz after reading our &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;Strings and Character Data in Python&lt;/a&gt; tutorial.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Protocols: Leveraging Structural Subtyping</title>
      <id>https://realpython.com/python-protocol/</id>
      <link href="https://realpython.com/python-protocol/"/>
      <updated>2024-07-17T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn about Python&#x27;s protocols and how they can help you get the most out of using Python&#x27;s type hint system and static type checkers.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;In Python, a &lt;strong&gt;protocol&lt;/strong&gt; specifies the methods and attributes that a class must implement to be considered of a given type. Protocols are important in Python’s &lt;strong&gt;type hint system&lt;/strong&gt;, which allows for static type checking through external tools, such as &lt;a href=&quot;http://mypy-lang.org/&quot;&gt;mypy&lt;/a&gt;, &lt;a href=&quot;https://github.com/microsoft/pyright&quot;&gt;Pyright&lt;/a&gt;, and &lt;a href=&quot;https://pyre-check.org/&quot;&gt;Pyre&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Before there were protocols, these tools could only check for &lt;strong&gt;nominal subtyping&lt;/strong&gt; based on inheritance. There was no way to check for &lt;strong&gt;structural subtyping&lt;/strong&gt;, which relies on the internal structure of classes. This limitation affected Python’s &lt;strong&gt;duck typing&lt;/strong&gt; system, which allows you to use objects without considering their nominal types. Protocols overcome this limitation, making static duck typing possible.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Gain clarity around the use of the term &lt;strong&gt;protocol&lt;/strong&gt; in Python&lt;/li&gt;
&lt;li&gt;Learn how &lt;strong&gt;type hints&lt;/strong&gt; facilitate &lt;strong&gt;static type checking&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Learn how protocols allow &lt;strong&gt;static duck typing&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Create custom protocols with the &lt;strong&gt;&lt;code&gt;Protocol&lt;/code&gt; class&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Understand the differences between &lt;strong&gt;protocols&lt;/strong&gt; and &lt;strong&gt;abstract base classes&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this tutorial, you’ll need to know the basics of &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt; in Python, including concepts such as &lt;a href=&quot;https://realpython.com/python-classes/&quot;&gt;classes&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/inheritance-composition-python/&quot;&gt;inheritance&lt;/a&gt;. You should also know about &lt;a href=&quot;https://realpython.com/python-type-checking/&quot;&gt;type checking&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/duck-typing-python/&quot;&gt;duck typing&lt;/a&gt; in Python.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-protocol-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-protocol-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to leverage structural subtyping with Python protocols&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;the-meaning-of-protocol-in-python&quot;&gt;The Meaning of “Protocol” in Python&lt;a class=&quot;headerlink&quot; href=&quot;#the-meaning-of-protocol-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;During Python’s evolution, the term &lt;strong&gt;protocol&lt;/strong&gt; became overloaded with two subtly different meanings. The first meaning refers to internal protocols, such as the &lt;a href=&quot;https://realpython.com/python-iterators-iterables/#what-is-the-python-iterator-protocol&quot;&gt;iterator&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-with-statement/#creating-custom-context-managers&quot;&gt;context manager&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-descriptors/&quot;&gt;descriptor&lt;/a&gt; protocols.&lt;/p&gt;
&lt;p&gt;These protocols are widely understood in the community and consist of &lt;a href=&quot;https://realpython.com/python-magic-methods/&quot;&gt;special methods&lt;/a&gt; that make up a given protocol. For example, the &lt;a href=&quot;https://docs.python.org/3/library/stdtypes.html#iterator.__iter__&quot;&gt;&lt;code&gt;.__iter__()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://docs.python.org/3/library/stdtypes.html#iterator.__next__&quot;&gt;&lt;code&gt;.__next__()&lt;/code&gt;&lt;/a&gt; methods define the iterator protocol.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://realpython.com/python38-new-features/&quot;&gt;Python 3.8&lt;/a&gt; introduced a second, slightly different type of &lt;a href=&quot;https://realpython.com/python38-new-features/#more-precise-types&quot;&gt;protocol&lt;/a&gt;. These protocols specify the methods and attributes that a class must implement to be considered of a given type. So, these protocols also have to do with a class’s internal structure.&lt;/p&gt;
&lt;p&gt;With this kind of protocol, you can define interchangeable classes as long as they share a common internal structure. This feature allows you to enforce a relationship between types or classes without the burden of &lt;a href=&quot;https://realpython.com/inheritance-composition-python/#whats-inheritance&quot;&gt;inheritance&lt;/a&gt;. This relationship is known as &lt;strong&gt;structural subtyping&lt;/strong&gt; or &lt;a href=&quot;https://realpython.com/duck-typing-python/#understanding-type-hints-and-static-duck-typing&quot;&gt;static duck typing&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll focus on this second meaning of the term protocol. First, you’ll have a look at how Python manages types.&lt;/p&gt;
&lt;h2 id=&quot;dynamic-and-static-typing-in-python&quot;&gt;Dynamic and Static Typing in Python&lt;a class=&quot;headerlink&quot; href=&quot;#dynamic-and-static-typing-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python is a dynamically typed language, which means that the Python interpreter checks an object’s type when the code runs. It also means that while a variable can only reference one object at a time, the type of that object can change during the variable’s lifetime.&lt;/p&gt;
&lt;p&gt;For example, you can have a variable that starts as a string and changes into an integer number:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;One hundred&quot;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;One hundred&#x27;&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;100&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this example, you have a variable that starts as a string. Later in your code, you change the variable’s value to an integer.&lt;/p&gt;
&lt;p&gt;Because of its dynamic nature, Python has embraced a flexible typing system that’s known as duck typing.&lt;/p&gt;
&lt;h3 id=&quot;duck-typing&quot;&gt;Duck Typing&lt;a class=&quot;headerlink&quot; href=&quot;#duck-typing&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Duck typing is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Type_system&quot;&gt;type system&lt;/a&gt; in which an object is considered compatible with a given type if it has all the &lt;a href=&quot;https://realpython.com/python-classes/#providing-behavior-with-methods&quot;&gt;methods&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-classes/#attaching-data-to-classes-and-instances&quot;&gt;attributes&lt;/a&gt; that the type requires. This typing system supports the ability to use objects of independent and decoupled classes in a specific context as long as they adhere to some common interface.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; To dive deeper into duck typing, check out the &lt;a href=&quot;https://realpython.com/duck-typing-python/&quot;&gt;Duck Typing in Python: Writing Flexible and Decoupled Code&lt;/a&gt; tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;As an example of duck typing, you can consider built-in container data types, such as &lt;a href=&quot;https://realpython.com/python-list/&quot;&gt;lists&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-tuple/&quot;&gt;tuples&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;strings&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionaries&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-sets/&quot;&gt;sets&lt;/a&gt;. All of these data types support iteration:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;numbers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;person&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Jane&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Python Dev&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;letters&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;abc&quot;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ordinals&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;one&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;first&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;two&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;second&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;three&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;third&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;even_digits&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;containers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;letters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ordinals&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;even_digits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;container&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;containers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;element&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;container&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;        &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot; &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;1 2 3 &lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Jane 25 Python Dev &lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;a b c &lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;one two three &lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;8 2 4 6 &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this code snippet, you define a few variables using different built-in types. Then, you start a &lt;a href=&quot;https://realpython.com/python-for-loop/&quot;&gt;&lt;code&gt;for&lt;/code&gt;&lt;/a&gt; loop over the collections and iterate over each of them to print their elements to the screen. Even though the built-in types are significantly different from one another, they all support iteration.&lt;/p&gt;
&lt;p&gt;The duck typing system allows you to create code that can work with different objects, provided that they share a common interface. This system allows you to set relationships between classes that don’t rely on inheritance, which produces flexible and decoupled code.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-protocol/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-protocol/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Quiz: How Do You Choose Python Function Names?</title>
      <id>https://realpython.com/quizzes/python-function-names/</id>
      <link href="https://realpython.com/quizzes/python-function-names/"/>
      <updated>2024-07-17T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of how to choose Python function names.
By working through this quiz, you&#x27;ll revisit the rules and conventions for naming Python functions
and why they&#x27;re important for writing Pythonic code.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of
&lt;a href=&quot;https://realpython.com/python-function-names/&quot;&gt;how to choose Python function names&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit the rules and conventions for naming Python functions
and why they&amp;rsquo;re important for &lt;a href=&quot;https://realpython.com/learning-paths/writing-pythonic-code/&quot;&gt;writing Pythonic code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Choosing the ideal Python function names makes your code more readable and easier to maintain.
Code with well-chosen names can also be less prone to bugs.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Exercises Course: Introduction to Web Scraping With Python</title>
      <id>https://realpython.com/courses/exercises-introduction-web-scraping/</id>
      <link href="https://realpython.com/courses/exercises-introduction-web-scraping/"/>
      <updated>2024-07-16T14:00:00+00:00</updated>
      <summary>In this course, you&#x27;ll practice the main steps of the web scraping process. You&#x27;ll write a script that uses Python&#x27;s requests library to scrape and parse data from a website. You&#x27;ll also interact with HTML forms using tools like Beautiful Soup and Mechanical Soup to extract specific information.</summary>
      <content type="html">
        &lt;p&gt;&lt;strong&gt;Web scraping&lt;/strong&gt; is the process of collecting and parsing raw data from the Web, and the Python community has come up with some pretty powerful web scraping tools.&lt;/p&gt;
&lt;p&gt;The Internet hosts the greatest source of information on the planet. Many disciplines, such as &lt;a href=&quot;https://realpython.com/learning-paths/data-science-python-core-skills/&quot;&gt;data science&lt;/a&gt;, business intelligence, and investigative reporting, can benefit enormously from collecting and analyzing data from websites. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll practice:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Parsing website data using &lt;strong&gt;string methods&lt;/strong&gt; and &lt;strong&gt;regular expressions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Parsing website data using an &lt;strong&gt;HTML parser&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Interacting with &lt;strong&gt;forms&lt;/strong&gt; and other website components&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Split Your Dataset With scikit-learn&#x27;s train_test_split()</title>
      <id>https://realpython.com/train-test-split-python-data/</id>
      <link href="https://realpython.com/train-test-split-python-data/"/>
      <updated>2024-07-15T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn why splitting your dataset in supervised machine learning is important and how to do it with train_test_split() from scikit-learn.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;One of the key aspects of supervised &lt;a href=&quot;https://realpython.com/learning-paths/machine-learning-python/&quot;&gt;machine learning&lt;/a&gt; is model evaluation and validation. When you evaluate the predictive performance of your model, it’s essential that the process be unbiased. Using &lt;a href=&quot;https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html&quot;&gt;&lt;strong&gt;&lt;code&gt;train_test_split()&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt; from the data science library &lt;a href=&quot;https://scikit-learn.org/stable/index.html&quot;&gt;scikit-learn&lt;/a&gt;, you can split your dataset into subsets that minimize the potential for bias in your evaluation and validation process.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Why you need to &lt;strong&gt;split your dataset&lt;/strong&gt; in supervised machine learning&lt;/li&gt;
&lt;li&gt;Which &lt;strong&gt;subsets&lt;/strong&gt; of the dataset you need for an unbiased evaluation of your model&lt;/li&gt;
&lt;li&gt;How to use &lt;strong&gt;&lt;code&gt;train_test_split()&lt;/code&gt;&lt;/strong&gt; to split your data&lt;/li&gt;
&lt;li&gt;How to combine &lt;code&gt;train_test_split()&lt;/code&gt; with &lt;strong&gt;prediction methods&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition, you’ll get information on related tools from &lt;a href=&quot;https://scikit-learn.org/stable/api/sklearn.model_selection.html&quot;&gt;&lt;code&gt;sklearn.model_selection&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/train-test-split-python-data-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-train-test-split-python-data-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that you’ll use to learn about splitting your dataset with scikit-learn’s train_test_split().&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;container border rounded text-wrap-pretty my-3&quot;&gt;

  &lt;p class=&quot;my-3&quot;&gt;&lt;mark class=&quot;marker-highlight&quot;&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “Split Your Dataset With scikit-learn&#x27;s train_test_split()” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col-xs-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/train-test-split-python-data/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;embed-responsive embed-responsive-16by9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 embed-responsive-item rounded&quot; style=&quot;object-fit: contain; background: #abe5b2;&quot; alt=&quot;Split Your Dataset With scikit-learn&#x27;s train_test_split()&quot; src=&quot;https://files.realpython.com/media/Splitting-Datasets-With-sklearns-train_test_split_Watermarked.13dcac93b15d.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Splitting-Datasets-With-sklearns-train_test_split_Watermarked.13dcac93b15d.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Splitting-Datasets-With-sklearns-train_test_split_Watermarked.13dcac93b15d.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Splitting-Datasets-With-sklearns-train_test_split_Watermarked.13dcac93b15d.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Splitting-Datasets-With-sklearns-train_test_split_Watermarked.13dcac93b15d.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)&quot;&gt;


          &lt;div class=&quot;card-img-overlay d-flex align-items-center&quot;&gt;
            &lt;div class=&quot;mx-auto&quot;&gt;
              &lt;span class=&quot;text-light&quot; style=&quot;opacity: 0.90;&quot;&gt;&lt;span class=&quot;icon baseline scale2x&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;div class=&quot;mt-3 d-md-none&quot;&gt;&lt;/div&gt; 
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Interactive Quiz&lt;/strong&gt;&lt;/p&gt;
      &lt;a href=&quot;/quizzes/train-test-split-python-data/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Split Your Dataset With scikit-learn&#x27;s train_test_split()&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of how to use the train_test_split() function from the scikit-learn library to split your dataset into subsets for unbiased evaluation in machine learning.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;the-importance-of-data-splitting&quot;&gt;The Importance of Data Splitting&lt;a class=&quot;headerlink&quot; href=&quot;#the-importance-of-data-splitting&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Supervised_learning&quot;&gt;Supervised machine learning&lt;/a&gt; is about creating models that precisely map the given inputs to the given outputs. Inputs are also called independent variables or &lt;strong&gt;predictors&lt;/strong&gt;, while outputs may be referred to as dependent variables or &lt;strong&gt;responses&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;How you measure the precision of your model depends on the type of a problem you’re trying to solve. In &lt;a href=&quot;https://realpython.com/linear-regression-in-python/#regression&quot;&gt;regression analysis&lt;/a&gt;, you typically use the &lt;a href=&quot;https://en.wikipedia.org/wiki/Coefficient_of_determination&quot;&gt;coefficient of determination&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Root-mean-square_deviation&quot;&gt;root mean square error&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Mean_absolute_error&quot;&gt;mean absolute error&lt;/a&gt;, or similar quantities. For &lt;a href=&quot;https://realpython.com/logistic-regression-python/#classification&quot;&gt;classification&lt;/a&gt; problems, you often apply &lt;a href=&quot;https://developers.google.com/machine-learning/crash-course/classification/accuracy&quot;&gt;accuracy&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Precision_and_recall&quot;&gt;precision, recall&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/F1_score&quot;&gt;F1 score&lt;/a&gt;, and related indicators.&lt;/p&gt;
&lt;p&gt;The acceptable numeric values that measure precision vary from field to field. You can find detailed explanations from &lt;a href=&quot;https://statisticsbyjim.com/regression/how-high-r-squared/&quot;&gt;Statistics By Jim&lt;/a&gt;, &lt;a href=&quot;https://www.quora.com/How-do-I-decide-whether-a-certain-R-square-value-is-good-enough-in-regression-analysis&quot;&gt;Quora&lt;/a&gt;, and many other resources.&lt;/p&gt;
&lt;p&gt;What’s most important to understand is that you usually need &lt;strong&gt;unbiased evaluation&lt;/strong&gt; to properly use these measures, assess the predictive performance of your model, and validate the model.&lt;/p&gt;
&lt;p&gt;This means that you can’t evaluate the predictive performance of a model with the same data you used for training. You need evaluate the model with &lt;strong&gt;fresh data&lt;/strong&gt; that hasn’t been seen by the model before. You can accomplish that by splitting your dataset before you use it.&lt;/p&gt;
&lt;h3 id=&quot;training-validation-and-test-sets&quot;&gt;Training, Validation, and Test Sets&lt;a class=&quot;headerlink&quot; href=&quot;#training-validation-and-test-sets&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Splitting your dataset is essential for an unbiased evaluation of prediction performance. In most cases, it’s enough to split your dataset randomly into &lt;a href=&quot;https://en.wikipedia.org/wiki/Training,_validation,_and_test_sets&quot;&gt;three subsets&lt;/a&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The training set&lt;/strong&gt; is applied to train or &lt;strong&gt;fit&lt;/strong&gt; your model. For example, you use the training set to find the optimal weights, or coefficients, for &lt;a href=&quot;https://realpython.com/linear-regression-in-python/&quot;&gt;linear regression&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/logistic-regression-python/&quot;&gt;logistic regression&lt;/a&gt;, or &lt;a href=&quot;https://en.wikipedia.org/wiki/Artificial_neural_network&quot;&gt;neural networks&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The validation set&lt;/strong&gt; is used for unbiased model evaluation during &lt;a href=&quot;https://en.wikipedia.org/wiki/Hyperparameter_optimization&quot;&gt;hyperparameter tuning&lt;/a&gt;. For example, when you want to find the optimal number of neurons in a neural network or the best kernel for a support vector machine, you experiment with different values. For each considered setting of hyperparameters, you fit the model with the training set and assess its performance with the validation set.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The test set&lt;/strong&gt; is needed for an unbiased evaluation of the final model. You shouldn’t use it for fitting or validation.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In less complex cases, when you don’t have to tune hyperparameters, it’s okay to work with only the training and test sets.&lt;/p&gt;
&lt;h3 id=&quot;underfitting-and-overfitting&quot;&gt;Underfitting and Overfitting&lt;a class=&quot;headerlink&quot; href=&quot;#underfitting-and-overfitting&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Splitting a dataset might also be important for detecting if your model suffers from one of two very common problems, called &lt;a href=&quot;https://en.wikipedia.org/wiki/Overfitting&quot;&gt;underfitting and overfitting&lt;/a&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Underfitting&lt;/strong&gt; is usually the consequence of a model being unable to encapsulate the relations among data. For example, this can happen when trying to represent nonlinear relations with a linear model. Underfitted models will likely have poor performance with both training and test sets.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Overfitting&lt;/strong&gt; usually takes place when a model has an excessively complex structure and learns both the existing relations among data and noise. Such models often have bad generalization capabilities. Although they work well with training data, they usually yield poor performance with unseen test data.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can find a more detailed explanation of underfitting and overfitting in &lt;a href=&quot;https://realpython.com/linear-regression-in-python/#underfitting-and-overfitting&quot;&gt;Linear Regression in Python&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;prerequisites-for-using-train_test_split&quot;&gt;Prerequisites for Using &lt;code&gt;train_test_split()&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#prerequisites-for-using-train_test_split&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Now that you understand the need to split a dataset in order to perform unbiased model evaluation and identify underfitting or overfitting, you’re ready to learn how to split your own datasets.&lt;/p&gt;
&lt;p&gt;You’ll use version 1.5.0 of &lt;strong&gt;scikit-learn&lt;/strong&gt;, or &lt;strong&gt;&lt;code&gt;sklearn&lt;/code&gt;&lt;/strong&gt;. It has many packages for data science and machine learning, but for this tutorial, you’ll focus on the  &lt;strong&gt;&lt;code&gt;model_selection&lt;/code&gt;&lt;/strong&gt;  package, specifically on the function &lt;strong&gt;&lt;code&gt;train_test_split()&lt;/code&gt;&lt;/strong&gt;. &lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; While this tutorial is tested with this specific version of scikit-learn, the features that you’ll use are core to the library and should work equivalently in other versions of scikit-learn as well.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;You can &lt;a href=&quot;https://scikit-learn.org/stable/install.html&quot;&gt;install &lt;code&gt;sklearn&lt;/code&gt;&lt;/a&gt; with &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;&lt;code&gt;pip&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/train-test-split-python-data/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/train-test-split-python-data/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Quiz: How to Use Generators and yield in Python</title>
      <id>https://realpython.com/quizzes/generators-and-yield-in-python/</id>
      <link href="https://realpython.com/quizzes/generators-and-yield-in-python/"/>
      <updated>2024-07-15T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of Python generators and the yield statement. With this knowledge, you&#x27;ll be able to work with large datasets in a more Pythonic fashion, create generator functions and expressions, and build data pipelines.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of &lt;a href=&quot;https://realpython.com/introduction-to-python-generators/&quot;&gt;Python generators&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Generators and the Python &lt;code&gt;yield&lt;/code&gt; statement can help you when you&amp;rsquo;re working with large datasets that might overwhelm your machine&amp;rsquo;s memory. Another use case is when you have a complex function that needs to maintain an internal state every time it&amp;rsquo;s called.&lt;/p&gt;
&lt;p&gt;When you understand Python generators, then you&amp;rsquo;ll be able to work with large datasets in a more Pythonic fashion, create generator functions and expressions, and apply your knowledge towards building efficient data pipelines.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Quiz: How to Write Beautiful Python Code With PEP 8</title>
      <id>https://realpython.com/quizzes/python-pep8/</id>
      <link href="https://realpython.com/quizzes/python-pep8/"/>
      <updated>2024-07-15T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of PEP 8, the Python Enhancement Proposal that provides guidelines and best practices on how to write Python code. By working through this quiz, you&#x27;ll revisit the key guidelines laid out in PEP 8 and how to set up your development environment to write PEP 8 compliant Python code.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of
&lt;a href=&quot;https://realpython.com/python-pep8/&quot;&gt;how to write beautiful Python code with PEP 8&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit the key guidelines laid out in PEP 8 and how to set up your development environment to write PEP 8 compliant Python code.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Quiz: How to Flatten a List of Lists in Python</title>
      <id>https://realpython.com/quizzes/python-flatten-list/</id>
      <link href="https://realpython.com/quizzes/python-flatten-list/"/>
      <updated>2024-07-14T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of how to flatten a list in Python. Flattening a list involves converting a multidimensional list, such as a matrix, into a one-dimensional list. This is a common operation when working with data stored as nested lists.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of &lt;a href=&quot;https://realpython.com/python-flatten-list/&quot;&gt;how to flatten a list in Python&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You&amp;rsquo;ll write code and answer questions to revisit the concept of converting a multidimensional list, such as a matrix, into a one-dimensional list.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Quiz: Python Type Checking</title>
      <id>https://realpython.com/quizzes/python-type-checking/</id>
      <link href="https://realpython.com/quizzes/python-type-checking/"/>
      <updated>2024-07-14T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of Python type checking. You&#x27;ll revisit concepts such as type annotations, type hints, adding static types to code, running a static type checker, and enforcing types at runtime. This knowledge will help you develop your code more efficiently.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of
&lt;a href=&quot;https://realpython.com/python-type-checking/&quot;&gt;Python Type Checking&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit type annotations and type hints, adding static types to code, running a static type checker, and enforcing types at runtime.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #212: Digging Into Graph Theory in Python With David Amos</title>
      <id>https://realpython.com/podcasts/rpp/212/</id>
      <link href="https://realpython.com/podcasts/rpp/212/"/>
      <updated>2024-07-12T12:00:00+00:00</updated>
      <summary>Have you wondered about graph theory and how to start exploring it in Python? What resources and Python libraries can you use to experiment and learn more? This week on the show, former co-host David Amos returns to talk about what he&#x27;s been up to and share his knowledge about graph theory in Python.</summary>
      <content type="html">
        &lt;p&gt;Have you wondered about graph theory and how to start exploring it in Python? What resources and Python libraries can you use to experiment and learn more? This week on the show, former co-host David Amos returns to talk about what he&#x27;s been up to and share his knowledge about graph theory in Python.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Quiz: Build a Blog Using Django, GraphQL, and Vue</title>
      <id>https://realpython.com/quizzes/python-django-blog/</id>
      <link href="https://realpython.com/quizzes/python-django-blog/"/>
      <updated>2024-07-11T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of building a Django blog back end and a Vue front end, using GraphQL to communicate between them. This will help you decouple your back end and front end, handle data persistence in the API, and display the data in a single-page app (SPA).</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of building a Django blog back end and a Vue front end, using GraphQL to communicate between them. &lt;/p&gt;
&lt;p&gt;You&amp;rsquo;ll revisit how to run the Django server and a Vue application on your computer at the same time.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>How Do You Choose Python Function Names?</title>
      <id>https://realpython.com/python-function-names/</id>
      <link href="https://realpython.com/python-function-names/"/>
      <updated>2024-07-10T14:00:00+00:00</updated>
      <summary>This tutorial discusses the rules and conventions for choosing Python function names and why they&#x27;re important.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;&lt;em&gt;One of the hardest decisions in programming is choosing names&lt;/em&gt;. Programmers often use this phrase to highight the challenges of selecting Python function names. It may be an exaggeration, but there’s still a lot of truth in it.&lt;/p&gt;
&lt;p&gt;There are some hard &lt;strong&gt;rules&lt;/strong&gt; you can’t break when naming Python functions and other objects. There are also other &lt;strong&gt;conventions and best practices&lt;/strong&gt; that don’t raise errors when you break them, but they’re still important when writing &lt;strong&gt;Pythonic code&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Choosing the ideal Python function names makes your code more readable and easier to maintain. Code with well-chosen names can also be less prone to bugs.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll learn about the rules and conventions for naming Python functions and why they’re important. So, &lt;strong&gt;how do you choose Python function names?&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-function-names-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-function-names-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that you’ll use as you learn how to choose Python function names.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;container border rounded text-wrap-pretty my-3&quot;&gt;

  &lt;p class=&quot;my-3&quot;&gt;&lt;mark class=&quot;marker-highlight&quot;&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “How Do You Choose Python Function Names?” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col-xs-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/python-function-names/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;embed-responsive embed-responsive-16by9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 embed-responsive-item rounded&quot; style=&quot;object-fit: contain; background: #e5c5ac;&quot; alt=&quot;How Do You Choose Python Function Names?&quot; src=&quot;https://files.realpython.com/media/What-Are-Naming-Conventions-for-Classes-and-Functions-in-Python_Watermarked.3a219d9e5b3b.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/What-Are-Naming-Conventions-for-Classes-and-Functions-in-Python_Watermarked.3a219d9e5b3b.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/What-Are-Naming-Conventions-for-Classes-and-Functions-in-Python_Watermarked.3a219d9e5b3b.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/What-Are-Naming-Conventions-for-Classes-and-Functions-in-Python_Watermarked.3a219d9e5b3b.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/What-Are-Naming-Conventions-for-Classes-and-Functions-in-Python_Watermarked.3a219d9e5b3b.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)&quot;&gt;


          &lt;div class=&quot;card-img-overlay d-flex align-items-center&quot;&gt;
            &lt;div class=&quot;mx-auto&quot;&gt;
              &lt;span class=&quot;text-light&quot; style=&quot;opacity: 0.90;&quot;&gt;&lt;span class=&quot;icon baseline scale2x&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;div class=&quot;mt-3 d-md-none&quot;&gt;&lt;/div&gt; 
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Interactive Quiz&lt;/strong&gt;&lt;/p&gt;
      &lt;a href=&quot;/quizzes/python-function-names/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;How Do You Choose Python Function Names?&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of how to choose Python function names.
By working through this quiz, you&#x27;ll revisit the rules and conventions for naming Python functions
and why they&#x27;re important for writing Pythonic code.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;in-short-use-descriptive-python-function-names-using-snake_case&quot;&gt;In Short: Use Descriptive Python Function Names Using &lt;code&gt;snake_case&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#in-short-use-descriptive-python-function-names-using-snake_case&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In Python, the labels you use to refer to objects are called &lt;a href=&quot;https://docs.python.org/3/reference/lexical_analysis.html#identifiers&quot;&gt;&lt;em&gt;identifiers&lt;/em&gt; or &lt;em&gt;names&lt;/em&gt;&lt;/a&gt;. You set a name for a Python function when you use the &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;&lt;code&gt;def&lt;/code&gt; keyword&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When creating Python names, you can use uppercase and lowercase letters, the digits 0 to 9, and the underscore (&lt;code&gt;_&lt;/code&gt;). However, you can’t use digits as the first character. You can use some other &lt;a href=&quot;https://en.wikipedia.org/wiki/Unicode&quot;&gt;Unicode&lt;/a&gt; characters in Python identifiers, but not all Unicode characters are valid. &lt;a href=&quot;https://github.com/python/cpython/pull/1686&quot;&gt;Not even 🐍 is valid&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;Still, it’s preferable to use only the Latin characters present in &lt;a href=&quot;https://en.wikipedia.org/wiki/ASCII&quot;&gt;ASCII&lt;/a&gt;. The Latin characters are easier to type and more universally found on most keyboards. Using other characters rarely improves readability and can be a source of bugs.&lt;/p&gt;
&lt;p&gt;Here are some syntactically valid and invalid names for Python functions and other objects:&lt;/p&gt;
&lt;div class=&quot;table-responsive&quot;&gt;
&lt;table class=&quot;table table-hover&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Validity&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;number&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Valid&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;first_name&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Valid&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;first name&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Invalid&lt;/td&gt;
&lt;td&gt;No whitespace allowed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;first_10_numbers&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Valid&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;10_numbers&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Invalid&lt;/td&gt;
&lt;td&gt;No digits allowed at the start of names&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;_name&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Valid&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;greeting!&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Invalid&lt;/td&gt;
&lt;td&gt;No ASCII punctuation allowed except for the underscore (&lt;code&gt;_&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;café&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Valid&lt;/td&gt;
&lt;td&gt;Not recommended&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;你好&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Valid&lt;/td&gt;
&lt;td&gt;Not recommended&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;hello⁀world&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Valid&lt;/td&gt;
&lt;td&gt;Not recommended—&lt;a href=&quot;https://en.wikipedia.org/wiki/Template:Punctuation_marks_in_Unicode#Pc,_connector&quot;&gt;connector punctuation characters&lt;/a&gt; and other marks are valid characters&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;However, Python has conventions about naming functions that go beyond these rules. One of the core Python Enhancement Proposals, &lt;a href=&quot;https://peps.python.org/pep-0008/#naming-conventions&quot;&gt;PEP 8&lt;/a&gt;, defines Python’s style guide, which includes naming conventions.  &lt;/p&gt;
&lt;p&gt;According to PEP 8 style guidelines, Python functions should be named using lowercase letters and with an underscore separating words. This style is often referred to as &lt;a href=&quot;https://simple.wikipedia.org/wiki/Snake_case&quot;&gt;snake case&lt;/a&gt;. For example, &lt;code&gt;get_text()&lt;/code&gt; is a better function name than &lt;code&gt;getText()&lt;/code&gt; in Python.&lt;/p&gt;
&lt;p&gt;Function names should also describe the actions being performed by the function clearly and concisely whenever possible. For example, for a function that calculates the total value of an online order, &lt;code&gt;calculate_total()&lt;/code&gt; is a better name than &lt;code&gt;total()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You’ll explore these conventions and best practices in more detail in the following sections of this tutorial.&lt;/p&gt;
&lt;h2 id=&quot;what-case-should-you-use-for-python-function-names&quot;&gt;What Case Should You Use for Python Function Names?&lt;a class=&quot;headerlink&quot; href=&quot;#what-case-should-you-use-for-python-function-names&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Several character cases, like &lt;strong&gt;snake case&lt;/strong&gt; and &lt;strong&gt;camel case&lt;/strong&gt;, are used in programming for identifiers to name the various entities. Programming languages have their own preferences, so the right style for one language may not be suitable for another.&lt;/p&gt;
&lt;p&gt;Python functions are generally written in &lt;em&gt;snake case&lt;/em&gt;. When you use this format, all the letters are lowercase, including the first letter, and you use an underscore to separate words. You don’t need to use an underscore if the function name includes only one word. The following function names are examples of snake case:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;find_winner()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;save()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both function names include lowercase letters, and one of them has two English words separated by an underscore. You can also use the underscore at the beginning or end of a function name. However, there are conventions outlining when you should use the underscore in this way.&lt;/p&gt;
&lt;p&gt;You can use a &lt;a href=&quot;https://realpython.com/python-double-underscore/#single-leading-underscore-in-python-names&quot;&gt;single leading underscore&lt;/a&gt;, such as with &lt;code&gt;_find_winner()&lt;/code&gt;, to indicate that a function is meant only for internal use. An object with a leading single underscore in its name can be used internally within a module or a class. While Python doesn’t enforce private variables or functions, a leading underscore is an accepted convention to show the programmer’s intent.&lt;/p&gt;
&lt;p&gt;A &lt;a href=&quot;https://realpython.com/python-double-underscore/#trailing-underscores-in-python-names&quot;&gt;single trailing underscore&lt;/a&gt; is used by convention when you want to avoid a conflict with existing Python names or keywords. For example, you can’t use the name &lt;em&gt;import&lt;/em&gt; for a function since &lt;code&gt;import&lt;/code&gt; is a keyword. You can’t use keywords as names for functions or other objects. You can choose a different name, but you can also add a trailing underscore to create &lt;code&gt;import_()&lt;/code&gt;, which is a valid name.&lt;/p&gt;
&lt;p&gt;You can also use a single trailing underscore if you wish to reuse the name of a built-in function or other object. For example, if you want to define a function that you’d like to call &lt;em&gt;max&lt;/em&gt;, you can name your function &lt;code&gt;max_()&lt;/code&gt; to avoid conflict with the built-in function &lt;code&gt;max()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Unlike the case with the keyword &lt;code&gt;import&lt;/code&gt;, &lt;code&gt;max()&lt;/code&gt; is not a keyword but a built-in function. Therefore, you &lt;em&gt;could&lt;/em&gt; define your function using the same name, &lt;code&gt;max()&lt;/code&gt;, but it’s generally preferable to avoid this approach to prevent confusion and ensure you can still use the built-in function.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-function-names/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-function-names/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Quiz: Choosing the Best Font for Programming</title>
      <id>https://realpython.com/quizzes/coding-fonts/</id>
      <link href="https://realpython.com/quizzes/coding-fonts/"/>
      <updated>2024-07-10T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of how to choose the best font for your daily programming. You&#x27;ll get questions about the technicalities and features to consider when choosing a programming font and refresh your knowledge about how to spot a high-quality coding font.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of how to choose the best font for your daily programming. You&amp;rsquo;ll get questions about the technicalities and features to consider when choosing a programming font and refresh your knowledge about how to spot a high-quality coding font.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Customize VS Code Settings</title>
      <id>https://realpython.com/courses/customize-vscode-settings/</id>
      <link href="https://realpython.com/courses/customize-vscode-settings/"/>
      <updated>2024-07-09T14:00:00+00:00</updated>
      <summary>In this course, Philipp helps you customize your Visual Studio Code settings to switch from a basic cluttered look to a clean presentable look. This is not just pleasant on the eyes, but also gives you a nice user interface if you want to share on a zoom call or screen recording.</summary>
      <content type="html">
        &lt;p&gt;Visual Studio Code, is an open-source code editor available on all platforms. It’s also a great platform for Python development. The default settings in VS Code present a somewhat cluttered environment. &lt;/p&gt;
&lt;p&gt;This &lt;strong&gt;Code Conversation&lt;/strong&gt; with instructor Philipp Acsany is about learning how to customize the settings within the interface of VS Code. Having a clean digital workspace is an important part of your work life. Removing distractions and making code more readable can increase productivity and even help you spot bugs.&lt;/p&gt;
&lt;p&gt;In this &lt;strong&gt;Code Conversation&lt;/strong&gt;, you&amp;rsquo;ll learn how to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Work With User Settings&lt;/li&gt;
&lt;li&gt;Create a VS Code Profile&lt;/li&gt;
&lt;li&gt;Find and Adjust Specific Settings&lt;/li&gt;
&lt;li&gt;Clean Up the VS Code User Interface&lt;/li&gt;
&lt;li&gt;Export Your Profile to Re-use Across Installations&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Quiz: Split Your Dataset With scikit-learn&#x27;s train_test_split()</title>
      <id>https://realpython.com/quizzes/train-test-split-python-data/</id>
      <link href="https://realpython.com/quizzes/train-test-split-python-data/"/>
      <updated>2024-07-09T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of how to use the train_test_split() function from the scikit-learn library to split your dataset into subsets for unbiased evaluation in machine learning.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of
&lt;a href=&quot;https://realpython.com/train-test-split-python-data/&quot;&gt;how to use &lt;code&gt;train_test_split()&lt;/code&gt;&lt;/a&gt; from the &lt;code&gt;sklearn&lt;/code&gt; library.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit why you need to split your dataset in supervised machine learning, which subsets of the dataset you need for an unbiased evaluation of your model, how to use &lt;code&gt;train_test_split()&lt;/code&gt; to split your data, and how to combine &lt;code&gt;train_test_split()&lt;/code&gt; with prediction methods.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python News Roundup: July 2024</title>
      <id>https://realpython.com/python-news-july-2024/</id>
      <link href="https://realpython.com/python-news-july-2024/"/>
      <updated>2024-07-08T14:00:00+00:00</updated>
      <summary>Over the last month, NumPy and Polars have released new major versions. While the data science ecosystem sees some important developments, there are also important discussions about the core language itself, including how Python should be versioned in the future.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Summer isn’t all holidays and lazy days at the beach. Over the last month, two important players in the data science ecosystem released new major versions. NumPy published version 2.0, which comes with several improvements but also some breaking changes. At the same time, Polars reached its version 1.0 milestone and is now considered production-ready.&lt;/p&gt;
&lt;p&gt;PyCon US was hosted in Pittsburgh, Pennsylvania in May. The conference is an important meeting spot for the community and sparked some new ideas and discussions. You can read about some of these in PSF’s coverage of the Python Language Summit, and watch some of the videos posted from the conference.&lt;/p&gt;
&lt;p&gt;Dive in to learn more about the most important Python news from the last month. &lt;/p&gt;
&lt;h2 id=&quot;numpy-version-20&quot;&gt;NumPy Version 2.0&lt;a class=&quot;headerlink&quot; href=&quot;#numpy-version-20&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://realpython.com/numpy-tutorial/&quot;&gt;NumPy&lt;/a&gt; is a foundational package in the data science space. The library provides in-memory &lt;em&gt;N&lt;/em&gt;-dimensional arrays and many functions for fast operations on those arrays.&lt;/p&gt;
&lt;p&gt;Many libraries in the ecosystem use NumPy under the hood, including &lt;a href=&quot;https://realpython.com/pandas-dataframe/&quot;&gt;pandas&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-scipy-cluster-optimize/&quot;&gt;SciPy&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/train-test-split-python-data/&quot;&gt;scikit-learn&lt;/a&gt;. The NumPy package has been around for close to twenty years and has played an important role in the rising popularity of Python among data scientists.&lt;/p&gt;
&lt;p&gt;The new version 2.0 of NumPy is an important milestone, which adds an improved string type, cleans up the library, and improves performance. However, it comes with some changes that may affect your code.&lt;/p&gt;
&lt;p&gt;The biggest breaking changes happen in the C-API of NumPy. Typically, this won’t affect you directly, but it can affect other libraries that you rely on. The community has rallied strongly and most of the bigger packages already support NumPy 2.0. You can check NumPy’s table of &lt;a href=&quot;https://github.com/numpy/numpy/issues/26191&quot;&gt;ecosystem support&lt;/a&gt; for details.&lt;/p&gt;
&lt;p&gt;One of the main reasons for using NumPy is that the library can do fast and convenient array operations. For a simple example, the following code calculates square numbers:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;numbers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;go&quot;&gt;[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;np&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;numbers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;go&quot;&gt;array([ 0,  1,  4,  9, 16, 25, 36, 49, 64, 81])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;First, you use &lt;a href=&quot;https://realpython.com/python-range/&quot;&gt;&lt;code&gt;range()&lt;/code&gt;&lt;/a&gt; and a &lt;a href=&quot;https://realpython.com/list-comprehension-python/&quot;&gt;list comprehension&lt;/a&gt; to calculate the first ten square numbers in pure Python. Then, you repeat the calculation with NumPy. Note that you don’t need to explicitly spell out the loop. NumPy handles that for you under the hood.&lt;/p&gt;
&lt;p&gt;Furthermore, the NumPy version will be considerably faster, especially for bigger arrays of numbers. One of the secrets to this speed is that NumPy arrays are limited to having one data type, while a Python list can be heterogeneous. One list can contain elements as different as integers, floats, strings, and even nested lists. That’s not possible in a NumPy array.&lt;/p&gt;
&lt;h3 id=&quot;improved-string-handling&quot;&gt;Improved String Handling&lt;a class=&quot;headerlink&quot; href=&quot;#improved-string-handling&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;By enforcing all elements to be of the same type that take up the same number of bytes in memory, NumPy can quickly find and work with individual elements. One downside to this has been that strings can be awkward to work with:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;words&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;numpy&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;python&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;words&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;array([&#x27;numpy&#x27;, &#x27;python&#x27;], dtype=&#x27;&amp;lt;U6&#x27;)&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;words&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;monty python&quot;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;words&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;array([&#x27;numpy&#x27;, &#x27;monty &#x27;], dtype=&#x27;&amp;lt;U6&#x27;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You first create an array consisting of two strings. Note that NumPy automatically detects that the longest string is six characters long, so it sets aside space for each string to be six characters long. The &lt;code&gt;6&lt;/code&gt; in the data type string, &lt;code&gt;&amp;lt;U6&lt;/code&gt;, indicates this.&lt;/p&gt;
&lt;p&gt;Next, you try to replace the second string with a longer string. Unfortunately, only the first six characters are stored since that’s how much space NumPy has set aside for each string in this array. There are ways to work around these limitations, but in NumPy 2.0, you can take advantage of variable length strings instead:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-news-july-2024/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-news-july-2024/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #211: Python Doesn&#x27;t Round Numbers the Way You Might Think</title>
      <id>https://realpython.com/podcasts/rpp/211/</id>
      <link href="https://realpython.com/podcasts/rpp/211/"/>
      <updated>2024-07-05T12:00:00+00:00</updated>
      <summary>Does Python round numbers the same way you learned back in math class? You might be surprised by the default method Python uses and the variety of ways to round numbers in Python. Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;Does Python round numbers the same way you learned back in math class? You might be surprised by the default method Python uses and the variety of ways to round numbers in Python. Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Working With JSON Data in Python</title>
      <id>https://realpython.com/python-json/</id>
      <link href="https://realpython.com/python-json/"/>
      <updated>2024-07-03T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to read and write JSON-encoded data in Python. You&#x27;ll begin with practical examples that show how to use Python&#x27;s built-in &quot;json&quot; module and then move on to learn how to serialize and deserialize custom data.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Since its introduction, &lt;a href=&quot;https://en.wikipedia.org/wiki/JSON&quot;&gt;JSON&lt;/a&gt; has rapidly emerged as the predominant standard for the exchange of information. Whether you want to transfer data with an &lt;a href=&quot;https://realpython.com/api-integration-in-python/&quot;&gt;API&lt;/a&gt; or store information in a &lt;a href=&quot;https://realpython.com/introduction-to-mongodb-and-python/&quot;&gt;document database&lt;/a&gt;, it’s likely you’ll encounter JSON. Fortunately, Python provides robust tools to facilitate this process and help you manage JSON data efficiently.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Understand&lt;/strong&gt; the JSON syntax&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Convert&lt;/strong&gt; Python data to JSON&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Deserialize&lt;/strong&gt; JSON to Python&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Write and read&lt;/strong&gt; JSON files&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Validate&lt;/strong&gt; JSON syntax&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Prettify&lt;/strong&gt; JSON in the terminal&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Minify&lt;/strong&gt; JSON with Python&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;While JSON is the most common format for data distribution, it’s not the only option for such tasks. Both &lt;a href=&quot;https://realpython.com/python-xml-parser/&quot;&gt;XML&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-yaml/&quot;&gt;YAML&lt;/a&gt; serve similar purposes. If you’re interested in how the formats differ, then you can check out the tutorial on how to &lt;a href=&quot;https://realpython.com/python-serialize-data/&quot;&gt;serialize your data with Python&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-json/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-json&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to work with JSON data in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;container border rounded text-wrap-pretty my-3&quot;&gt;

  &lt;p class=&quot;my-3&quot;&gt;&lt;mark class=&quot;marker-highlight&quot;&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “Working With JSON Data in Python” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col-xs-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/python-json/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;embed-responsive embed-responsive-16by9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 embed-responsive-item rounded&quot; style=&quot;object-fit: contain; background: #ff7e74;&quot; alt=&quot;Working With JSON Data in Python&quot; src=&quot;https://files.realpython.com/media/Working-With-JSON-Data-in-Python_Watermarked.66a8fdcb8859.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Working-With-JSON-Data-in-Python_Watermarked.66a8fdcb8859.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Working-With-JSON-Data-in-Python_Watermarked.66a8fdcb8859.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Working-With-JSON-Data-in-Python_Watermarked.66a8fdcb8859.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Working-With-JSON-Data-in-Python_Watermarked.66a8fdcb8859.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)&quot;&gt;


          &lt;div class=&quot;card-img-overlay d-flex align-items-center&quot;&gt;
            &lt;div class=&quot;mx-auto&quot;&gt;
              &lt;span class=&quot;text-light&quot; style=&quot;opacity: 0.90;&quot;&gt;&lt;span class=&quot;icon baseline scale2x&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;div class=&quot;mt-3 d-md-none&quot;&gt;&lt;/div&gt; 
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Interactive Quiz&lt;/strong&gt;&lt;/p&gt;
      &lt;a href=&quot;/quizzes/python-json/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Working With JSON Data in Python&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of working with JSON in Python. By working through this quiz, you&#x27;ll revisit key concepts related to JSON data manipulation and handling in Python.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;introducing-json&quot;&gt;Introducing JSON&lt;a class=&quot;headerlink&quot; href=&quot;#introducing-json&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The acronym &lt;strong&gt;JSON&lt;/strong&gt; stands for &lt;a href=&quot;https://www.json.org/&quot;&gt;JavaScript Object Notation&lt;/a&gt;. As the name suggests, JSON originated from &lt;a href=&quot;https://realpython.com/python-vs-javascript/&quot;&gt;JavaScript&lt;/a&gt;. However, JSON has transcended its origins to become language-agnostic and is now recognized as the &lt;a href=&quot;https://tools.ietf.org/html/rfc8259&quot;&gt;standard&lt;/a&gt; for &lt;strong&gt;data interchange&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The popularity of JSON can be attributed to native support by the JavaScript language, resulting in excellent parsing performance in web browsers. On top of that, JSON’s straightforward syntax allows both humans and computers to read and write JSON data effortlessly.&lt;/p&gt;
&lt;p&gt;To get a first impression of JSON, have a look at this example code:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;json&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--purple&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;JSON&lt;/span&gt;
    &lt;span class=&quot;mr-2&quot; aria-label=&quot;Filename&quot;&gt;&lt;code style=&quot;color: inherit;&quot;&gt;hello_world.json&lt;/code&gt;&lt;/span&gt;
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;greeting&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hello, world!&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You’ll learn more about the JSON syntax later in this tutorial. For now, recognize that the JSON format is &lt;strong&gt;text-based&lt;/strong&gt;. In other words, you can create JSON files using the code editor of your choice. Once you set the file extension to &lt;code&gt;.json&lt;/code&gt;, most code editors display your JSON data with syntax highlighting out of the box:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/json-syntax-highlighting.bf172e2b07bd.png&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block &quot; src=&quot;https://files.realpython.com/media/json-syntax-highlighting.bf172e2b07bd.png&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/json-syntax-highlighting.bf172e2b07bd.png 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/json-syntax-highlighting.bf172e2b07bd.png 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/json-syntax-highlighting.bf172e2b07bd.png 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/json-syntax-highlighting.bf172e2b07bd.png 1920w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Editor screenshot with code highlighting for a JSON file&quot; data-asset=&quot;5839&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;The screenshot above shows how &lt;a href=&quot;https://realpython.com/python-development-visual-studio-code/&quot;&gt;VS Code&lt;/a&gt; displays JSON data using the &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=BeardedBear.beardedtheme&quot;&gt;Bearded color theme&lt;/a&gt;. You’ll have a closer look at the syntax of the JSON format next!&lt;/p&gt;
&lt;h3 id=&quot;examining-json-syntax&quot;&gt;Examining JSON Syntax&lt;a class=&quot;headerlink&quot; href=&quot;#examining-json-syntax&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In the previous section, you got a first impression of how JSON data looks. And as a Python developer, the JSON structure probably reminds you of &lt;a href=&quot;https://realpython.com/python-data-structures/&quot;&gt;common Python data structures&lt;/a&gt;, like a dictionary that contains a string as a key and a value. If you understand the syntax of a &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionary&lt;/a&gt; in Python, you already know the general syntax of a &lt;strong&gt;JSON object&lt;/strong&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Later in this tutorial, you’ll learn that you’re free to use lists and other data types at the top level of a JSON document.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The similarity between Python dictionaries and JSON objects is no surprise. One idea behind establishing JSON as the go-to data interchange format was to make working with JSON as convenient as possible, independently of which programming language you use:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;[A collection of key-value pairs and arrays] are universal data structures. Virtually all modern programming languages support them in one form or another. It makes sense that a data format that is interchangeable with programming languages is also based on these structures. (&lt;a href=&quot;https://www.json.org/json-en.html&quot;&gt;Source&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;To explore the JSON syntax further, create a new file named &lt;code&gt;hello_frieda.json&lt;/code&gt; and add a more complex JSON structure as the content of the file:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;json&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--purple&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;JSON&lt;/span&gt;
    &lt;span class=&quot;mr-2&quot; aria-label=&quot;Filename&quot;&gt;&lt;code style=&quot;color: inherit;&quot;&gt;hello_frieda.json&lt;/code&gt;&lt;/span&gt;
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;linenos&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Frieda&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 3&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;isDog&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 4&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;hobbies&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;eating&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;sleeping&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;barking&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 5&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;age&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 6&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;address&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 7&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;work&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 8&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;home&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Berlin&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Germany&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 9&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;friends&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Philipp&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;hobbies&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;eating&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;sleeping&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;reading&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Mitch&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;hobbies&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;running&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;snacking&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;19&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In the code above, you see data about a dog named Frieda, which is formatted as JSON. The top-level value is a JSON object. Just like Python dictionaries, you wrap JSON objects inside curly braces (&lt;code&gt;{}&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;In line 1, you start the JSON object with an opening curly brace (&lt;code&gt;{&lt;/code&gt;), and then you close the object at the end of line 20 with a closing curly brace (&lt;code&gt;}&lt;/code&gt;).&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Although whitespace doesn’t matter in JSON, it’s customary for JSON documents to be formatted with two or four spaces to indicate indentation. If the file size of the JSON document is important, then you may consider minifying the JSON file by removing the whitespace. You’ll learn more about minifying JSON data later in the tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Inside the JSON object, you can define zero, one, or more key-value pairs. If you add multiple key-value pairs, then you must separate them with a comma (&lt;code&gt;,&lt;/code&gt;).&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-json/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-json/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Quiz: Python&#x27;s Magic Methods: Leverage Their Power in Your Classes</title>
      <id>https://realpython.com/quizzes/python-magic-methods/</id>
      <link href="https://realpython.com/quizzes/python-magic-methods/"/>
      <updated>2024-07-03T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of Python&#x27;s magic methods. These special methods are fundamental to object-oriented programming in Python, allowing you to customize the behavior of your classes.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of
&lt;a href=&quot;https://realpython.com/python-magic-methods/&quot;&gt;Python&amp;rsquo;s Magic Methods&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit the concept of magic methods in Python, how they work, and how you can use them to customize the behavior of your classes.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Defining Python Constants for Code Maintainability</title>
      <id>https://realpython.com/courses/defining-constants-code-maintainability/</id>
      <link href="https://realpython.com/courses/defining-constants-code-maintainability/"/>
      <updated>2024-07-02T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to properly define constants in Python. By coding a bunch of practical example, you&#x27;ll also learn how Python constants can improve your code&#x27;s readability, reusability, and maintainability.</summary>
      <content type="html">
        &lt;p&gt;In programming, the term &lt;strong&gt;constant&lt;/strong&gt; refers to names representing values that don&amp;rsquo;t change during a program&amp;rsquo;s execution. Constants are a fundamental concept in programming, and Python developers use them in many cases. However, Python doesn&amp;rsquo;t have a dedicated syntax for defining constants. In practice, Python constants are just &lt;strong&gt;variables&lt;/strong&gt; that &lt;em&gt;never change&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;To prevent programmers from reassigning a name that&amp;rsquo;s supposed to hold a constant, the Python community has adopted a naming convention: &lt;em&gt;use uppercase letters&lt;/em&gt;. For every Pythonista, it&amp;rsquo;s essential to know what constants are, as well as why and when to use them.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Properly &lt;strong&gt;define constants&lt;/strong&gt; in Python&lt;/li&gt;
&lt;li&gt;Identify some &lt;strong&gt;built-in constants&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;Use constants to improve your code&amp;rsquo;s &lt;strong&gt;readability&lt;/strong&gt;, &lt;strong&gt;reusability&lt;/strong&gt;, and &lt;strong&gt;maintainability&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Apply different approaches to &lt;strong&gt;organize&lt;/strong&gt; and &lt;strong&gt;manage&lt;/strong&gt; constants in a project&lt;/li&gt;
&lt;li&gt;Use several techniques to make constants &lt;strong&gt;strictly constant&lt;/strong&gt; in Python&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python&#x27;s Built-in Functions: A Complete Exploration</title>
      <id>https://realpython.com/python-built-in-functions/</id>
      <link href="https://realpython.com/python-built-in-functions/"/>
      <updated>2024-07-01T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn the basics of working with Python&#x27;s numerous built-in functions. You&#x27;ll explore how to use these predefined functions to perform common tasks and operations, such as mathematical calculations, data type conversions, and string manipulations.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python has many &lt;strong&gt;built-in functions&lt;/strong&gt; that you can use directly without importing anything. These functions cover a wide variety of common programming tasks that include performing math operations, working with built-in data types, processing iterables of data, handling input and output in your programs, working with scopes, and more.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Get to know Python’s &lt;strong&gt;built-in functions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Learn about common &lt;strong&gt;use cases&lt;/strong&gt; of Python’s built-in functions&lt;/li&gt;
&lt;li&gt;Use these functions to solve &lt;strong&gt;practical problems&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this tutorial, you’ll need to be familiar with Python programming, including topics like working with built-in &lt;a href=&quot;https://realpython.com/python-data-types/&quot;&gt;data types&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;functions&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-classes/&quot;&gt;classes&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/primer-on-python-decorators/&quot;&gt;decorators&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-scope-legb-rule/&quot;&gt;scopes&lt;/a&gt;, and the &lt;a href=&quot;https://realpython.com/python-import/&quot;&gt;import&lt;/a&gt; system.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-built-in-functions-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-built-in-functions-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to use Python’s built-in functions.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;container border rounded text-wrap-pretty my-3&quot;&gt;

  &lt;p class=&quot;my-3&quot;&gt;&lt;mark class=&quot;marker-highlight&quot;&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “Python&#x27;s Built-in Functions: A Complete Exploration” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col-xs-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/python-built-in-functions/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;embed-responsive embed-responsive-16by9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 embed-responsive-item rounded&quot; style=&quot;object-fit: contain; background: #ff7e74;&quot; alt=&quot;Python&#x27;s Built-in Functions: A Complete Exploration&quot; src=&quot;https://files.realpython.com/media/Pythons-Built-in-Functions-A-Quick-Exploration_Watermarked.44a8e102943b.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Pythons-Built-in-Functions-A-Quick-Exploration_Watermarked.44a8e102943b.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Pythons-Built-in-Functions-A-Quick-Exploration_Watermarked.44a8e102943b.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Pythons-Built-in-Functions-A-Quick-Exploration_Watermarked.44a8e102943b.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Pythons-Built-in-Functions-A-Quick-Exploration_Watermarked.44a8e102943b.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)&quot;&gt;


          &lt;div class=&quot;card-img-overlay d-flex align-items-center&quot;&gt;
            &lt;div class=&quot;mx-auto&quot;&gt;
              &lt;span class=&quot;text-light&quot; style=&quot;opacity: 0.90;&quot;&gt;&lt;span class=&quot;icon baseline scale2x&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;div class=&quot;mt-3 d-md-none&quot;&gt;&lt;/div&gt; 
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Interactive Quiz&lt;/strong&gt;&lt;/p&gt;
      &lt;a href=&quot;/quizzes/python-built-in-functions/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Python&#x27;s Built-in Functions: A Complete Exploration&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Take this quiz to test your knowledge about the available built-in functions in Python. By taking this quiz, you&#x27;ll deepen your understanding of how to use these functions and the common programming problems they cover, from mathematical computations to Python-specific features.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;built-in-functions-in-python&quot;&gt;Built-in Functions in Python&lt;a class=&quot;headerlink&quot; href=&quot;#built-in-functions-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python has several &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;functions&lt;/a&gt; available for you to use directly from anywhere in your code. These functions are known as &lt;a href=&quot;https://docs.python.org/3/library/functions.html&quot;&gt;built-in functions&lt;/a&gt; and they cover many common programming problems, from mathematical computations to Python-specific features.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Many of Python’s built-in functions are classes with function-style names. Good examples are &lt;code&gt;str&lt;/code&gt;, &lt;code&gt;tuple&lt;/code&gt;, &lt;code&gt;list&lt;/code&gt;, and &lt;code&gt;dict&lt;/code&gt;, which are classes that define built-in data types. These classes are listed in the Python documentation as &lt;em&gt;built-in functions&lt;/em&gt; and you’ll find them in this tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In this tutorial, you’ll learn the basics of Python’s built-in functions. By the end, you’ll know what their use cases are and how they work. To kick things off, you’ll start with those built-in functions related to math computations.&lt;/p&gt;
&lt;h2 id=&quot;using-math-related-built-in-functions&quot;&gt;Using Math-Related Built-in Functions&lt;a class=&quot;headerlink&quot; href=&quot;#using-math-related-built-in-functions&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In Python, you’ll find a few built-in functions that take care of common math operations, like computing the absolute value of a &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;number&lt;/a&gt;, calculating powers, and more. Here’s a summary of the math-related built-in functions in Python:&lt;/p&gt;
&lt;div class=&quot;table-responsive&quot;&gt;
&lt;table class=&quot;table table-hover&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://realpython.com/python-absolute-value/&quot;&gt;&lt;code&gt;abs()&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Calculates the absolute value of a number&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://docs.python.org/3/library/functions.html#divmod&quot;&gt;&lt;code&gt;divmod()&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Computes the quotient and remainder of integer division&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://realpython.com/python-min-and-max/&quot;&gt;&lt;code&gt;max()&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Finds the largest of the given arguments or items in an iterable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://realpython.com/python-min-and-max/&quot;&gt;&lt;code&gt;min()&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Finds the smallest of the given arguments or items in an iterable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://docs.python.org/3/library/functions.html#pow&quot;&gt;&lt;code&gt;pow()&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Raises a number to a power&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://realpython.com/python-rounding/#pythons-built-in-round-function&quot;&gt;&lt;code&gt;round()&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Rounds a floating-point value&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://realpython.com/python-sum-function/&quot;&gt;&lt;code&gt;sum()&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Sums the values in an iterable&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;In the following sections, you’ll learn how these functions work and how to use them in your Python code.&lt;/p&gt;
&lt;h3 id=&quot;getting-the-absolute-value-of-a-number-abs&quot;&gt;Getting the Absolute Value of a Number: &lt;code&gt;abs()&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#getting-the-absolute-value-of-a-number-abs&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Absolute_value&quot;&gt;absolute value&lt;/a&gt; or &lt;strong&gt;modulus&lt;/strong&gt; of a &lt;a href=&quot;https://en.wikipedia.org/wiki/Real_number&quot;&gt;real number&lt;/a&gt; is its non-negative value. In other words, the absolute value is the number without its &lt;a href=&quot;https://en.wikipedia.org/wiki/Sign_(mathematics)&quot;&gt;sign&lt;/a&gt;. For example, the absolute value of &lt;em&gt;-5&lt;/em&gt; is &lt;em&gt;5&lt;/em&gt;, and the absolute value of &lt;em&gt;5&lt;/em&gt; is also &lt;em&gt;5&lt;/em&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; To learn more about &lt;code&gt;abs()&lt;/code&gt;, check out the &lt;a href=&quot;https://realpython.com/python-absolute-value/&quot;&gt;How to Find an Absolute Value in Python&lt;/a&gt; tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Python’s built-in &lt;code&gt;abs()&lt;/code&gt; function allows you to quickly compute the absolute value or modulus of a &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;number&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;decimal&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Decimal&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;fractions&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Fraction&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;42&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;42&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;42.42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;42.42&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;42.42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;42.42&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;complex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-2+3j&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;3.605551275463989&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;complex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;2+3j&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;3.605551275463989&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fraction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-1/2&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Fraction(1, 2)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fraction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;1/2&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Fraction(1, 2)&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Decimal&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-0.5&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Decimal(&#x27;0.5&#x27;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Decimal&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;0.5&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Decimal(&#x27;0.5&#x27;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In these examples, you compute the absolute value of different numeric types using the &lt;code&gt;abs()&lt;/code&gt; function. First, you use integer numbers, then floating-point and complex numbers, and finally, fractional and decimal numbers. In all cases, when you call the function with a negative value, the final result removes the sign.&lt;/p&gt;
&lt;p&gt;For a practical example, say that you need to compute the total profits and losses of your company from a month’s transactions:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;transactions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;incomes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;income&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;income&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;transactions&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;income&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;expenses&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;expense&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;expense&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;transactions&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;expense&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Total incomes: $&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;incomes&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Total incomes: $800&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Total expenses: $&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;expenses&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Total expenses: $300&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Total profit: $&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;incomes&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;expenses&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Total profit: $500&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this example, to compute the expenses, you use the &lt;code&gt;abs()&lt;/code&gt; function to get the absolute value of the expenses, which results in a positive value.&lt;/p&gt;
&lt;h3 id=&quot;finding-the-quotient-and-remainder-in-division-divmod&quot;&gt;Finding the Quotient and Remainder in Division: &lt;code&gt;divmod()&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#finding-the-quotient-and-remainder-in-division-divmod&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Python provides a built-in function called &lt;code&gt;divmod()&lt;/code&gt; that takes two numbers as arguments and &lt;a href=&quot;https://realpython.com/python-return-statement/&quot;&gt;returns&lt;/a&gt; a tuple with the &lt;strong&gt;quotient&lt;/strong&gt; and &lt;strong&gt;remainder&lt;/strong&gt; that result from the integer division of the input numbers:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-built-in-functions/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-built-in-functions/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #210: Creating a Guitar Synthesizer &amp; Generating WAV Files With Python</title>
      <id>https://realpython.com/podcasts/rpp/210/</id>
      <link href="https://realpython.com/podcasts/rpp/210/"/>
      <updated>2024-06-28T12:00:00+00:00</updated>
      <summary>What techniques go into synthesizing a guitar sound in Python? What higher-level programming and Python concepts can you practice while building advanced projects? This week on the show, we talk with Real Python author and core team member Bartosz Zaczyński about his recent step-by-step project, Build a Guitar Synthesizer: Play Musical Tablature in Python.</summary>
      <content type="html">
        &lt;p&gt;What techniques go into synthesizing a guitar sound in Python? What higher-level programming and Python concepts can you practice while building advanced projects? This week on the show, we talk with Real Python author and core team member Bartosz Zaczyński about his recent step-by-step project, Build a Guitar Synthesizer: Play Musical Tablature in Python.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Understanding the Python Mock Object Library</title>
      <id>https://realpython.com/python-mock-library/</id>
      <link href="https://realpython.com/python-mock-library/"/>
      <updated>2024-06-26T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to use the Python mock object library, unittest.mock, to create and use mock objects to improve your tests. Obstacles like complex logic and unpredictable dependencies make writing valuable tests difficult, but unittest.mock can help you overcome these obstacles.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python’s &lt;code&gt;unittest.mock&lt;/code&gt; library is a tool that helps you create mock objects to simulate complex logic and unpredictable &lt;a href=&quot;https://realpython.com/courses/managing-python-dependencies/&quot;&gt;dependencies&lt;/a&gt;.
This helps you write valuable tests that verify your application logic is correct, reliable, and efficient.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll be able to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Create Python mock objects&lt;/strong&gt; using &lt;code&gt;Mock&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Assert&lt;/strong&gt; that you’re using objects as you intended&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Inspect&lt;/strong&gt; usage data stored on your Python mocks&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Configure&lt;/strong&gt; certain aspects of your Python mock objects&lt;/li&gt;
&lt;li&gt;Substitute your mocks for real objects using &lt;strong&gt;&lt;code&gt;patch()&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Avoid common problems&lt;/strong&gt; inherent in Python mocking&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You’ll begin by learning about what mocking is and how you can use it to improve your tests.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-mock-library-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-mock-library-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that you’ll use to learn about Python’s mock object library.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;container border rounded text-wrap-pretty my-3&quot;&gt;

  &lt;p class=&quot;my-3&quot;&gt;&lt;mark class=&quot;marker-highlight&quot;&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “Understanding the Python Mock Object Library” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col-xs-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/python-mock-library/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;embed-responsive embed-responsive-16by9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 embed-responsive-item rounded&quot; style=&quot;object-fit: contain; background: #abe0e6;&quot; alt=&quot;Understanding the Python Mock Object Library&quot; src=&quot;https://files.realpython.com/media/unittest.mock-Tutorial_Watermarked.8e92b54478af.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/unittest.mock-Tutorial_Watermarked.8e92b54478af.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/unittest.mock-Tutorial_Watermarked.8e92b54478af.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/unittest.mock-Tutorial_Watermarked.8e92b54478af.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/unittest.mock-Tutorial_Watermarked.8e92b54478af.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)&quot;&gt;


          &lt;div class=&quot;card-img-overlay d-flex align-items-center&quot;&gt;
            &lt;div class=&quot;mx-auto&quot;&gt;
              &lt;span class=&quot;text-light&quot; style=&quot;opacity: 0.90;&quot;&gt;&lt;span class=&quot;icon baseline scale2x&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;div class=&quot;mt-3 d-md-none&quot;&gt;&lt;/div&gt; 
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Interactive Quiz&lt;/strong&gt;&lt;/p&gt;
      &lt;a href=&quot;/quizzes/python-mock-library/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Understanding the Python Mock Object Library&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of Python&#x27;s unittest.mock library. With this knowledge, you&#x27;ll be able to write robust tests, create mock objects, and ensure your code is reliable and efficient.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;what-is-mocking&quot;&gt;What Is Mocking?&lt;a class=&quot;headerlink&quot; href=&quot;#what-is-mocking&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A &lt;a href=&quot;https://en.wikipedia.org/wiki/Mock_object&quot;&gt;mock object&lt;/a&gt; substitutes and imitates a real object within a &lt;a href=&quot;https://realpython.com/python-testing/&quot;&gt;testing environment&lt;/a&gt;. Using mock objects is a versatile and powerful way to &lt;a href=&quot;https://realpython.com/python-cli-testing/#mocks&quot;&gt;improve the quality of your tests&lt;/a&gt;. This is because by using Python mock objects, you can control your code’s behavior during testing.&lt;/p&gt;
&lt;p&gt;For example, if your code makes &lt;a href=&quot;https://realpython.com/python-requests/&quot;&gt;HTTP requests&lt;/a&gt; to external services, then your tests execute predictably only so far as the services are behaving as you expected. Sometimes, a temporary change in the behavior of these external services can cause intermittent failures within your test suite.&lt;/p&gt;
&lt;p&gt;Because of this, it would be better for you to test your code in a controlled environment. &lt;a href=&quot;https://realpython.com/testing-third-party-apis-with-mocks/&quot;&gt;Replacing the actual request with a mock object&lt;/a&gt; would allow you to simulate external service outages and successful responses in a predictable way.&lt;/p&gt;
&lt;p&gt;Sometimes, it’s difficult to test certain areas of your codebase. Such areas include &lt;code&gt;except&lt;/code&gt; blocks and &lt;code&gt;if&lt;/code&gt; statements that are hard to satisfy. Using Python mock objects can help you control the execution path of your code to reach these areas and improve your &lt;a href=&quot;https://en.wikipedia.org/wiki/Code_coverage&quot;&gt;code coverage&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Another reason to use mock objects is to better understand how you’re using their real counterparts in your code. A Python mock object contains data about its usage that you can inspect, such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you called a method&lt;/li&gt;
&lt;li&gt;How you called the method&lt;/li&gt;
&lt;li&gt;How often you called the method&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Understanding what a mock object does is the first step to learning how to use one.
Next, you’ll explore the Python mock object library to see how to use Python mock objects.&lt;/p&gt;
&lt;h2 id=&quot;the-python-mock-library&quot;&gt;The Python Mock Library&lt;a class=&quot;headerlink&quot; href=&quot;#the-python-mock-library&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python’s built-in mock object library is &lt;a href=&quot;https://docs.python.org/3/library/unittest.mock.html&quot;&gt;&lt;code&gt;unittest.mock&lt;/code&gt;&lt;/a&gt;. It provides an easy way to introduce mocks into your tests.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The standard library includes &lt;code&gt;unittest.mock&lt;/code&gt; starting from Python 3.3 and in all newer versions. If you’re using an older version of Python, then you’ll need to install the official backport of the library.&lt;/p&gt;
&lt;p&gt;To do so, install &lt;a href=&quot;https://pypi.org/project/mock/&quot;&gt;&lt;code&gt;mock&lt;/code&gt;&lt;/a&gt; from the &lt;strong&gt;Python Package Index (PyPI)&lt;/strong&gt; using &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;&lt;code&gt;pip&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Shell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-m&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;pip&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;mock
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You may want to create and activate a &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;virtual environment&lt;/a&gt; before installing the package.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;code&gt;unittest.mock&lt;/code&gt; provides a class called &lt;code&gt;Mock&lt;/code&gt;, which you’ll use to imitate real objects in your codebase. &lt;code&gt;Mock&lt;/code&gt;, along with its subclasses, offers incredible flexibility and insightful data that will meet most of your Python mocking needs.&lt;/p&gt;
&lt;p&gt;The library also provides a function called &lt;code&gt;patch()&lt;/code&gt;, which replaces the real objects in your code with &lt;code&gt;Mock&lt;/code&gt; instances. You can use &lt;code&gt;patch()&lt;/code&gt; as either a &lt;a href=&quot;https://realpython.com/primer-on-python-decorators/&quot;&gt;decorator&lt;/a&gt; or a &lt;a href=&quot;https://realpython.com/python-with-statement/&quot;&gt;context manager&lt;/a&gt;, giving you control over the scope in which the object will be mocked. Once the designated scope exits, &lt;code&gt;patch()&lt;/code&gt; will clean up your code by replacing the mocked objects with their original counterparts.&lt;/p&gt;
&lt;p&gt;Finally, &lt;code&gt;unittest.mock&lt;/code&gt; provides solutions for some of the issues inherent in mocking objects, which you’ll explore later in this tutorial. &lt;/p&gt;
&lt;p&gt;Now that you have a better understanding of what mocking is and the library you’ll be using, it’s time to dive in and explore the features and functionalities &lt;code&gt;unittest.mock&lt;/code&gt; has to offer.&lt;/p&gt;
&lt;h2 id=&quot;the-mock-object&quot;&gt;The &lt;code&gt;Mock&lt;/code&gt; Object&lt;a class=&quot;headerlink&quot; href=&quot;#the-mock-object&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;unittest.mock&lt;/code&gt; offers a base class for mocking objects called &lt;code&gt;Mock&lt;/code&gt;. The use cases for &lt;code&gt;Mock&lt;/code&gt; are practically limitless because &lt;code&gt;Mock&lt;/code&gt; is so flexible.&lt;/p&gt;
&lt;p&gt;Begin by instantiating a new &lt;code&gt;Mock&lt;/code&gt; instance:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;unittest.mock&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Mock&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mock&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Mock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mock&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;lt;Mock id=&#x27;4561344720&#x27;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-mock-library/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-mock-library/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Build a GUI Calculator With PyQt and Python</title>
      <id>https://realpython.com/courses/build-gui-calculator-pyqt/</id>
      <link href="https://realpython.com/courses/build-gui-calculator-pyqt/"/>
      <updated>2024-06-25T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to create graphical user interface (GUI) applications with Python and PyQt. Once you&#x27;ve covered the basics, you&#x27;ll build a fully functional desktop calculator that can respond to user events with concrete actions.</summary>
      <content type="html">
        &lt;p&gt;Even though web and mobile applications appear to have taken over the software development market, there&amp;rsquo;s still demand for traditional &lt;strong&gt;graphical user interface (GUI)&lt;/strong&gt; desktop applications. If you&amp;rsquo;re interested in building these kinds of applications in Python, then you&amp;rsquo;ll find a wide variety of libraries to choose from. They include &lt;a href=&quot;https://docs.python.org/3/library/tkinter.html&quot;&gt;Tkinter&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-gui-with-wxpython/&quot;&gt;wxPython&lt;/a&gt;, &lt;a href=&quot;https://www.riverbankcomputing.com/software/pyqt/intro&quot;&gt;PyQt&lt;/a&gt;, &lt;a href=&quot;https://wiki.qt.io/Qt_for_Python&quot;&gt;PySide&lt;/a&gt;, and a few others.&lt;/p&gt;
&lt;p&gt;In this video course, you&amp;rsquo;ll learn the basics of building GUI desktop applications with Python and &lt;strong&gt;PyQt&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create &lt;strong&gt;graphical user interfaces&lt;/strong&gt; with Python and PyQt&lt;/li&gt;
&lt;li&gt;Connect the &lt;strong&gt;user&amp;rsquo;s events&lt;/strong&gt; on the app&amp;rsquo;s GUI with the &lt;strong&gt;app&amp;rsquo;s logic&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Organize a PyQt app using a proper &lt;strong&gt;project layout&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Create a &lt;strong&gt;fully functional GUI application&lt;/strong&gt; with PyQt&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Creating Great README Files for Your Python Projects</title>
      <id>https://realpython.com/readme-python-project/</id>
      <link href="https://realpython.com/readme-python-project/"/>
      <updated>2024-06-24T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to create, organize, and format high-quality README files for your Python projects.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Most software projects benefit from having a piece of documentation that provides a quick start guide for setting up, using, and contributing to the project. This is especially true in open-source projects where you typically want to attract users and contributors. This type of document is commonly known as a &lt;strong&gt;&lt;code&gt;README&lt;/code&gt;&lt;/strong&gt; file, and you should add one to each Python project you create.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What a &lt;strong&gt;&lt;code&gt;README&lt;/code&gt;&lt;/strong&gt; file is&lt;/li&gt;
&lt;li&gt;How to &lt;strong&gt;organize&lt;/strong&gt; a &lt;code&gt;README&lt;/code&gt; file&lt;/li&gt;
&lt;li&gt;What &lt;strong&gt;document format&lt;/strong&gt; to use for &lt;code&gt;README&lt;/code&gt; files&lt;/li&gt;
&lt;li&gt;How to prepare a &lt;code&gt;README&lt;/code&gt; file for platforms like &lt;strong&gt;PyPI&lt;/strong&gt; and &lt;strong&gt;GitHub&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;What &lt;strong&gt;tools&lt;/strong&gt; and &lt;strong&gt;templates&lt;/strong&gt; to use to create &lt;code&gt;README&lt;/code&gt; files&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You won’t need special knowledge to read through this tutorial. However, to start creating your own &lt;code&gt;README&lt;/code&gt; files, you should familiarize yourself with markup languages, such as &lt;a href=&quot;https://www.markdownguide.org/&quot;&gt;Markdown&lt;/a&gt; and &lt;a href=&quot;https://docutils.sourceforge.io/rst.html&quot;&gt;reStructuredText&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Template:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/readme-python-project-template/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-readme-python-project-template&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free template&lt;/a&gt; you can use to create your own great README files.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;container border rounded text-wrap-pretty my-3&quot;&gt;

  &lt;p class=&quot;my-3&quot;&gt;&lt;mark class=&quot;marker-highlight&quot;&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “Creating Great README Files for Your Python Projects” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col-xs-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/readme-python-project/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;embed-responsive embed-responsive-16by9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 embed-responsive-item rounded&quot; style=&quot;object-fit: contain; background: #ffc873;&quot; alt=&quot;Creating Great README Files for Your Python Projects&quot; src=&quot;https://files.realpython.com/media/Creating-Good-README.md-Files-for-Your-Python-Projects_Watermarked.034ab572fa3e.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Creating-Good-README.md-Files-for-Your-Python-Projects_Watermarked.034ab572fa3e.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Creating-Good-README.md-Files-for-Your-Python-Projects_Watermarked.034ab572fa3e.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Creating-Good-README.md-Files-for-Your-Python-Projects_Watermarked.034ab572fa3e.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Creating-Good-README.md-Files-for-Your-Python-Projects_Watermarked.034ab572fa3e.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)&quot;&gt;


          &lt;div class=&quot;card-img-overlay d-flex align-items-center&quot;&gt;
            &lt;div class=&quot;mx-auto&quot;&gt;
              &lt;span class=&quot;text-light&quot; style=&quot;opacity: 0.90;&quot;&gt;&lt;span class=&quot;icon baseline scale2x&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;div class=&quot;mt-3 d-md-none&quot;&gt;&lt;/div&gt; 
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Interactive Quiz&lt;/strong&gt;&lt;/p&gt;
      &lt;a href=&quot;/quizzes/readme-python-project/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Creating Great README Files for Your Python Projects&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Take this quiz to test your understanding of how a great README file can make your Python project stand out and how to create your own README files.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;what-is-a-readme-file&quot;&gt;What Is a &lt;code&gt;README&lt;/code&gt; File?&lt;a class=&quot;headerlink&quot; href=&quot;#what-is-a-readme-file&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A &lt;a href=&quot;https://en.wikipedia.org/wiki/README&quot;&gt;&lt;code&gt;README&lt;/code&gt;&lt;/a&gt; file is a document that you typically add to the root directory of a software project. It’s often a short guide that provides essential information about the project. The &lt;code&gt;README&lt;/code&gt; file aims to help users and developers understand the project’s purpose, how to use it, and how to contribute to it. It’s also a way to communicate with potential users, collaborators, and contributors.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;README&lt;/code&gt; files are typically plain text files that are the most visible piece of documentation and often the landing page for many software projects, including &lt;a href=&quot;https://en.wikipedia.org/wiki/Open-source_software&quot;&gt;open-source&lt;/a&gt; projects.&lt;/p&gt;
&lt;p&gt;In most cases, the file name is written in uppercase letters to draw the user’s attention and ensure it’s the first thing they read.&lt;/p&gt;
&lt;p&gt;A &lt;code&gt;README&lt;/code&gt; should contain only the necessary information for users, collaborators, and developers to get started using and contributing to your project. For more extended documentation, &lt;a href=&quot;https://en.wikipedia.org/wiki/Wiki&quot;&gt;wikis&lt;/a&gt; or dedicated &lt;a href=&quot;https://realpython.com/python-project-documentation-with-mkdocs/&quot;&gt;documentation pages&lt;/a&gt; are more appropriate and recommended.&lt;/p&gt;
&lt;h2 id=&quot;why-do-you-need-a-readme-in-your-python-projects&quot;&gt;Why Do You Need a &lt;code&gt;README&lt;/code&gt; in Your Python Projects?&lt;a class=&quot;headerlink&quot; href=&quot;#why-do-you-need-a-readme-in-your-python-projects&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;README&lt;/code&gt; files have a long history in &lt;a href=&quot;https://en.wikipedia.org/wiki/Free_software&quot;&gt;free&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Open-source_software&quot;&gt;open-source&lt;/a&gt; software. The &lt;a href=&quot;https://en.wikipedia.org/wiki/GNU_Coding_Standards&quot;&gt;GNU Coding Standards&lt;/a&gt; encourage you to include a &lt;code&gt;README&lt;/code&gt; to provide a &lt;em&gt;general overview&lt;/em&gt; of the package’s contents. However, this type of file isn’t limited to free and open-source projects. You can add a &lt;code&gt;README&lt;/code&gt; to any project you like.&lt;/p&gt;
&lt;p&gt;Why should you spend time writing a &lt;code&gt;README&lt;/code&gt; file for your Python projects? Here are a few general reasons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;README&lt;/code&gt; files are kind of a &lt;strong&gt;standard&lt;/strong&gt; in the software industry.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;README&lt;/code&gt; file is frequently the first thing your users will &lt;strong&gt;notice or search for&lt;/strong&gt; when they find your project.&lt;/li&gt;
&lt;li&gt;A good &lt;code&gt;README&lt;/code&gt; file helps your project &lt;strong&gt;stand out&lt;/strong&gt; from other projects.&lt;/li&gt;
&lt;li&gt;A high-quality &lt;code&gt;README&lt;/code&gt; file differentiates a &lt;strong&gt;good project&lt;/strong&gt; from a bad one.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;README&lt;/code&gt; files are often displayed as the &lt;strong&gt;project’s landing page&lt;/strong&gt; on software development platforms like &lt;a href=&quot;https://realpython.com/python-git-github-intro/&quot;&gt;GitHub&lt;/a&gt; and &lt;a href=&quot;https://about.gitlab.com/&quot;&gt;GitLab&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;From a more specialized point of view, a good &lt;code&gt;README&lt;/code&gt; file can help you:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Introduce the project&lt;/strong&gt; by providing an overview of what the project is about, its purpose, and its main features.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Provide guidance&lt;/strong&gt; by offering instructions on how to set up the project for use and contributions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Attract contributors&lt;/strong&gt; by providing clear guidelines on how to contribute to the project.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Provide documentation&lt;/strong&gt; by working as the primary source of documentation for the project.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Supply support and contact Information&lt;/strong&gt; by providing details on how to get help or contact the project maintainers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Include license information&lt;/strong&gt; by specifying the terms for using and contributing to the project.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These are just a few of the benefits of adding a &lt;code&gt;README&lt;/code&gt; file to your Python projects. So, what do you think? Is it worth it to add them?&lt;/p&gt;
&lt;h2 id=&quot;what-is-the-usual-structure-of-a-great-readme-file&quot;&gt;What Is the Usual Structure of a Great &lt;code&gt;README&lt;/code&gt; File?&lt;a class=&quot;headerlink&quot; href=&quot;#what-is-the-usual-structure-of-a-great-readme-file&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;First, you should know that there isn’t &lt;em&gt;one right way&lt;/em&gt; to structure a high-quality &lt;code&gt;README&lt;/code&gt; file. In practice, the content and sections you include in this file will depend on your specific project. However, you’ll find that most &lt;code&gt;README&lt;/code&gt; files have common sections, such as the project’s name, the instructions on how to set up and use the project, guidelines for contributing to the project, and similar topics.&lt;/p&gt;
&lt;p&gt;In the following sections, you’ll learn about the most commonly used sections in &lt;code&gt;README&lt;/code&gt; files and their content.&lt;/p&gt;
&lt;h3 id=&quot;common-sections-in-great-readme-files&quot;&gt;Common Sections in Great &lt;code&gt;README&lt;/code&gt; Files&lt;a class=&quot;headerlink&quot; href=&quot;#common-sections-in-great-readme-files&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Before discussing how to organize a &lt;code&gt;README&lt;/code&gt; file in a well-structured document with pertinent sections, you’ll briefly consider the general content that most &lt;code&gt;README&lt;/code&gt; files contain. To approach this topic for a given Python project, you try to answer the following questions:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/readme-python-project/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/readme-python-project/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #209: Python&#x27;s Command-Line Utilities &amp; Music Information Retrieval Tools</title>
      <id>https://realpython.com/podcasts/rpp/209/</id>
      <link href="https://realpython.com/podcasts/rpp/209/"/>
      <updated>2024-06-21T12:00:00+00:00</updated>
      <summary>What are the built-in Python modules that can work as useful command-line tools? How can these tools add more functionality to Windows machines? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;What are the built-in Python modules that can work as useful command-line tools? How can these tools add more functionality to Windows machines? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Build a Guitar Synthesizer: Play Musical Tablature in Python</title>
      <id>https://realpython.com/python-guitar-synthesizer/</id>
      <link href="https://realpython.com/python-guitar-synthesizer/"/>
      <updated>2024-06-19T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll build a guitar synthesizer using the Karplus-Strong algorithm in Python. You&#x27;ll model vibrating strings, simulate strumming techniques, read musical notation and tablature, and apply audio effects. By the end, you&#x27;ll have created a digital guitar that can play any song.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Have you ever wanted to compose music without expensive gear or a professional studio? Maybe you’ve tried to play a musical instrument before but found the manual dexterity required too daunting or time-consuming. If so, you might be interested in harnessing the power of Python to create a guitar synthesizer. By following a few relatively simple steps, you’ll be able to turn your computer into a virtual guitar that can play any song.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Implement the &lt;strong&gt;Karplus-Strong&lt;/strong&gt; plucked string synthesis algorithm&lt;/li&gt;
&lt;li&gt;Mimic different types of &lt;strong&gt;string instruments&lt;/strong&gt; and their &lt;strong&gt;tunings&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Combine multiple vibrating strings into &lt;strong&gt;polyphonic chords&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Simulate realistic &lt;strong&gt;guitar picking&lt;/strong&gt; and &lt;strong&gt;strumming&lt;/strong&gt; finger techniques&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;impulse responses&lt;/strong&gt; of real instruments to replicate their unique timbre&lt;/li&gt;
&lt;li&gt;Read &lt;strong&gt;musical notes&lt;/strong&gt; from &lt;strong&gt;scientific pitch notation&lt;/strong&gt; and &lt;strong&gt;guitar tablature&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;At any point, you’re welcome to download the complete source code of the guitar synthesizer, as well as the sample tablature and other resources that you’ll use throughout this tutorial. They might prove useful in case you want to explore the code in more detail or get a head start. To download the bonus materials now, visit the following link:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-guitar-synthesizer-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-guitar-synthesizer-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that you’ll use to build a guitar synthesizer in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;container border rounded text-wrap-pretty my-3&quot;&gt;

  &lt;p class=&quot;my-3&quot;&gt;&lt;mark class=&quot;marker-highlight&quot;&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “Build a Guitar Synthesizer” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col-xs-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/python-guitar-synthesizer/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;embed-responsive embed-responsive-16by9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 embed-responsive-item rounded&quot; style=&quot;object-fit: contain; background: #ffc774;&quot; alt=&quot;Build a Guitar Synthesizer: Play Musical Tablature in Python&quot; src=&quot;https://files.realpython.com/media/Build-a-Guitar-Synthesizer-with-Python_Watermarked.a80fc2b14da2.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Build-a-Guitar-Synthesizer-with-Python_Watermarked.a80fc2b14da2.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Build-a-Guitar-Synthesizer-with-Python_Watermarked.a80fc2b14da2.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Build-a-Guitar-Synthesizer-with-Python_Watermarked.a80fc2b14da2.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Build-a-Guitar-Synthesizer-with-Python_Watermarked.a80fc2b14da2.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)&quot;&gt;


          &lt;div class=&quot;card-img-overlay d-flex align-items-center&quot;&gt;
            &lt;div class=&quot;mx-auto&quot;&gt;
              &lt;span class=&quot;text-light&quot; style=&quot;opacity: 0.90;&quot;&gt;&lt;span class=&quot;icon baseline scale2x&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;div class=&quot;mt-3 d-md-none&quot;&gt;&lt;/div&gt; 
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Interactive Quiz&lt;/strong&gt;&lt;/p&gt;
      &lt;a href=&quot;/quizzes/python-guitar-synthesizer/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Build a Guitar Synthesizer&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of what it takes to build a guitar synthesizer in Python. By working through this quiz, you&#x27;ll revisit a few key concepts from music theory and sound synthesis.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;demo-guitar-synthesizer-in-python&quot;&gt;Demo: Guitar Synthesizer in Python&lt;a class=&quot;headerlink&quot; href=&quot;#demo-guitar-synthesizer-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In this step-by-step guide, you’ll build a &lt;a href=&quot;https://en.wikipedia.org/wiki/Plucked_string_instrument&quot;&gt;plucked string instrument&lt;/a&gt; synthesizer based on the &lt;a href=&quot;https://en.wikipedia.org/wiki/Karplus%E2%80%93Strong_string_synthesis&quot;&gt;Karplus-Strong&lt;/a&gt; algorithm in Python. Along the way, you’ll create an ensemble of virtual instruments, including an &lt;a href=&quot;https://en.wikipedia.org/wiki/Acoustic_guitar&quot;&gt;acoustic&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Bass_guitar&quot;&gt;bass&lt;/a&gt;, and &lt;a href=&quot;https://en.wikipedia.org/wiki/Electric_guitar&quot;&gt;electric guitar&lt;/a&gt;, as well as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Banjo&quot;&gt;banjo&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Ukulele&quot;&gt;ukulele&lt;/a&gt;. Then, you’ll implement a custom &lt;strong&gt;guitar tab&lt;/strong&gt; reader so that you can play your favorite songs.&lt;/p&gt;
&lt;p&gt;By the end of this tutorial, you’ll be able to synthesize music from &lt;a href=&quot;https://en.wikipedia.org/wiki/Tablature#Guitar_tablature&quot;&gt;guitar tablature&lt;/a&gt;, or guitar tabs for short, which is a simplified form of musical notation that allows you to play music without having to learn how to read standard sheet music. Finally, you’ll store the result in an &lt;a href=&quot;https://en.wikipedia.org/wiki/MP3&quot;&gt;MP3&lt;/a&gt; file for playback.&lt;/p&gt;
&lt;p&gt;Below is a short demonstration of the synthesizer, re-creating the iconic soundtracks of classic video games like &lt;a href=&quot;https://en.wikipedia.org/wiki/Doom_(1993_video_game)&quot;&gt;Doom&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Diablo_(video_game)&quot;&gt;Diablo&lt;/a&gt;. Click the play button to listen to the sample output:&lt;/p&gt;
&lt;figure&gt;
  &lt;div class=&quot;embed-responsive embed-responsive-16by9 rounded mb-3 border&quot;&gt;
    &lt;iframe loading=&quot;lazy&quot; class=&quot;embed-responsive-item&quot; src=&quot;https://player.vimeo.com/video/955609045&quot; frameborder=&quot;0&quot; allow=&quot;fullscreen&quot; allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/div&gt;
  &lt;figcaption class=&quot;figure-caption text-center&quot;&gt;E1M1 - At Doom&#x27;s Gate (Bobby Prince), Tristram (Matt Uelmen)&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Once you find a guitar tab that you like, you can plug it into your Python guitar synthesizer and bring the music to life. For example, the &lt;a href=&quot;https://www.songsterr.com/&quot;&gt;Songsterr&lt;/a&gt; website is a fantastic resource with a wide range of songs you can choose from.&lt;/p&gt;
&lt;h2 id=&quot;project-overview&quot;&gt;Project Overview&lt;a class=&quot;headerlink&quot; href=&quot;#project-overview&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;For your convenience, the project that you’re about to build, along with its third-party dependencies, will be managed by Poetry. The project will contain two Python packages with distinctly different areas of responsibility:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;digitar&lt;/code&gt;:&lt;/strong&gt; For the synthesis of the digital guitar sound&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;tablature&lt;/code&gt;:&lt;/strong&gt; For reading and interpreting guitar tablature from a file&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You’ll also design and implement a custom &lt;strong&gt;data format&lt;/strong&gt; to store guitar tabs on disk or in memory. This will allow you to play music based on a fairly standard tablature notation, which you’ll find in various places on the Internet. Your project will also provide a &lt;strong&gt;Python script&lt;/strong&gt; to tie everything together, which will let you interpret the tabs with a single command right from your terminal.&lt;/p&gt;
&lt;p&gt;Now, you can dive into the details of what you’ll need to set up your development environment and start coding.&lt;/p&gt;
&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;a class=&quot;headerlink&quot; href=&quot;#prerequisites&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Although you don’t need to be a musician to follow along with this tutorial, a basic understanding of &lt;a href=&quot;https://en.wikipedia.org/wiki/Music_theory&quot;&gt;musical concepts&lt;/a&gt; such as &lt;a href=&quot;https://en.wikipedia.org/wiki/Musical_note&quot;&gt;notes&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Semitone&quot;&gt;semitones&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Octave&quot;&gt;octaves&lt;/a&gt;, and &lt;a href=&quot;https://en.wikipedia.org/wiki/Chord_(music)&quot;&gt;chords&lt;/a&gt; will help you grasp the information more quickly. It’d also be nice if you had a rough idea of how computers represent and process &lt;a href=&quot;https://en.wikipedia.org/wiki/Digital_audio&quot;&gt;digital audio&lt;/a&gt; in terms of sampling rate, bit depth, and file formats like &lt;a href=&quot;https://realpython.com/python-wav-files/&quot;&gt;WAV&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;But don’t worry if you’re new to these ideas! You’ll be guided through each step in small increments with clear explanations and examples. So, even if you’ve never done any music synthesis before, you’ll have a working &lt;strong&gt;digital guitar&lt;/strong&gt; or &lt;strong&gt;digitar&lt;/strong&gt; by the end of this tutorial.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; You can &lt;a href=&quot;https://www.youtube.com/watch?v=rgaTLrZGlk0&quot;&gt;learn music theory in half an hour&lt;/a&gt; by watching an excellent and free video by Andrew Huang.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The project that you’ll build was tested against &lt;a href=&quot;https://realpython.com/python312-new-features/&quot;&gt;Python 3.12&lt;/a&gt; but should work fine in earlier Python versions, too, down to &lt;a href=&quot;https://realpython.com/python310-new-features/&quot;&gt;Python 3.10&lt;/a&gt;. In case you need a quick refresher, here’s a list of helpful resources covering the most important language features that you’ll take advantage of in your digital guitar journey:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-walrus-operator/&quot;&gt;Assignment expressions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-data-classes/&quot;&gt;Data classes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-enum/&quot;&gt;Enumerations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/duck-typing-python/#understanding-type-hints-and-static-duck-typing&quot;&gt;Protocols (static duck typing)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python310-new-features/#structural-pattern-matching&quot;&gt;Structural pattern matching&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-type-checking/&quot;&gt;Type hints&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Other than that, you’ll use the following third-party Python packages in your project:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/numpy-tutorial/&quot;&gt;NumPy&lt;/a&gt; to simplify and speed up the underlying sound synthesis&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://pypi.org/project/pedalboard/&quot;&gt;Pedalboard&lt;/a&gt; to apply special effects akin to electric guitar amplifiers &lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-pydantic/&quot;&gt;Pydantic&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-yaml/&quot;&gt;PyYAML&lt;/a&gt; to parse musical tablature representing finger movements on a guitar neck&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-guitar-synthesizer/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-guitar-synthesizer/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Rounding Numbers in Python</title>
      <id>https://realpython.com/courses/rounding-numbers-python/</id>
      <link href="https://realpython.com/courses/rounding-numbers-python/"/>
      <updated>2024-06-18T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn about the mistakes you might make when rounding numbers and how to best manage or avoid them. It&#x27;s a great place to start for the early to intermediate Python developer who&#x27;s interested in using Python for finance, data science, or scientific computing.</summary>
      <content type="html">
        &lt;p&gt;With many businesses &lt;a href=&quot;https://stackoverflow.blog/2017/09/14/python-growing-quickly/&quot;&gt;turning to Python&amp;rsquo;s powerful data science ecosystem&lt;/a&gt; to analyze their data, understanding how to avoid introducing bias into datasets is absolutely vital. If you&amp;rsquo;ve studied some statistics, then you&amp;rsquo;re probably familiar with terms like reporting bias, selection bias, and sampling bias. There&amp;rsquo;s another type of bias that plays an important role when you&amp;rsquo;re dealing with numeric data: rounding bias. &lt;/p&gt;
&lt;p&gt;Understanding how rounding works in Python can help you avoid biasing your dataset. This is an important skill. After all, drawing conclusions from biased data can lead to costly mistakes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Why the way you round numbers is important&lt;/li&gt;
&lt;li&gt;How to round a number according to &lt;strong&gt;various rounding strategies&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to &lt;strong&gt;implement&lt;/strong&gt; each strategy in pure Python&lt;/li&gt;
&lt;li&gt;How &lt;strong&gt;rounding affects data&lt;/strong&gt; and which rounding strategy &lt;strong&gt;minimizes this effect&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to round numbers in &lt;strong&gt;NumPy arrays&lt;/strong&gt; and &lt;strong&gt;pandas DataFrames&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;When to apply different rounding strategies&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Ruff: A Modern Python Linter for Error-Free and Maintainable Code</title>
      <id>https://realpython.com/ruff-python/</id>
      <link href="https://realpython.com/ruff-python/"/>
      <updated>2024-06-17T14:00:00+00:00</updated>
      <summary>Ruff is an extremely fast, modern linter with a simple interface, making it straightforward to use. It also aims to be a drop-in replacement for other linting and formatting tools, like Pylint, isort, and Black. It&#x27;s no surprise it&#x27;s quickly becoming one of the most popular Python linters.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Linting is essential to writing &lt;strong&gt;clean and readable code&lt;/strong&gt; that you can share with others. A linter, like Ruff, is a tool that analyzes your code and looks for errors, stylistic issues, and suspicious constructs. Linting allows you to address issues and &lt;a href=&quot;https://realpython.com/python-code-quality/&quot;&gt;improve your code quality&lt;/a&gt; before you &lt;a href=&quot;https://realpython.com/python-git-github-intro/#committing-changes&quot;&gt;commit&lt;/a&gt; your code and share it with others. &lt;/p&gt;
&lt;p&gt;Ruff is a modern linter that’s extremely fast and has a simple interface, making it straightforward to use. It also aims to be a drop-in replacement for many other linting and formatting tools, such as &lt;a href=&quot;https://github.com/PyCQA/flake8&quot;&gt;Flake8&lt;/a&gt;, &lt;a href=&quot;https://github.com/PyCQA/isort&quot;&gt;isort&lt;/a&gt;, and &lt;a href=&quot;https://github.com/psf/black&quot;&gt;Black&lt;/a&gt;. It’s quickly becoming one of the most popular Python linters.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Install &lt;strong&gt;Ruff&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Check your Python code&lt;/strong&gt; for errors&lt;/li&gt;
&lt;li&gt;Automatically &lt;strong&gt;fix your linting errors&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use Ruff to &lt;strong&gt;format your code&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Add optional configurations&lt;/strong&gt; to supercharge your linting&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most from this tutorial, you should be familiar with &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;virtual environments&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;installing third-party modules&lt;/a&gt;, and be comfortable with using the &lt;a href=&quot;https://realpython.com/terminal-commands/&quot;&gt;terminal&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Ruff cheat sheet:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/ruff-python-pdf/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-ruff-python-pdf&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to get access to a free Ruff cheat sheet&lt;/a&gt; that summarizes the main Ruff commands you’ll use in this tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;container border rounded text-wrap-pretty my-3&quot;&gt;

  &lt;p class=&quot;my-3&quot;&gt;&lt;mark class=&quot;marker-highlight&quot;&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “Ruff: A Modern Python Linter” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col-xs-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/ruff-python/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;embed-responsive embed-responsive-16by9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 embed-responsive-item rounded&quot; style=&quot;object-fit: contain; background: #ff7e74;&quot; alt=&quot;Ruff: A Modern Linter for Error-Free and Maintainable Code&quot; src=&quot;https://files.realpython.com/media/Showcase-Ruff-Linter_Watermarked.71e600eb11de.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Showcase-Ruff-Linter_Watermarked.71e600eb11de.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Showcase-Ruff-Linter_Watermarked.71e600eb11de.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Showcase-Ruff-Linter_Watermarked.71e600eb11de.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Showcase-Ruff-Linter_Watermarked.71e600eb11de.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)&quot;&gt;


          &lt;div class=&quot;card-img-overlay d-flex align-items-center&quot;&gt;
            &lt;div class=&quot;mx-auto&quot;&gt;
              &lt;span class=&quot;text-light&quot; style=&quot;opacity: 0.90;&quot;&gt;&lt;span class=&quot;icon baseline scale2x&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;div class=&quot;mt-3 d-md-none&quot;&gt;&lt;/div&gt; 
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Interactive Quiz&lt;/strong&gt;&lt;/p&gt;
      &lt;a href=&quot;/quizzes/ruff-python/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Ruff: A Modern Python Linter&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of Ruff, a modern linter for Python. By working through this quiz, you&#x27;ll revisit why you&#x27;d want to use Ruff to check your Python code and how it automatically fixes errors, formats your code, and provides optional configurations to enhance your linting.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;installing-ruff&quot;&gt;Installing Ruff&lt;a class=&quot;headerlink&quot; href=&quot;#installing-ruff&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Now that you know why linting your code is important and how Ruff is a powerful tool for the job, it’s time to install it. Thankfully, Ruff works out of the box, so no complicated installation instructions or configurations are needed to start using it. &lt;/p&gt;
&lt;p&gt;Assuming your project is already set up with a virtual environment, you can install Ruff in the following ways:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Shell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-m&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;pip&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;ruff
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In addition to &lt;code&gt;pip&lt;/code&gt;, you can also install Ruff with &lt;a href=&quot;https://brew.sh/&quot;&gt;Homebrew&lt;/a&gt; if you’re on macOS or Linux:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Shell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;brew&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;ruff
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.conda.io/en/latest/&quot;&gt;Conda&lt;/a&gt; users can install Ruff using &lt;code&gt;conda-forge&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Shell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;conda&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-c&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;conda-forge&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;ruff
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you use Arch, Alpine, or openSUSE Linux, you can also use the official distribution repositories. You’ll find specific instructions on the &lt;a href=&quot;https://docs.astral.sh/ruff/installation/&quot;&gt;Ruff installation page&lt;/a&gt; of the official documentation.&lt;/p&gt;
&lt;p&gt;Additionally, if you’d like Ruff to be available for all your projects, you might want to install Ruff with &lt;a href=&quot;https://realpython.com/python-pipx/&quot;&gt;&lt;code&gt;pipx&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can check that Ruff installed correctly by using the &lt;code&gt;ruff version&lt;/code&gt; command:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Shell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;ruff&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;version
&lt;span class=&quot;go&quot;&gt;ruff 0.4.7&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.a4fe9af56412.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For the &lt;code&gt;ruff&lt;/code&gt; command to appear in your &lt;a href=&quot;https://en.wikipedia.org/wiki/PATH_(variable)&quot;&gt;&lt;code&gt;PATH&lt;/code&gt;&lt;/a&gt;, you may need to close and reopen your terminal application or start a new terminal session.&lt;/p&gt;
&lt;h2 id=&quot;linting-your-python-code&quot;&gt;Linting Your Python Code&lt;a class=&quot;headerlink&quot; href=&quot;#linting-your-python-code&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;While linting helps keep your code consistent and error-free, it doesn’t guarantee that your code will be &lt;em&gt;bug-free&lt;/em&gt;. Finding the bugs in your code is best handled with a &lt;a href=&quot;https://realpython.com/python-debug-idle/&quot;&gt;debugger&lt;/a&gt; and adequate &lt;a href=&quot;https://realpython.com/pytest-python-testing/&quot;&gt;testing&lt;/a&gt;, which won’t be covered in this tutorial. Coming up in the next sections, you’ll learn how to use Ruff to check for errors and speed up your workflow.&lt;/p&gt;
&lt;h3 id=&quot;checking-for-errors&quot;&gt;Checking for Errors&lt;a class=&quot;headerlink&quot; href=&quot;#checking-for-errors&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The code below is a simple script called &lt;code&gt;one_ring.py&lt;/code&gt;. When you run it, it gets a &lt;a href=&quot;https://realpython.com/python-random/&quot;&gt;random&lt;/a&gt; &lt;strong&gt;Lord of the Rings&lt;/strong&gt; character name from a &lt;a href=&quot;https://realpython.com/python-tuple/&quot;&gt;&lt;code&gt;tuple&lt;/code&gt;&lt;/a&gt; and lets you know if that character bore the burden of the &lt;strong&gt;One Ring&lt;/strong&gt;. This code has no real practical use and is just a bit of fun. Regardless of the size of your code base, the steps are going to be the same: &lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/ruff-python/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/ruff-python/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #208: Detecting Outliers in Your Data With Python</title>
      <id>https://realpython.com/podcasts/rpp/208/</id>
      <link href="https://realpython.com/podcasts/rpp/208/"/>
      <updated>2024-06-14T12:00:00+00:00</updated>
      <summary>How do you find the most interesting or suspicious points within your data? What libraries and techniques can you use to detect these anomalies with Python? This week on the show, we speak with author Brett Kennedy about his book &quot;Outlier Detection in Python.&quot;</summary>
      <content type="html">
        &lt;p&gt;How do you find the most interesting or suspicious points within your data? What libraries and techniques can you use to detect these anomalies with Python? This week on the show, we speak with author Brett Kennedy about his book &quot;Outlier Detection in Python.&quot;&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Listing All Files in a Directory With Python</title>
      <id>https://realpython.com/courses/listing-all-files-directory/</id>
      <link href="https://realpython.com/courses/listing-all-files-directory/"/>
      <updated>2024-06-11T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll be examining a couple of methods to get a list of files and folders in a directory with Python. You&#x27;ll also use both methods to recursively list directory contents. Finally, you&#x27;ll examine a situation that pits one method against the other.</summary>
      <content type="html">
        &lt;p&gt;Getting a &lt;a href=&quot;https://realpython.com/python-lists-tuples/&quot;&gt;list&lt;/a&gt; of all the &lt;a href=&quot;https://en.wikipedia.org/wiki/Computer_file&quot;&gt;files&lt;/a&gt; and folders in a &lt;a href=&quot;https://en.wikipedia.org/wiki/Directory_(computing)&quot;&gt;directory&lt;/a&gt; is a natural first step for many &lt;strong&gt;file-related operations&lt;/strong&gt; in Python. When looking into it, though, you may be surprised to find various ways to go about it.&lt;/p&gt;
&lt;p&gt;When you&amp;rsquo;re faced with many ways of doing something, it can be a good indication that there&amp;rsquo;s no one-size-fits-all solution to your problems. Most likely, every solution will have its own advantages and trade-offs. This is the case when it comes to getting a list of the contents of a directory in Python.&lt;/p&gt;
&lt;p&gt;In this video course, you&amp;rsquo;ll be focusing on the most general-purpose techniques in the &lt;a href=&quot;https://realpython.com/python-pathlib/&quot;&gt;&lt;code&gt;pathlib&lt;/code&gt; module&lt;/a&gt; to list items in a directory, but you&amp;rsquo;ll also learn a bit about some alternative tools.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #207: Decomposing Software Problems &amp; Avoiding the Trap of Clever Code</title>
      <id>https://realpython.com/podcasts/rpp/207/</id>
      <link href="https://realpython.com/podcasts/rpp/207/"/>
      <updated>2024-06-07T12:00:00+00:00</updated>
      <summary>How do you effectively break a software problem into individual steps? What are signs you&#x27;re writing overly clever code? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;How do you effectively break a software problem into individual steps? What are signs you&#x27;re writing overly clever code? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Interfaces: Object-Oriented Design Principles</title>
      <id>https://realpython.com/courses/interfaces-object-oriented-design-principles/</id>
      <link href="https://realpython.com/courses/interfaces-object-oriented-design-principles/"/>
      <updated>2024-06-04T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll explore how to use a Python interface. You&#x27;ll come to understand why interfaces are so useful and learn how to implement formal and informal interfaces in Python. You&#x27;ll also examine the differences between Python interfaces and those in other programming languages.</summary>
      <content type="html">
        &lt;p&gt;Interfaces play an important role in software engineering. As an application grows, updates and changes to the code base become more difficult to manage. More often than not, you wind up having classes that look very similar but are unrelated, which can lead to some confusion. In this video course, you&amp;rsquo;ll see how you can use a &lt;strong&gt;Python interface&lt;/strong&gt; to help determine what class you should use to tackle the current problem.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll be able to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Understand&lt;/strong&gt; how interfaces work and the caveats of Python interface creation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Comprehend&lt;/strong&gt; how useful interfaces are in a dynamic language like Python&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Implement&lt;/strong&gt; an informal Python interface&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use&lt;/strong&gt; &lt;code&gt;abc.ABCMeta&lt;/code&gt; and &lt;code&gt;@abc.abstractmethod&lt;/code&gt; to implement a formal Python interface&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #206: Building Python Unit Tests &amp; Exploring a Data Visualization Gallery</title>
      <id>https://realpython.com/podcasts/rpp/206/</id>
      <link href="https://realpython.com/podcasts/rpp/206/"/>
      <updated>2024-05-31T12:00:00+00:00</updated>
      <summary>How do you start adding unit tests to your Python code? Can the built-in unittest framework cover most or all of your needs? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;How do you start adding unit tests to your Python code? Can the built-in unittest framework cover most or all of your needs? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Efficient Iterations With Python Iterators and Iterables</title>
      <id>https://realpython.com/courses/efficient-iterations-iterators-iterables/</id>
      <link href="https://realpython.com/courses/efficient-iterations-iterators-iterables/"/>
      <updated>2024-05-28T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn what iterators and iterables are in Python. You&#x27;ll learn how they differ and when to use them in your code. You&#x27;ll also learn how to create your own iterators and iterables to make data processing more efficient.</summary>
      <content type="html">
        &lt;p&gt;Python&amp;rsquo;s &lt;strong&gt;iterators&lt;/strong&gt; and &lt;strong&gt;iterables&lt;/strong&gt; are two different but related tools that come in handy when you need to iterate over a data stream or container. Iterators power and control the iteration process, while iterables typically hold data that you want to iterate over one value at a time.&lt;/p&gt;
&lt;p&gt;Iterators and iterables are fundamental components of Python programming, and you&amp;rsquo;ll have to deal with them in almost all your programs. Learning how they work and how to create them is key for you as a Python developer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create &lt;strong&gt;iterators&lt;/strong&gt; using the &lt;strong&gt;iterator protocol&lt;/strong&gt; in Python&lt;/li&gt;
&lt;li&gt;Understand the &lt;strong&gt;differences&lt;/strong&gt; between iterators and iterables&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Work&lt;/strong&gt; with iterators and iterables in your Python code&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;generator functions&lt;/strong&gt; and the &lt;strong&gt;&lt;code&gt;yield&lt;/code&gt; statement&lt;/strong&gt; to create &lt;strong&gt;generator iterators&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Build your own &lt;strong&gt;iterables&lt;/strong&gt; using different techniques, such as the &lt;strong&gt;iterable protocol&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Building a Python GUI Application With Tkinter</title>
      <id>https://realpython.com/courses/building-gui-application-tkinter/</id>
      <link href="https://realpython.com/courses/building-gui-application-tkinter/"/>
      <updated>2024-05-21T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn the basics of GUI programming with Tkinter, the de facto Python GUI framework. Master GUI programming concepts such as widgets, geometry managers, and event handlers. Then, put it all together by building two applications: a temperature converter and a text editor.</summary>
      <content type="html">
        &lt;p&gt;Python has a lot of &lt;a href=&quot;http://wiki.python.org/moin/GuiProgramming&quot;&gt;GUI frameworks&lt;/a&gt;, but &lt;a href=&quot;https://wiki.python.org/moin/TkInter&quot;&gt;Tkinter&lt;/a&gt; is the only framework that&amp;rsquo;s built into the Python standard library. Tkinter has several strengths. It&amp;rsquo;s &lt;strong&gt;cross-platform&lt;/strong&gt;, so the same code works on Windows, macOS, and Linux. Visual elements are rendered using native operating system elements, so applications built with Tkinter look like they belong on the platform where they&amp;rsquo;re run.&lt;/p&gt;
&lt;p&gt;Although Tkinter is considered the de facto Python GUI framework, it&amp;rsquo;s not without criticism. One notable criticism is that GUIs built with Tkinter look outdated. If you want a shiny, modern interface, then Tkinter may not be what you&amp;rsquo;re looking for.&lt;/p&gt;
&lt;p&gt;However, Tkinter is lightweight and relatively painless to use compared to other frameworks. This makes it a compelling choice for building GUI applications in Python, especially for applications where a modern sheen is unnecessary, and the top priority is to quickly build something that&amp;rsquo;s functional and cross-platform.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Get started with Tkinter with a &lt;strong&gt;Hello, World&lt;/strong&gt; application&lt;/li&gt;
&lt;li&gt;Work with &lt;strong&gt;widgets&lt;/strong&gt;, such as buttons and text boxes&lt;/li&gt;
&lt;li&gt;Control your application layout with &lt;strong&gt;geometry managers&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Make your applications &lt;strong&gt;interactive&lt;/strong&gt; by associating button clicks with Python functions&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #205: Considering Accessibility &amp; Assistive Tech as a Python Developer</title>
      <id>https://realpython.com/podcasts/rpp/205/</id>
      <link href="https://realpython.com/podcasts/rpp/205/"/>
      <updated>2024-05-17T12:00:00+00:00</updated>
      <summary>What&#x27;s it like to learn Python as a visually impaired or blind developer? How can you improve the accessibility of your Python web applications and learn current guidelines? This week on the show, Real Python community member Audrey van Breederode discusses her programming journey, web accessibility, and assistive technology.</summary>
      <content type="html">
        &lt;p&gt;What&#x27;s it like to learn Python as a visually impaired or blind developer? How can you improve the accessibility of your Python web applications and learn current guidelines? This week on the show, Real Python community member Audrey van Breederode discusses her programming journey, web accessibility, and assistive technology.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>HTML and CSS Foundations for Python Developers</title>
      <id>https://realpython.com/courses/html-css-foundations/</id>
      <link href="https://realpython.com/courses/html-css-foundations/"/>
      <updated>2024-05-14T14:00:00+00:00</updated>
      <summary>There&#x27;s no way around HTML and CSS when you want to build web apps. Even if you&#x27;re not aiming to become a web developer, knowing the basics of HTML and CSS will help you understand the Web better. In this video course, you&#x27;ll get an introduction to HTML and CSS for Python programmers.</summary>
      <content type="html">
        &lt;p&gt;When you want to build websites as a Python programmer, there&amp;rsquo;s no way around HTML and CSS.
Almost every website on the Internet is built with &lt;strong&gt;HTML markup&lt;/strong&gt; to structure the page.
To make a website look nice, you can style HTML with &lt;strong&gt;CSS&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re interested in web development with Python, then knowing HTML and CSS will help you understand web frameworks like &lt;strong&gt;Django&lt;/strong&gt; and &lt;strong&gt;Flask&lt;/strong&gt; better.
But even if you&amp;rsquo;re just getting started with Python, HTML and CSS can enable you to create small websites to impress your friends.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Structure a basic &lt;strong&gt;HTML&lt;/strong&gt; file&lt;/li&gt;
&lt;li&gt;View and inspect HTML in your &lt;strong&gt;browser&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Insert &lt;strong&gt;images&lt;/strong&gt; and page &lt;strong&gt;links&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Style a website with &lt;strong&gt;CSS&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Format HTML with &lt;strong&gt;accessibility&lt;/strong&gt; in mind&lt;/li&gt;
&lt;li&gt;Use Python to &lt;strong&gt;write and parse&lt;/strong&gt; HTML code&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #204: Querying OpenStreetMaps via API &amp; Lazy Evaluation in Python</title>
      <id>https://realpython.com/podcasts/rpp/204/</id>
      <link href="https://realpython.com/podcasts/rpp/204/"/>
      <updated>2024-05-10T12:00:00+00:00</updated>
      <summary>Would you like to get more practice working with APIs in Python? How about exploring the globe using the data from OpenStreetMap? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;Would you like to get more practice working with APIs in Python? How about exploring the globe using the data from OpenStreetMap? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  

</feed>
