<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tu codigo cotidiano</title>
    <description>The latest articles on DEV Community by Tu codigo cotidiano (@tu_codigocotidiano_f173d).</description>
    <link>https://dev.to/tu_codigocotidiano_f173d</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3375057%2Ffa90e872-13fe-4a57-b3d6-e75515a50879.png</url>
      <title>DEV Community: Tu codigo cotidiano</title>
      <link>https://dev.to/tu_codigocotidiano_f173d</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tu_codigocotidiano_f173d"/>
    <language>en</language>
    <item>
      <title>What Physically Happens When You Ask an AI a Question?</title>
      <dc:creator>Tu codigo cotidiano</dc:creator>
      <pubDate>Tue, 11 Aug 2026 22:18:14 +0000</pubDate>
      <link>https://dev.to/tu_codigocotidiano_f173d/what-physically-happens-when-you-ask-an-ai-a-question-5503</link>
      <guid>https://dev.to/tu_codigocotidiano_f173d/what-physically-happens-when-you-ask-an-ai-a-question-5503</guid>
      <description>&lt;p&gt;We often think about artificial intelligence as something purely digital.&lt;/p&gt;

&lt;p&gt;You type a question.&lt;/p&gt;

&lt;p&gt;Press Enter.&lt;/p&gt;

&lt;p&gt;A few seconds later, an answer appears.&lt;/p&gt;

&lt;p&gt;But physically, a surprising amount of infrastructure has been involved during those few seconds.&lt;/p&gt;

&lt;p&gt;Your question first travels through networking infrastructure toward a data center. There, the text is transformed into tokens that can be processed by an AI model.&lt;/p&gt;

&lt;p&gt;Specialized hardware—often GPUs or other accelerators—performs billions of mathematical operations to calculate what should come next.&lt;/p&gt;

&lt;p&gt;That computation requires electricity.&lt;/p&gt;

&lt;p&gt;Electricity produces heat.&lt;/p&gt;

&lt;p&gt;Heat requires cooling.&lt;/p&gt;

&lt;p&gt;And all of this happens while networking systems move information between your device, servers, memory, storage and computing accelerators.&lt;/p&gt;

&lt;p&gt;In other words, an AI response is not simply “generated by software.”&lt;/p&gt;

&lt;p&gt;It is the result of a physical chain involving:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Networks&lt;/li&gt;
&lt;li&gt;Data centers&lt;/li&gt;
&lt;li&gt;GPUs and accelerators&lt;/li&gt;
&lt;li&gt;Memory&lt;/li&gt;
&lt;li&gt;Electricity&lt;/li&gt;
&lt;li&gt;Cooling systems&lt;/li&gt;
&lt;li&gt;Large-scale distributed computing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I recently explored this idea in a new episode of &lt;strong&gt;TuCodigoCotidiano&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;🎧 &lt;strong&gt;¿Qué ocurre físicamente cuando le preguntas algo a una IA?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tucodigocotidiano.yarumaltech.com/escuchar-podcast/que-ocurre-fisicamente-cuando-le-preguntas-algo-a-una-ia/" rel="noopener noreferrer"&gt;https://tucodigocotidiano.yarumaltech.com/escuchar-podcast/que-ocurre-fisicamente-cuando-le-preguntas-algo-a-una-ia/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The episode is in Spanish and focuses on understanding the physical infrastructure behind something we now do every day: asking an AI a question.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhud5otruqn02kh58ug9u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhud5otruqn02kh58ug9u.png" alt=" " width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  ai #machinelearning #computerscience #technology
&lt;/h1&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>technology</category>
    </item>
    <item>
      <title>Build a Personal Expense Tracker in Python: From Fundamentals to a Real Terminal App</title>
      <dc:creator>Tu codigo cotidiano</dc:creator>
      <pubDate>Tue, 28 Jul 2026 12:06:08 +0000</pubDate>
      <link>https://dev.to/tu_codigocotidiano_f173d/build-a-personal-expense-tracker-in-python-from-fundamentals-to-a-real-terminal-app-375m</link>
      <guid>https://dev.to/tu_codigocotidiano_f173d/build-a-personal-expense-tracker-in-python-from-fundamentals-to-a-real-terminal-app-375m</guid>
      <description>&lt;p&gt;Learning Python syntax is one thing.&lt;/p&gt;

&lt;p&gt;Using variables, conditionals, loops, lists, dictionaries, and functions &lt;strong&gt;together to build an actual program&lt;/strong&gt; is where things start to become much more interesting.&lt;/p&gt;

&lt;p&gt;I published a new step-by-step project in &lt;strong&gt;TuCodigoCotidiano&lt;/strong&gt; where we build a personal expense tracker that runs entirely in the terminal.&lt;/p&gt;

&lt;p&gt;The guide is written in Spanish and is designed for people who already know the basic Python concepts but want to understand how those pieces fit together inside a real application.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we build
&lt;/h2&gt;

&lt;p&gt;The project starts small.&lt;/p&gt;

&lt;p&gt;A single expense becomes a dictionary.&lt;/p&gt;

&lt;p&gt;Multiple expenses become a list of dictionaries.&lt;/p&gt;

&lt;p&gt;Then we gradually add functions until the program can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Register income&lt;/li&gt;
&lt;li&gt;Register expenses&lt;/li&gt;
&lt;li&gt;Display transactions&lt;/li&gt;
&lt;li&gt;Calculate total income&lt;/li&gt;
&lt;li&gt;Calculate total expenses&lt;/li&gt;
&lt;li&gt;Calculate the current balance&lt;/li&gt;
&lt;li&gt;Group expenses by category&lt;/li&gt;
&lt;li&gt;Validate user input&lt;/li&gt;
&lt;li&gt;Run through an interactive terminal menu&lt;/li&gt;
&lt;li&gt;Save data to JSON&lt;/li&gt;
&lt;li&gt;Load previous data when the program starts again&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The final structure is intentionally simple:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;problem → data → functions → interaction → validation → persistence → application&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;No classes.&lt;/p&gt;

&lt;p&gt;No database.&lt;/p&gt;

&lt;p&gt;No external libraries.&lt;/p&gt;

&lt;p&gt;Just Python and the standard library.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I built the tutorial this way
&lt;/h2&gt;

&lt;p&gt;A common beginner experience is learning concepts independently:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;if&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;for&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;lists&lt;/p&gt;

&lt;p&gt;dictionaries&lt;/p&gt;

&lt;p&gt;functions&lt;/p&gt;

&lt;p&gt;But knowing those concepts does not automatically explain &lt;strong&gt;how to design a program&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So instead of starting with a large finished script, the project begins with a practical question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What would a program need to do to help you understand where your money is going?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;From there, every new piece of code solves one specific part of the problem.&lt;/p&gt;

&lt;p&gt;The goal is not only to finish an expense tracker.&lt;/p&gt;

&lt;p&gt;The goal is to understand how a real program grows from a simple idea.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read the complete project
&lt;/h2&gt;

&lt;p&gt;🐍 &lt;strong&gt;Construye un gestor de gastos personales en la terminal&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tucodigocotidiano.yarumaltech.com/leer_guias/construye-un-gestor-de-gastos-personales-en-la-terminal/#del-problema-cotidiano-al-programa" rel="noopener noreferrer"&gt;https://tucodigocotidiano.yarumaltech.com/leer_guias/construye-un-gestor-de-gastos-personales-en-la-terminal/#del-problema-cotidiano-al-programa&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The complete tutorial is in Spanish and includes the code, explanations, visual diagrams, validation, JSON persistence, testing ideas, common mistakes, and challenges to extend the project.&lt;/p&gt;

&lt;p&gt;If you were extending this project, what would you build next: budgets, dates, search, editing transactions, or something else?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsneuoc70die4u73oupda.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsneuoc70die4u73oupda.jpeg" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>The Electromagnetic Spectrum: The Invisible Infrastructure Behind Our Connected World</title>
      <dc:creator>Tu codigo cotidiano</dc:creator>
      <pubDate>Mon, 27 Jul 2026 14:13:34 +0000</pubDate>
      <link>https://dev.to/tu_codigocotidiano_f173d/the-electromagnetic-spectrum-the-invisible-infrastructure-behind-our-connected-world-3kon</link>
      <guid>https://dev.to/tu_codigocotidiano_f173d/the-electromagnetic-spectrum-the-invisible-infrastructure-behind-our-connected-world-3kon</guid>
      <description>&lt;p&gt;Before getting out of bed, you have probably already used one of the most important infrastructures in the modern world.&lt;/p&gt;

&lt;p&gt;You checked your phone, received a message, or connected to Wi-Fi.&lt;/p&gt;

&lt;p&gt;None of those actions would be possible without the &lt;strong&gt;electromagnetic spectrum&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  An invisible network around us
&lt;/h2&gt;

&lt;p&gt;Radio, Wi-Fi, Bluetooth, mobile networks, television, satellite communications, and many navigation systems use specific regions of the electromagnetic spectrum.&lt;/p&gt;

&lt;p&gt;Although these technologies may appear unrelated, they all transmit information using electromagnetic waves.&lt;/p&gt;

&lt;p&gt;What changes between them is mainly their frequency, wavelength, transmission power, and method of encoding information.&lt;/p&gt;

&lt;p&gt;Even visible light belongs to this same family. Our eyes simply detect a very small portion of a much larger spectrum.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequencies as invisible lanes
&lt;/h2&gt;

&lt;p&gt;Imagine hundreds of people speaking inside the same room at the same time.&lt;/p&gt;

&lt;p&gt;Without separate conversations, turns, or channels, understanding anyone would become extremely difficult.&lt;/p&gt;

&lt;p&gt;Something similar happens with wireless communications.&lt;/p&gt;

&lt;p&gt;Different services use different frequency bands to reduce interference. Mobile networks, aviation, emergency services, weather systems, radio stations, and satellites must operate under carefully coordinated rules.&lt;/p&gt;

&lt;p&gt;These frequencies work like invisible lanes through which information travels.&lt;/p&gt;

&lt;p&gt;Some frequencies can cover long distances and pass through obstacles more effectively. Others can carry larger amounts of information but require more antennas or clearer paths between transmitter and receiver.&lt;/p&gt;

&lt;h2&gt;
  
  
  Internet is not a magical cloud
&lt;/h2&gt;

&lt;p&gt;Wireless signals are only one part of the journey.&lt;/p&gt;

&lt;p&gt;After reaching an antenna, information may continue through base stations, fiber-optic cables, data centers, and satellite links.&lt;/p&gt;

&lt;p&gt;Fiber optics also use electromagnetic radiation, transmitting information through pulses of light.&lt;/p&gt;

&lt;p&gt;The connected world therefore combines two major routes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Electromagnetic waves travelling through the air.&lt;/li&gt;
&lt;li&gt;Light pulses travelling through fiber-optic cables.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Together, they support everything from everyday messages to aircraft navigation, weather alerts, emergency communications, and space exploration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Listen to the episode
&lt;/h2&gt;

&lt;p&gt;In this Spanish-language episode of &lt;strong&gt;TuCódigoCotidiano&lt;/strong&gt;, Javier and Laura explore the electromagnetic spectrum and explain why it can be understood as the invisible infrastructure of modern society.&lt;/p&gt;

&lt;p&gt;🎧 Listen here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tucodigocotidiano.yarumaltech.com/escuchar-podcast/el-espectro-electromagnetico-la-infraestructura-invisible/" rel="noopener noreferrer"&gt;https://tucodigocotidiano.yarumaltech.com/escuchar-podcast/el-espectro-electromagnetico-la-infraestructura-invisible/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cities have visible roads for vehicles and electromagnetic roads for information.&lt;/p&gt;

&lt;p&gt;Although we cannot see them, their design determines how connected, secure, and resilient our society can become.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3xxspnz32demzbxgh26b.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3xxspnz32demzbxgh26b.jpg" alt=" " width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>telecommunications</category>
      <category>networking</category>
      <category>science</category>
      <category>podcast</category>
    </item>
    <item>
      <title>Python Functions for Beginners: Stop Repeating Code and Start Reusing Solutions</title>
      <dc:creator>Tu codigo cotidiano</dc:creator>
      <pubDate>Fri, 24 Jul 2026 14:10:27 +0000</pubDate>
      <link>https://dev.to/tu_codigocotidiano_f173d/python-functions-for-beginners-stop-repeating-code-and-start-reusing-solutions-2664</link>
      <guid>https://dev.to/tu_codigocotidiano_f173d/python-functions-for-beginners-stop-repeating-code-and-start-reusing-solutions-2664</guid>
      <description>&lt;p&gt;Copying a few lines of code may seem harmless.&lt;/p&gt;

&lt;p&gt;But what happens when the same instructions appear three, five, or ten times throughout your program?&lt;/p&gt;

&lt;p&gt;A small change suddenly requires editing several places. One forgotten copy may behave differently from the others, and the program becomes harder to understand and maintain.&lt;/p&gt;

&lt;p&gt;This is one of the problems that functions help us solve.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If a task appears several times, it probably needs a name.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A function turns a group of related instructions into a reusable solution that we can execute whenever we need it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem with repeated code
&lt;/h2&gt;

&lt;p&gt;Imagine that we need to calculate the total price of several purchases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;product_1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;notebook&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;price_1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;8500&lt;/span&gt;
&lt;span class="n"&gt;quantity_1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="n"&gt;total_1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price_1&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;quantity_1&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;quantity_1&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; units of &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;product_1&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; cost $&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;total_1&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;product_2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pencil&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;price_2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;
&lt;span class="n"&gt;quantity_2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="n"&gt;total_2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price_2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;quantity_2&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;quantity_2&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; units of &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;product_2&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; cost $&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;total_2&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The program works, but the same procedure is repeated:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Receive a product.&lt;/li&gt;
&lt;li&gt;Receive its price.&lt;/li&gt;
&lt;li&gt;Receive a quantity.&lt;/li&gt;
&lt;li&gt;Calculate the total.&lt;/li&gt;
&lt;li&gt;Display the result.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Instead of copying that procedure every time, we can create a function and give the task a descriptive name.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a function with &lt;code&gt;def&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;In Python, a function definition begins with the &lt;code&gt;def&lt;/code&gt; keyword:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello! Welcome to Python.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This definition contains several important parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;def&lt;/code&gt; tells Python that we are defining a function.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;greet&lt;/code&gt; is the function name.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;()&lt;/code&gt; contains the function parameters.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;:&lt;/code&gt; marks the beginning of the function body.&lt;/li&gt;
&lt;li&gt;The indented instructions belong to the function.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Defining a function does not execute it automatically.&lt;/p&gt;

&lt;p&gt;To run its instructions, we must call it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello! Welcome to Python.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each call executes the function body again.&lt;/p&gt;

&lt;p&gt;This distinction is essential:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A function definition describes a task. A function call asks Python to perform it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Parameters and arguments
&lt;/h2&gt;

&lt;p&gt;Our first function always displays the same message.&lt;/p&gt;

&lt;p&gt;To make it work with different values, we can add a parameter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello, &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;. Welcome to Python.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Laura&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Carlos&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Sofia&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;name&lt;/code&gt; is a &lt;strong&gt;parameter&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"Laura"&lt;/code&gt;, &lt;code&gt;"Carlos"&lt;/code&gt;, and &lt;code&gt;"Sofia"&lt;/code&gt; are &lt;strong&gt;arguments&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A parameter represents the information that a function expects to receive.&lt;/p&gt;

&lt;p&gt;An argument is the actual value provided when the function is called.&lt;/p&gt;

&lt;p&gt;The same function can therefore process different data without changing its internal instructions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using multiple parameters
&lt;/h2&gt;

&lt;p&gt;A function can receive more than one value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;show_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; units of &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; cost $&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;show_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;notebook&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;show_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pencil&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python matches positional arguments with parameters according to their order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"notebook" → product
8500       → price
3          → quantity
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For this reason, both the number and order of the arguments matter.&lt;/p&gt;

&lt;p&gt;The calculation logic now exists in only one place. We can reuse it with as many products as necessary.&lt;/p&gt;

&lt;h2&gt;
  
  
  Returning results with &lt;code&gt;return&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The previous function displays the calculated total.&lt;/p&gt;

&lt;p&gt;But what happens when another part of the program needs to use that value?&lt;/p&gt;

&lt;p&gt;This is where &lt;code&gt;return&lt;/code&gt; becomes important:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The returned value can be stored in a variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;notebook_total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculate_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;pencil_total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculate_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;notebook_total&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pencil_total&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It can also participate in another operation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;grand_total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;notebook_total&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;pencil_total&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grand_total&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A returned value is not limited to being displayed.&lt;/p&gt;

&lt;p&gt;The program can store it, compare it, transform it, send it to another function, or use it in a larger calculation.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;print()&lt;/code&gt; and &lt;code&gt;return&lt;/code&gt; are not the same
&lt;/h2&gt;

&lt;p&gt;This is one of the most important distinctions when learning Python functions.&lt;/p&gt;

&lt;p&gt;Consider these two examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;show_double&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_double&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both functions calculate the same value, but they do different things.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;show_double()&lt;/code&gt; displays the value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;show_double&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Its output is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;calculate_double()&lt;/code&gt; returns the value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculate_double&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Its output is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;14
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A useful way to remember the difference is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;print()&lt;/code&gt; communicates a value to the user.&lt;br&gt;
&lt;code&gt;return&lt;/code&gt; gives the value back to the program.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Use &lt;code&gt;print()&lt;/code&gt; when the main purpose is to display information.&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;return&lt;/code&gt; when the result must continue participating in the program.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why does a function return &lt;code&gt;None&lt;/code&gt;?
&lt;/h2&gt;

&lt;p&gt;Every Python function call produces a result.&lt;/p&gt;

&lt;p&gt;When a function finishes without an explicit &lt;code&gt;return&lt;/code&gt;, Python automatically returns &lt;code&gt;None&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Consider this example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;show_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;show_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;25500
None
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function displayed &lt;code&gt;25500&lt;/code&gt;, but it did not return that number.&lt;/p&gt;

&lt;p&gt;Therefore, the value stored in &lt;code&gt;result&lt;/code&gt; is &lt;code&gt;None&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;None&lt;/code&gt; does not mean zero, an empty string, or an error.&lt;/p&gt;

&lt;p&gt;It represents the absence of a useful returned value.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common beginner mistakes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Forgetting the parentheses
&lt;/h3&gt;

&lt;p&gt;Writing the function name by itself refers to the function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;greet&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding parentheses calls it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first expression identifies the function object. The second expression executes the function.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Sending the wrong number of arguments
&lt;/h3&gt;

&lt;p&gt;A function with three required parameters expects three corresponding arguments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;show_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This call is incomplete:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;show_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;notebook&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8500&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python will report an error because the &lt;code&gt;quantity&lt;/code&gt; argument is missing.&lt;/p&gt;

&lt;p&gt;The correct call is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;show_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;notebook&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Sending arguments in the wrong order
&lt;/h3&gt;

&lt;p&gt;Consider this function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;show_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This call uses the correct number of arguments but places them incorrectly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;show_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;notebook&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python will assign:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;8500       → product
"notebook" → price
3          → quantity
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The names of positional parameters do not automatically identify the arguments. Their position determines how Python assigns them.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Trying to calculate with a function that only prints
&lt;/h3&gt;

&lt;p&gt;This function displays a value but returns &lt;code&gt;None&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;show_double&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Therefore, this operation will fail:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;show_double&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function prints &lt;code&gt;10&lt;/code&gt;, but &lt;code&gt;result&lt;/code&gt; contains &lt;code&gt;None&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To reuse the calculated value, return it instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_double&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculate_double&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  A practical example
&lt;/h2&gt;

&lt;p&gt;Let us create a function that calculates the price of a purchase after applying a discount:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_discounted_price&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discount_percentage&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;discount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;discount_percentage&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
    &lt;span class="n"&gt;final_price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;discount&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;final_price&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can now use the same solution with different values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;first_product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculate_discounted_price&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;second_product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculate_discounted_price&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;80000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;first_product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;second_product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;90000.0
68000.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can also combine the returned values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;purchase_total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;first_product&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;second_product&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;purchase_total&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This demonstrates the main advantage of &lt;code&gt;return&lt;/code&gt;: the results can continue moving through the program.&lt;/p&gt;

&lt;h2&gt;
  
  
  A better way to think about functions
&lt;/h2&gt;

&lt;p&gt;Functions are more than a Python syntax feature.&lt;/p&gt;

&lt;p&gt;They help us:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Divide large problems into smaller tasks.&lt;/li&gt;
&lt;li&gt;Give meaningful names to those tasks.&lt;/li&gt;
&lt;li&gt;Avoid repeating instructions.&lt;/li&gt;
&lt;li&gt;Make changes in one place.&lt;/li&gt;
&lt;li&gt;Test individual pieces of logic.&lt;/li&gt;
&lt;li&gt;Reuse solutions with different data.&lt;/li&gt;
&lt;li&gt;Combine small solutions into larger programs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When deciding whether to create a function, ask:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Does this task appear more than once?&lt;/li&gt;
&lt;li&gt;Can I describe the task with a clear name?&lt;/li&gt;
&lt;li&gt;Which information does the task need?&lt;/li&gt;
&lt;li&gt;Should the function display something or return a result?&lt;/li&gt;
&lt;li&gt;Will another part of the program need the result?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These questions transform functions from a syntax exercise into a tool for designing better programs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final challenge
&lt;/h2&gt;

&lt;p&gt;Create a function called &lt;code&gt;calculate_average&lt;/code&gt; that receives three grades and returns their average.&lt;/p&gt;

&lt;p&gt;Start with this structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_average&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grade_1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;grade_2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;grade_3&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# Write your solution here
&lt;/span&gt;    &lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then store the result and display it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;student_average&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculate_average&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;4.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;3.8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;4.2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;student_average&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As an additional challenge, create another function that receives the average and returns either &lt;code&gt;"Passed"&lt;/code&gt; or &lt;code&gt;"Failed"&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Continue learning
&lt;/h2&gt;

&lt;p&gt;I published a complete illustrated Spanish guide that explains these concepts with additional examples, practical exercises, and common mistakes:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://tucodigocotidiano.yarumaltech.com/leer_guias/funciones-divide-los-problemas-y-reutiliza-soluciones/" rel="noopener noreferrer"&gt;https://tucodigocotidiano.yarumaltech.com/leer_guias/funciones-divide-los-problemas-y-reutiliza-soluciones/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What confused you the most when you first learned functions: parameters, arguments, &lt;code&gt;return&lt;/code&gt;, or &lt;code&gt;None&lt;/code&gt;?&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Python Dictionaries and Sets: Organize Named Data and Remove Duplicates</title>
      <dc:creator>Tu codigo cotidiano</dc:creator>
      <pubDate>Tue, 21 Jul 2026 16:44:17 +0000</pubDate>
      <link>https://dev.to/tu_codigocotidiano_f173d/python-dictionaries-and-sets-organize-named-data-and-remove-duplicates-4kc4</link>
      <guid>https://dev.to/tu_codigocotidiano_f173d/python-dictionaries-and-sets-organize-named-data-and-remove-duplicates-4kc4</guid>
      <description>&lt;p&gt;When we start learning Python, lists are often one of the first data structures we use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;student&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Laura&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Medellín&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works, but what does each position represent?&lt;/p&gt;

&lt;p&gt;We need to remember that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Position &lt;code&gt;0&lt;/code&gt; contains the name.&lt;/li&gt;
&lt;li&gt;Position &lt;code&gt;1&lt;/code&gt; contains the age.&lt;/li&gt;
&lt;li&gt;Position &lt;code&gt;2&lt;/code&gt; contains the city.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A dictionary provides a clearer alternative because every value is identified by a descriptive key.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a dictionary
&lt;/h2&gt;

&lt;p&gt;A dictionary stores information as key-value pairs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;student&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Laura&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;age&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;city&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Medellín&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of asking for the value at position &lt;code&gt;0&lt;/code&gt;, we can ask directly for the value associated with &lt;code&gt;"name"&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;student&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Laura
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A useful way to remember the difference is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A list position tells you where a value is. A dictionary key tells you what the value means.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Updating and adding information
&lt;/h2&gt;

&lt;p&gt;Python dictionaries are mutable, so their content can change after creation.&lt;/p&gt;

&lt;p&gt;To update an existing value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Keyboard&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;price&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;120000&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;price&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;110000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To add a new key-value pair, use the same syntax with a key that does not exist yet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;available&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The resulting dictionary is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Keyboard&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;price&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;110000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;available&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Safely reading values with &lt;code&gt;get()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Using square brackets requires the key to exist:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;student&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;email&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If &lt;code&gt;"email"&lt;/code&gt; is missing, Python raises a &lt;code&gt;KeyError&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;get()&lt;/code&gt; method provides a safer alternative:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;student&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;email&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It returns &lt;code&gt;None&lt;/code&gt; when the key is missing.&lt;/p&gt;

&lt;p&gt;You can also define a default value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;student&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;email&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Not registered&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Not registered
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To check whether a key exists, use the &lt;code&gt;in&lt;/code&gt; operator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;city&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;student&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;student&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;city&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Keys, values, and pairs
&lt;/h2&gt;

&lt;p&gt;Python provides three useful dictionary methods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;course&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Python Basics&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;duration&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;4 weeks&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;format&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Online&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;course&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;course&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;course&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;They provide different views of the same information:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;keys()&lt;/code&gt; returns the keys.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;values()&lt;/code&gt; returns the stored values.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;items()&lt;/code&gt; returns complete key-value pairs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Looping through a dictionary
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;items()&lt;/code&gt; method is especially useful when working with a &lt;code&gt;for&lt;/code&gt; loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;capitals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Colombia&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bogotá&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Peru&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Lima&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Argentina&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Buenos Aires&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;country&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;capital&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;capitals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;country&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;capital&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Colombia: Bogotá
Peru: Lima
Argentina: Buenos Aires
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During every iteration, Python assigns the current key to &lt;code&gt;country&lt;/code&gt; and its associated value to &lt;code&gt;capital&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a set?
&lt;/h2&gt;

&lt;p&gt;A set is a collection that stores unique values.&lt;/p&gt;

&lt;p&gt;Consider this list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;languages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Python&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Rust&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Python&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;JavaScript&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Rust&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can remove repeated values by converting it into a set:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;unique_languages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;languages&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;unique_languages&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The set keeps only one occurrence of each language.&lt;/p&gt;

&lt;p&gt;Sets are useful when you need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Remove duplicate values.&lt;/li&gt;
&lt;li&gt;Check whether a value is present.&lt;/li&gt;
&lt;li&gt;Compare groups of elements.&lt;/li&gt;
&lt;li&gt;Work with unique categories or identifiers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Unlike lists, sets do not support indexes or slicing.&lt;/p&gt;

&lt;h2&gt;
  
  
  An important detail
&lt;/h2&gt;

&lt;p&gt;Empty braces create an empty dictionary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;empty_dictionary&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create an empty set, use &lt;code&gt;set()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;empty_set&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a common source of confusion for Python beginners.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which structure should you choose?
&lt;/h2&gt;

&lt;p&gt;Use a &lt;strong&gt;list&lt;/strong&gt; when position and order are important.&lt;/p&gt;

&lt;p&gt;Use a &lt;strong&gt;dictionary&lt;/strong&gt; when every value should have a descriptive name.&lt;/p&gt;

&lt;p&gt;Use a &lt;strong&gt;set&lt;/strong&gt; when you need unique values and repetitions do not matter.&lt;/p&gt;

&lt;p&gt;Understanding this distinction makes programs easier to read, maintain, and extend.&lt;/p&gt;

&lt;p&gt;The original Spanish guide includes a step-by-step explanation with additional examples:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tucodigocotidiano.yarumaltech.com/leer_guias/diccionarios-y-conjuntos-datos-con-nombre-y-sin-duplicados/" rel="noopener noreferrer"&gt;https://tucodigocotidiano.yarumaltech.com/leer_guias/diccionarios-y-conjuntos-datos-con-nombre-y-sin-duplicados/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What was more confusing when you first learned Python: dictionaries or sets?&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Python Lists and Tuples for Beginners: Organize Data Step by Step</title>
      <dc:creator>Tu codigo cotidiano</dc:creator>
      <pubDate>Thu, 16 Jul 2026 11:46:35 +0000</pubDate>
      <link>https://dev.to/tu_codigocotidiano_f173d/python-lists-and-tuples-for-beginners-organize-data-step-by-step-1mid</link>
      <guid>https://dev.to/tu_codigocotidiano_f173d/python-lists-and-tuples-for-beginners-organize-data-step-by-step-1mid</guid>
      <description>&lt;p&gt;When you start learning Python, storing information in individual variables feels natural:&lt;/p&gt;

&lt;p&gt;student_1 = "Ana"&lt;br&gt;
student_2 = "Luis"&lt;br&gt;
student_3 = "Marta"&lt;/p&gt;

&lt;p&gt;However, this approach becomes difficult to maintain as the amount of information grows.&lt;/p&gt;

&lt;p&gt;Python lists allow us to group related values inside a single ordered collection:&lt;/p&gt;

&lt;p&gt;students = ["Ana", "Luis", "Marta"]&lt;/p&gt;

&lt;p&gt;Now we can access each element using its index:&lt;/p&gt;

&lt;p&gt;print(students[0])   # Ana&lt;br&gt;
print(students[-1])  # Marta&lt;/p&gt;

&lt;p&gt;Because lists are mutable, their elements can be updated after creation:&lt;/p&gt;

&lt;p&gt;students[1] = "Carlos"&lt;/p&gt;

&lt;p&gt;We can also add new information using append() or insert():&lt;/p&gt;

&lt;p&gt;students.append("Laura")&lt;br&gt;
students.insert(1, "Daniel")&lt;/p&gt;

&lt;p&gt;To remove elements, Python provides methods such as remove() and pop():&lt;/p&gt;

&lt;p&gt;students.remove("Ana")&lt;br&gt;
removed_student = students.pop(1)&lt;/p&gt;

&lt;p&gt;Lists can also be inspected without modifying them:&lt;/p&gt;

&lt;p&gt;print(len(students))&lt;br&gt;
print("Laura" in students)&lt;br&gt;
print("Pedro" not in students)&lt;/p&gt;

&lt;p&gt;Another useful operation is slicing, which lets us obtain part of a list:&lt;/p&gt;

&lt;p&gt;numbers = [10, 20, 30, 40, 50]&lt;/p&gt;

&lt;p&gt;print(numbers[1:4])&lt;br&gt;
print(numbers[:3])&lt;br&gt;
print(numbers[3:])&lt;/p&gt;

&lt;p&gt;Lists are ideal when the information may change. Tuples, on the other hand, are useful when the values should remain stable.&lt;/p&gt;

&lt;p&gt;Understanding both structures is an essential step toward building cleaner programs, processing collections of data, and working with loops, functions, APIs, and databases.&lt;/p&gt;

&lt;p&gt;I created a practical, beginner-friendly guide explaining these concepts step by step, with examples in Spanish.&lt;/p&gt;

&lt;p&gt;📖 Read the complete guide:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tucodigocotidiano.yarumaltech.com/leer_guias/listas-y-tuplas-organiza-informacion-en-orden/" rel="noopener noreferrer"&gt;https://tucodigocotidiano.yarumaltech.com/leer_guias/listas-y-tuplas-organiza-informacion-en-orden/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What was the first real project where you needed to use a Python list?&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>Python Strings From Scratch: Learn to Make Your Programs Communicate</title>
      <dc:creator>Tu codigo cotidiano</dc:creator>
      <pubDate>Wed, 15 Jul 2026 11:46:17 +0000</pubDate>
      <link>https://dev.to/tu_codigocotidiano_f173d/python-strings-from-scratch-learn-to-make-your-programs-communicate-25a1</link>
      <guid>https://dev.to/tu_codigocotidiano_f173d/python-strings-from-scratch-learn-to-make-your-programs-communicate-25a1</guid>
      <description>&lt;p&gt;Programming is not only about performing calculations. A useful program must also be able to display names, instructions, states and results that people can understand.&lt;/p&gt;

&lt;p&gt;I published a new Spanish guide in TuCódigoCotidiano explaining how strings work in Python from the ground up.&lt;/p&gt;

&lt;p&gt;In this guide, you will learn:&lt;/p&gt;

&lt;p&gt;What a string and the str data type are&lt;br&gt;
How to use single and double quotes&lt;br&gt;
How Python organizes characters through indexes&lt;br&gt;
How to access the first and last characters&lt;br&gt;
How to extract fragments using slicing&lt;br&gt;
How to concatenate and repeat text&lt;br&gt;
How to build clearer messages in your programs&lt;/p&gt;

&lt;p&gt;The explanations are accompanied by practical code examples that you can copy, run and modify while learning.&lt;/p&gt;

&lt;p&gt;Numbers allow programs to calculate. Strings allow programs to communicate.&lt;/p&gt;

&lt;p&gt;Read the complete guide in Spanish:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tucodigocotidiano.yarumaltech.com/leer_guias/cadenas-de-texto-aprende-a-conversar-con-python/" rel="noopener noreferrer"&gt;https://tucodigocotidiano.yarumaltech.com/leer_guias/cadenas-de-texto-aprende-a-conversar-con-python/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
      <category>spanish</category>
    </item>
    <item>
      <title>How to Build a Smart Android Compass with Kotlin, Jetpack Compose, and Sensor Fusion</title>
      <dc:creator>Tu codigo cotidiano</dc:creator>
      <pubDate>Mon, 13 Jul 2026 15:23:22 +0000</pubDate>
      <link>https://dev.to/tu_codigocotidiano_f173d/how-to-build-a-smart-android-compass-with-kotlin-jetpack-compose-and-sensor-fusion-551k</link>
      <guid>https://dev.to/tu_codigocotidiano_f173d/how-to-build-a-smart-android-compass-with-kotlin-jetpack-compose-and-sensor-fusion-551k</guid>
      <description>&lt;p&gt;A compass app sounds simple: read an angle from the phone and rotate a needle.&lt;/p&gt;

&lt;p&gt;Real sensors make the problem much more interesting.&lt;/p&gt;

&lt;p&gt;The measurements contain noise, the phone can rotate between portrait and landscape, nearby objects can affect the magnetometer, and angles cannot always be processed like ordinary numbers.&lt;/p&gt;

&lt;p&gt;I explored these challenges by building &lt;strong&gt;SmartCompass&lt;/strong&gt;, an Android application created with Kotlin and Jetpack Compose.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5jx677fle9hpj8wlqw3y.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5jx677fle9hpj8wlqw3y.jpeg" alt="SmartCompass Android application showing the compass heading, cardinal direction, magnetic field strength, and calibration status" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What the application does
&lt;/h2&gt;

&lt;p&gt;SmartCompass combines the phone's accelerometer and magnetometer to calculate its magnetic orientation.&lt;/p&gt;

&lt;p&gt;The application can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Calculate a magnetic heading between 0° and 359°.&lt;/li&gt;
&lt;li&gt;Convert the heading into a cardinal direction.&lt;/li&gt;
&lt;li&gt;Calculate pitch and roll.&lt;/li&gt;
&lt;li&gt;Smooth accelerometer and magnetometer measurements.&lt;/li&gt;
&lt;li&gt;Stabilize the final heading.&lt;/li&gt;
&lt;li&gt;Correct the coordinate system when the screen rotates.&lt;/li&gt;
&lt;li&gt;Measure magnetic field strength in microteslas.&lt;/li&gt;
&lt;li&gt;Build a local magnetic reference.&lt;/li&gt;
&lt;li&gt;Detect persistent changes relative to that reference.&lt;/li&gt;
&lt;li&gt;Report the magnetometer accuracy and calibration state.&lt;/li&gt;
&lt;li&gt;Handle devices without the required sensors.&lt;/li&gt;
&lt;li&gt;Start and stop sensor collection according to the Android lifecycle.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It does not require GPS or location permissions because it displays &lt;strong&gt;magnetic north&lt;/strong&gt;, not geographic north.&lt;/p&gt;

&lt;h2&gt;
  
  
  The circular-angle problem
&lt;/h2&gt;

&lt;p&gt;One of the most interesting problems appears when the compass crosses north.&lt;/p&gt;

&lt;p&gt;Consider these two measurements:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;359°
1°
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A regular arithmetic mean produces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(359 + 1) / 2 = 180°
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That result points south, even though both measurements are close to north.&lt;/p&gt;

&lt;p&gt;Angles form a circle rather than an infinite line. After 359°, the next direction is 0°. A heading filter must therefore understand circular distance.&lt;/p&gt;

&lt;p&gt;SmartCompass converts every angle into a two-dimensional unit vector:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = cos(angle)
y = sin(angle)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The vectors can be averaged, and the resulting direction can be recovered with &lt;code&gt;atan2()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This produces a value close to 0° for samples around 359° and 1°, avoiding the sudden jump to 180°.&lt;/p&gt;

&lt;h2&gt;
  
  
  Filtering the sensor measurements
&lt;/h2&gt;

&lt;p&gt;The application uses two different filtering strategies.&lt;/p&gt;

&lt;p&gt;First, a low-pass filter smooths the X, Y, and Z components received from the accelerometer and magnetometer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yₜ = αyₜ₋₁ + (1 − α)xₜ
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A larger &lt;code&gt;alpha&lt;/code&gt; produces a smoother but slower response. A smaller value reacts faster but preserves more noise.&lt;/p&gt;

&lt;p&gt;The filtered vectors are then used to calculate the device orientation.&lt;/p&gt;

&lt;p&gt;A second circular filter stabilizes the final heading. Keeping these responsibilities separate prevents a linear filter from being incorrectly applied to circular values.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding magnetic reliability
&lt;/h2&gt;

&lt;p&gt;Displaying a number is not enough. The application should also communicate whether that number can be trusted.&lt;/p&gt;

&lt;p&gt;SmartCompass uses two sources of information:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The accuracy level reported by Android.&lt;/li&gt;
&lt;li&gt;Changes in magnetic field strength relative to a local baseline.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;During the first samples, the application learns an approximate reference for the current environment. Later measurements are compared with this baseline.&lt;/p&gt;

&lt;p&gt;A single unusual sample does not immediately trigger a warning. The change must persist across several readings. Recovery also requires multiple normal readings, preventing the interface from constantly switching between warning and normal states.&lt;/p&gt;

&lt;p&gt;This mechanism is educational and adaptive. It cannot identify the source of a magnetic change or replace professional measuring equipment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keeping the domain logic independent
&lt;/h2&gt;

&lt;p&gt;The mathematical and calibration components do not depend directly on Android or Jetpack Compose.&lt;/p&gt;

&lt;p&gt;Classes responsible for tasks such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Normalizing angles.&lt;/li&gt;
&lt;li&gt;Finding the shortest angular difference.&lt;/li&gt;
&lt;li&gt;Converting headings into cardinal directions.&lt;/li&gt;
&lt;li&gt;Filtering vectors.&lt;/li&gt;
&lt;li&gt;Filtering circular values.&lt;/li&gt;
&lt;li&gt;Evaluating calibration.&lt;/li&gt;
&lt;li&gt;Analyzing magnetic measurements.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;can be tested with local unit tests.&lt;/p&gt;

&lt;p&gt;Sensor access is exposed through an abstraction, while the presentation layer receives application-specific models instead of raw &lt;code&gt;SensorManager&lt;/code&gt; events.&lt;/p&gt;

&lt;p&gt;This separation makes the code easier to understand, test, and extend.&lt;/p&gt;

&lt;h2&gt;
  
  
  A compass is more than a rotating needle
&lt;/h2&gt;

&lt;p&gt;The most valuable lesson from this project is that applications working with physical measurements should expose uncertainty and state, not only a final value.&lt;/p&gt;

&lt;p&gt;A useful compass should not merely say:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Heading: 23°
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It should also be able to explain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Direction: Northeast
Accuracy: Medium
Magnetic field: 43.2 μT
Calibration: Acceptable
Reading status: Ready
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That additional context helps the user understand when the measurement is stable and when the environment or sensor may require attention.&lt;/p&gt;

&lt;p&gt;I documented the complete implementation step by step, including the Android project structure, sensor processing, circular filters, calibration models, magnetic analysis, Compose interface, lifecycle management, and testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read the complete tutorial
&lt;/h2&gt;

&lt;p&gt;The full tutorial is available in Spanish:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://tucodigocotidiano.yarumaltech.com/leer_tutoriales/construye-una-brujula-inteligente-en-android-con-kotlin-y-jetpack-compose/" rel="noopener noreferrer"&gt;Build a Smart Compass on Android with Kotlin and Jetpack Compose&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What other smartphone sensor would you use for your next Android experiment?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxohc5a1ed8rmspf6c20g.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxohc5a1ed8rmspf6c20g.jpeg" alt=" " width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>android</category>
      <category>kotlin</category>
      <category>jetpackcompose</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Bucles en Python: aprende for, while y range desde cero</title>
      <dc:creator>Tu codigo cotidiano</dc:creator>
      <pubDate>Thu, 09 Jul 2026 21:10:19 +0000</pubDate>
      <link>https://dev.to/tu_codigocotidiano_f173d/bucles-en-python-aprende-for-while-y-range-desde-cero-58pc</link>
      <guid>https://dev.to/tu_codigocotidiano_f173d/bucles-en-python-aprende-for-while-y-range-desde-cero-58pc</guid>
      <description>&lt;p&gt;Cuando empiezas a aprender Python, una de las primeras señales de avance es dejar de copiar el mismo código muchas veces.&lt;/p&gt;

&lt;p&gt;Ahí aparecen los bucles.&lt;/p&gt;

&lt;p&gt;Un bucle permite repetir instrucciones de forma automática. En lugar de escribir varias veces la misma línea, le dices a Python qué debe repetir y bajo qué regla debe hacerlo.&lt;/p&gt;

&lt;h2&gt;
  
  
  Primer ejemplo con &lt;code&gt;for&lt;/code&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;numero&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numero&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Este código muestra los números del 1 al 5.&lt;/p&gt;

&lt;p&gt;La parte importante está aquí:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;En Python, el valor final de &lt;code&gt;range()&lt;/code&gt; funciona como límite, pero no se incluye. Por eso &lt;code&gt;range(1, 6)&lt;/code&gt; llega hasta 5.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;for&lt;/code&gt; también puede recorrer datos
&lt;/h2&gt;

&lt;p&gt;Un &lt;code&gt;for&lt;/code&gt; no solo sirve para contar. También puede recorrer elementos uno por uno:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;tareas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;comprar&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;empacar&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;enviar&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;tarea&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tareas&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Pendiente:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tarea&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Esto es útil cuando tienes datos parecidos: tareas, productos, nombres, mensajes o pedidos.&lt;/p&gt;

&lt;h2&gt;
  
  
  ¿Y qué hace &lt;code&gt;while&lt;/code&gt;?
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;while&lt;/code&gt; repite un bloque mientras una condición siga siendo verdadera.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;contador&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;contador&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;contador&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;contador&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;contador&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;En este caso, el contador empieza en 1 y aumenta en cada vuelta. Cuando llega a un valor mayor que 5, la condición deja de cumplirse y el bucle termina.&lt;/p&gt;

&lt;h2&gt;
  
  
  Regla sencilla
&lt;/h2&gt;

&lt;p&gt;Usa &lt;code&gt;for&lt;/code&gt; cuando tienes una secuencia o una cantidad clara de repeticiones.&lt;/p&gt;

&lt;p&gt;Usa &lt;code&gt;while&lt;/code&gt; cuando la repetición depende de una condición.&lt;/p&gt;

&lt;h2&gt;
  
  
  Errores comunes
&lt;/h2&gt;

&lt;p&gt;Al empezar con bucles, estos errores son normales:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;olvidar los dos puntos &lt;code&gt;:&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;no indentar el bloque&lt;/li&gt;
&lt;li&gt;pensar que &lt;code&gt;range(1, 6)&lt;/code&gt; llega hasta 6&lt;/li&gt;
&lt;li&gt;no actualizar el contador en un &lt;code&gt;while&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;copiar manualmente código que podría ir dentro de un bucle&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Mini reto
&lt;/h2&gt;

&lt;p&gt;Crea una lista de pedidos y recórrela con &lt;code&gt;for&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pedidos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Pedido 1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Pedido 2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Pedido 3&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;pedido&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pedidos&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Revisando:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pedido&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Todos los pedidos fueron revisados&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Guía completa
&lt;/h2&gt;

&lt;p&gt;Publiqué una guía más visual y paso a paso en TuCodigoCotidiano:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://tucodigocotidiano.yarumaltech.com/leer_guias/bucles-for-y-while-el-arte-de-repetir-sin-cansarse/" rel="noopener noreferrer"&gt;https://tucodigocotidiano.yarumaltech.com/leer_guias/bucles-for-y-while-el-arte-de-repetir-sin-cansarse/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;La idea es que una persona principiante pueda pasar de:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Estoy copiando el mismo código varias veces”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;a:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Puedo usar un bucle para repetir una tarea automáticamente”.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxqgzy7biithbt3lzp13i.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxqgzy7biithbt3lzp13i.jpeg" alt=" " width="800" height="566"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>spanish</category>
    </item>
    <item>
      <title>Condicionales en Python: enseña a tu programa a tomar decisiones</title>
      <dc:creator>Tu codigo cotidiano</dc:creator>
      <pubDate>Thu, 09 Jul 2026 03:01:04 +0000</pubDate>
      <link>https://dev.to/tu_codigocotidiano_f173d/condicionales-en-python-ensena-a-tu-programa-a-tomar-decisiones-5pp</link>
      <guid>https://dev.to/tu_codigocotidiano_f173d/condicionales-en-python-ensena-a-tu-programa-a-tomar-decisiones-5pp</guid>
      <description>&lt;h1&gt;
  
  
  Condicionales en Python: enseña a tu programa a tomar decisiones
&lt;/h1&gt;

&lt;p&gt;Cuando una persona empieza a aprender Python, normalmente aprende primero a guardar datos, hacer operaciones y mostrar resultados.&lt;/p&gt;

&lt;p&gt;Pero hay un momento clave en el aprendizaje:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;cuando el programa deja de hacer siempre lo mismo y empieza a tomar decisiones.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Para eso existen los condicionales.&lt;/p&gt;

&lt;p&gt;En esta guía explico los condicionales desde cero, con ejemplos pensados para principiantes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Qué aprenderás
&lt;/h2&gt;

&lt;p&gt;En la guía se explica:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;qué es un condicional;&lt;/li&gt;
&lt;li&gt;qué es una condición;&lt;/li&gt;
&lt;li&gt;qué significan &lt;code&gt;True&lt;/code&gt; y &lt;code&gt;False&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;cómo usar &lt;code&gt;if&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;cómo usar &lt;code&gt;else&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;cómo usar &lt;code&gt;elif&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;cómo evitar errores comunes;&lt;/li&gt;
&lt;li&gt;y cómo resolver un mini reto práctico.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Ejemplo básico
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;edad&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;edad&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Puedes entrar&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Aún no puedes entrar&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;La idea es que Python revise una condición y decida qué bloque de código debe ejecutar.&lt;/p&gt;

&lt;h2&gt;
  
  
  Por qué es importante
&lt;/h2&gt;

&lt;p&gt;Los condicionales son una de las bases de la programación.&lt;/p&gt;

&lt;p&gt;Permiten crear programas que reaccionan a los datos, por ejemplo:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;validar una edad;&lt;/li&gt;
&lt;li&gt;aplicar un descuento;&lt;/li&gt;
&lt;li&gt;mostrar un mensaje diferente;&lt;/li&gt;
&lt;li&gt;elegir entre varios caminos;&lt;/li&gt;
&lt;li&gt;tomar decisiones a partir de resultados calculados.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Guía completa
&lt;/h2&gt;

&lt;p&gt;Puedes leer la guía completa aquí:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tucodigocotidiano.yarumaltech.com/leer_guias/condicionales-ensena-a-tu-programa-a-tomar-decisiones/" rel="noopener noreferrer"&gt;https://tucodigocotidiano.yarumaltech.com/leer_guias/condicionales-ensena-a-tu-programa-a-tomar-decisiones/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Si estás empezando con Python, esta guía te ayuda a pasar de “Python calcula” a “Python decide”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fooopw90io3wpjdjz4rqw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fooopw90io3wpjdjz4rqw.jpeg" alt=" " width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
      <category>spanish</category>
    </item>
    <item>
      <title>I built Deception Mesh: an open-source Rust MVP for defensive cybersecurity telemetry</title>
      <dc:creator>Tu codigo cotidiano</dc:creator>
      <pubDate>Wed, 08 Jul 2026 21:06:08 +0000</pubDate>
      <link>https://dev.to/tu_codigocotidiano_f173d/i-built-deception-mesh-an-open-source-rust-mvp-for-defensive-cybersecurity-telemetry-2co3</link>
      <guid>https://dev.to/tu_codigocotidiano_f173d/i-built-deception-mesh-an-open-source-rust-mvp-for-defensive-cybersecurity-telemetry-2co3</guid>
      <description>&lt;p&gt;I just published &lt;strong&gt;Deception Mesh&lt;/strong&gt;, an open-source cybersecurity MVP built in Rust.&lt;/p&gt;

&lt;p&gt;Project page: &lt;a href="https://tucodigocotidiano.yarumaltech.com/proyectos/deception-mesh/" rel="noopener noreferrer"&gt;https://tucodigocotidiano.yarumaltech.com/proyectos/deception-mesh/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
GitHub: &lt;a href="https://github.com/tucodigocotidiano/deception-mesh" rel="noopener noreferrer"&gt;https://github.com/tucodigocotidiano/deception-mesh&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I built it
&lt;/h2&gt;

&lt;p&gt;Most small projects and learning environments think about security only after something goes wrong.&lt;/p&gt;

&lt;p&gt;Firewalls, authentication and monitoring are important, but there is another useful defensive idea:&lt;/p&gt;

&lt;p&gt;What if we could deploy small decoy services that are not real production systems, but can help us observe suspicious behavior?&lt;/p&gt;

&lt;p&gt;That is the core idea behind Deception Mesh.&lt;/p&gt;

&lt;p&gt;Instead of exposing only real services, the project uses lightweight decoy sensors that can capture suspicious HTTP and SSH activity and turn it into structured telemetry.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Deception Mesh does
&lt;/h2&gt;

&lt;p&gt;Deception Mesh is a defensive MVP.&lt;/p&gt;

&lt;p&gt;It is not an offensive tool.&lt;/p&gt;

&lt;p&gt;It does not try to exploit systems.&lt;/p&gt;

&lt;p&gt;It does not provide attack automation.&lt;/p&gt;

&lt;p&gt;Its purpose is to help observe suspicious interactions against decoy services and make those events easier to inspect.&lt;/p&gt;

&lt;p&gt;The MVP includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTTP decoy sensor&lt;/li&gt;
&lt;li&gt;SSH decoy sensor&lt;/li&gt;
&lt;li&gt;REST API&lt;/li&gt;
&lt;li&gt;JWT authentication&lt;/li&gt;
&lt;li&gt;Role-based access control&lt;/li&gt;
&lt;li&gt;Webhook notifications&lt;/li&gt;
&lt;li&gt;CSV export&lt;/li&gt;
&lt;li&gt;Docker deployment&lt;/li&gt;
&lt;li&gt;Documentation for local execution and testing&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The technical idea
&lt;/h2&gt;

&lt;p&gt;The project is based on a simple flow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A suspicious client interacts with a decoy service.&lt;/li&gt;
&lt;li&gt;The sensor captures the event.&lt;/li&gt;
&lt;li&gt;The system stores or exposes the event as structured telemetry.&lt;/li&gt;
&lt;li&gt;The operator can review the signal through logs, CSV exports, API responses or webhook notifications.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The goal is not to replace enterprise security platforms.&lt;/p&gt;

&lt;p&gt;The goal is to show that a small, understandable and auditable deception layer can be built with practical software engineering.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Rust
&lt;/h2&gt;

&lt;p&gt;I chose Rust because it is a strong fit for infrastructure-oriented security projects.&lt;/p&gt;

&lt;p&gt;It gives a good balance between performance, memory safety and explicit design.&lt;/p&gt;

&lt;p&gt;For a project that handles network-facing components, Rust also encourages discipline around error handling, data structures and system boundaries.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I wanted to prove
&lt;/h2&gt;

&lt;p&gt;With this MVP, I wanted to validate four things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A deception-based security concept can be implemented without building a huge platform.&lt;/li&gt;
&lt;li&gt;Rust can be used to create small defensive sensors with clean architecture.&lt;/li&gt;
&lt;li&gt;Security telemetry can be made understandable for developers and students.&lt;/li&gt;
&lt;li&gt;A project can be useful even when its scope is intentionally limited.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That last point matters.&lt;/p&gt;

&lt;p&gt;This is not presented as a finished commercial product.&lt;/p&gt;

&lt;p&gt;It is a validated MVP with a clear defensive scope and room for improvement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who this project is for
&lt;/h2&gt;

&lt;p&gt;This project may be useful for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Software engineering students&lt;/li&gt;
&lt;li&gt;Cybersecurity students&lt;/li&gt;
&lt;li&gt;Backend developers&lt;/li&gt;
&lt;li&gt;Rust learners&lt;/li&gt;
&lt;li&gt;People interested in defensive infrastructure&lt;/li&gt;
&lt;li&gt;Anyone curious about deception-based security&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It can also be a starting point for discussions around telemetry, detection, infrastructure hardening and practical security engineering.&lt;/p&gt;

&lt;h2&gt;
  
  
  Current limitations
&lt;/h2&gt;

&lt;p&gt;The project is intentionally honest about its current stage.&lt;/p&gt;

&lt;p&gt;It is an MVP.&lt;/p&gt;

&lt;p&gt;It still needs more hardening, better testing, stronger deployment guidance and deeper validation before being treated as production-ready.&lt;/p&gt;

&lt;p&gt;That is part of the reason I am publishing it openly.&lt;/p&gt;

&lt;p&gt;I want feedback, technical criticism and ideas from people who care about building useful defensive systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;Deception Mesh started as a practical experiment, but it became a valuable learning project around cybersecurity, Rust, backend systems and telecommunications.&lt;/p&gt;

&lt;p&gt;If you are interested in open-source cybersecurity, defensive telemetry or Rust-based infrastructure, I would be happy if you take a look.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/tucodigocotidiano/deception-mesh" rel="noopener noreferrer"&gt;https://github.com/tucodigocotidiano/deception-mesh&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feedback, issues, stars and technical suggestions are welcome.&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>rust</category>
      <category>opensource</category>
      <category>backend</category>
    </item>
    <item>
      <title>Python Operators and Expressions Explained for Beginners</title>
      <dc:creator>Tu codigo cotidiano</dc:creator>
      <pubDate>Wed, 08 Jul 2026 00:01:13 +0000</pubDate>
      <link>https://dev.to/tu_codigocotidiano_f173d/python-operators-and-expressions-explained-for-beginners-2dkp</link>
      <guid>https://dev.to/tu_codigocotidiano_f173d/python-operators-and-expressions-explained-for-beginners-2dkp</guid>
      <description>&lt;p&gt;When you start learning Python, one of the first big steps is understanding variables.&lt;/p&gt;

&lt;p&gt;A variable lets your program remember information.&lt;/p&gt;

&lt;p&gt;But the next step is even more powerful:&lt;/p&gt;

&lt;p&gt;using that information to calculate results.&lt;/p&gt;

&lt;p&gt;I recently published a new Spanish guide in my Python from scratch series:&lt;/p&gt;

&lt;p&gt;Operadores y expresiones: haz que Python calcule por ti&lt;/p&gt;

&lt;p&gt;The guide explains operators and expressions with simple examples, without heavy theory.&lt;/p&gt;

&lt;p&gt;The main idea is:&lt;/p&gt;

&lt;p&gt;A variable stores information.&lt;br&gt;&lt;br&gt;
An operator tells Python what to do.&lt;br&gt;&lt;br&gt;
An expression produces a result.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;precio&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12000&lt;/span&gt;
&lt;span class="n"&gt;cantidad&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;

&lt;span class="n"&gt;subtotal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;precio&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;cantidad&lt;/span&gt;
&lt;span class="n"&gt;descuento&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;subtotal&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.10&lt;/span&gt;
&lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;subtotal&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;descuento&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The guide covers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;what an operator is&lt;/li&gt;
&lt;li&gt;what an expression is&lt;/li&gt;
&lt;li&gt;basic arithmetic operators in Python&lt;/li&gt;
&lt;li&gt;how to use variables inside calculations&lt;/li&gt;
&lt;li&gt;how to store calculated results&lt;/li&gt;
&lt;li&gt;why parentheses matter&lt;/li&gt;
&lt;li&gt;common beginner mistakes&lt;/li&gt;
&lt;li&gt;a small final challenge&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some basic examples from the guide are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And one important idea for beginners:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;resultado_sin_parentesis&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="n"&gt;resultado_con_parentesis&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both lines look similar, but they can produce different results because parentheses change the order of the calculation.&lt;/p&gt;

&lt;p&gt;This guide is written in Spanish and is designed for people who are learning Python from zero.&lt;/p&gt;

&lt;p&gt;Full guide:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tucodigocotidiano.yarumaltech.com/leer_guias/operadores-y-expresiones-haz-que-python-calcule-por-ti/" rel="noopener noreferrer"&gt;https://tucodigocotidiano.yarumaltech.com/leer_guias/operadores-y-expresiones-haz-que-python-calcule-por-ti/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What was the first programming concept that made you feel you were finally understanding how code works?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz78w8ea68y4rlislzp3n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz78w8ea68y4rlislzp3n.png" alt=" " width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
