<?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: Akinnimi Stefan Emmanuel</title>
    <description>The latest articles on DEV Community by Akinnimi Stefan Emmanuel (@akinnimimanuel).</description>
    <link>https://dev.to/akinnimimanuel</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1122442%2F2411d273-e969-4230-bb3e-bd034315aad4.jpeg</url>
      <title>DEV Community: Akinnimi Stefan Emmanuel</title>
      <link>https://dev.to/akinnimimanuel</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akinnimimanuel"/>
    <language>en</language>
    <item>
      <title>Events Handling In JavaScript</title>
      <dc:creator>Akinnimi Stefan Emmanuel</dc:creator>
      <pubDate>Sat, 30 Sep 2023 20:27:37 +0000</pubDate>
      <link>https://dev.to/akinnimimanuel/events-handling-in-javascript-440l</link>
      <guid>https://dev.to/akinnimimanuel/events-handling-in-javascript-440l</guid>
      <description>&lt;p&gt;Events are notifications of changes in the operating system or browser environment fired inside the browser window. Web pages may react effectively to changes thanks to the event handler code that programmers can design and run whenever an event occurs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Event Types
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Mouse Events&lt;br&gt;
Click: This occurs when a mouse button is clicked (pressed and released) on an element.&lt;br&gt;
dblclick: This occurs when a mouse button is double-clicked on an element.&lt;br&gt;
mousedown: This occurs when a mouse button is pressed down on an element.&lt;br&gt;
mouseup: This occurs when a mouse button is released on an element.&lt;br&gt;
mousemove: This occurs when the mouse pointer moves over an element.&lt;br&gt;
mouseenter: This occurs when the mouse pointer enters an element.&lt;br&gt;
mouseleave: This occurs when the mouse pointer leaves an element.&lt;br&gt;
mouseover: This occurs when the mouse pointer moves over an element or its child elements.&lt;br&gt;
mouseout: This occurs when the mouse pointer moves out of an element or its child elements.&lt;br&gt;
contextmenu: This occurs when the right mouse button is clicked on an element, opening the context menu.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keyboard Events&lt;br&gt;
keydown: This occurs when a keyboard key is pressed down.&lt;br&gt;
keyup: This occurs when a keyboard key is released.&lt;br&gt;
keypress: This occurs when a keyboard key is pressed and released.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Form Events&lt;br&gt;
 submit: This occurs when a form is submitted.&lt;br&gt;
 reset: This occurs when a form is reset.&lt;br&gt;
 input: This occurs when the value of an input element changes (e.g., when typing into a text field).&lt;br&gt;
 focus: This occurs when an element receives focus (e.g., by clicking on an input field).&lt;br&gt;
 blur: This occurs when an element loses focus (e.g., clicking away from an input field).&lt;br&gt;
 change: This occurs when the value of a form element changes (e.g., selecting a different option in a dropdown).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Document and Window Events&lt;br&gt;
load: This occurs when a web page or an external resource (e.g., an image) has finished loading.&lt;br&gt;
unload: This occurs when the user navigates away from a web page or closes the window.&lt;br&gt;
resize: This occurs when the browser window is resized.&lt;br&gt;
scroll: This occurs when the user scrolls the webpage.&lt;br&gt;
DOMContentLoaded: This occurs when the HTML document has been completely loaded and parsed, even if external resources (like images) are still loading.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Drag and Drop Events&lt;br&gt;
dragstart: This occurs when an element is dragged.&lt;br&gt;
dragend: This occurs when the dragging of an element is finished.&lt;br&gt;
dragenter: This occurs when a dragged element enters a drop target.&lt;br&gt;
dragleave: This occurs when a dragged element leaves a drop target.&lt;br&gt;
dragover: This occurs when a dragged element is over a drop target.&lt;br&gt;
drop: This occurs when a dragged element is dropped on a drop target.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These event types allow programmers to create interactive and responsive web applications by listening and responding or acting on the actions on the web pages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Methods Of Attaching an Event Handler to HTML Elements
&lt;/h2&gt;

&lt;p&gt;To react to an event in your browser, you attach an event handler to it. This event handler fires when the event is triggered.&lt;/p&gt;

&lt;h3&gt;
  
  
  a. Inline Event Handlers
&lt;/h3&gt;

&lt;p&gt;You can add event handlers directly to HTML elements using inline event attributes. For example:&lt;/p&gt;

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

&lt;p&gt;In this example, the 'onclick' attribute specifies that the 'alert' message should be shown on the web page when the button is clicked. While this approach is simple, it's generally not recommended for larger applications due to concerns about separation of concerns and maintainability.&lt;/p&gt;

&lt;h3&gt;
  
  
  b. DOM Level 0 Event Handlers
&lt;/h3&gt;

&lt;p&gt;You can directly assign event handler functions to DOM elements using JavaScript. For example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F650tsv6f94rpcbjnrcgi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F650tsv6f94rpcbjnrcgi.png" alt="DOM level event handlers"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This method is straightforward but allows only one event handler per event type for a given element.&lt;/p&gt;

&lt;h3&gt;
  
  
  c. addEventListener():
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;addEventListener()&lt;/code&gt; method is the preferred way to attach event handlers in modern JavaScript. It allows you to add multiple event listeners to an element, ensuring better compatibility and flexibility. For example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff4rykcdtc0oytdtg7xyn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff4rykcdtc0oytdtg7xyn.png" alt="Add event listener method"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Whenever the button is clicked, an alert message is printed to the console.&lt;/p&gt;

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

&lt;p&gt;Whenever the mouse is moved over the div, the color of the div changes to purple.&lt;/p&gt;

&lt;h2&gt;
  
  
  Removing an Event Listener
&lt;/h2&gt;

&lt;p&gt;The removeEventListener() function can be used to delete an event handler that has already been added using the addEventListener() method. For example, this would remove the changeColor event handler.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxs5ywqyk65aree878fm5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxs5ywqyk65aree878fm5.png" alt="Removing an event listener"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Removing outdated event handlers from small, basic systems is not required, but it can increase productivity for bigger, more sophisticated projects. You can also have the same button execute multiple actions under different conditions by adding or removing event handlers, which is another benefit of this feature.&lt;/p&gt;

&lt;h2&gt;
  
  
  Event objects
&lt;/h2&gt;

&lt;p&gt;There are occasions when a parameter with a name like an event, evt, or e is supplied inside an event handler function. This is referred to as the event object, and it is often supplied to event handlers to offer more functionality and details.&lt;br&gt;
An event object is a javascript object containing information about an event when triggered in the DOM.&lt;/p&gt;

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

&lt;p&gt;In the code snippet above, notice the event type has changed to "keydown" meaning a key must be pressed to trigger this event.&lt;/p&gt;

&lt;p&gt;Here you can see we are including an event object, ‘events’  in the function, and in the function we are setting the events key to q, which means the letter q has to be pressed down on the keyboard to  “console.log”  the sentence to the console.&lt;/p&gt;

&lt;p&gt;You can also get the target using the method "event.target" which is the DOM element that triggered the event.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Common methods of the event objects include:
&lt;/h3&gt;

&lt;p&gt;event.key&lt;br&gt;
event.target&lt;br&gt;
event.type&lt;br&gt;
event.preventDefault &lt;br&gt;
event.currentTarget &lt;br&gt;
event.stopPropagation &lt;br&gt;
event.stopImmediatePropagation&lt;/p&gt;

&lt;p&gt;In summary, the event object is a crucial tool for handling events in JavaScript. It provides access to specific event data and allows you to control the event's behavior using different methods.&lt;/p&gt;

&lt;h2&gt;
  
  
  Event Propagation
&lt;/h2&gt;

&lt;p&gt;Event propagation refers to the order in which events are handled as they propagate through the document object model (DOM).&lt;/p&gt;

&lt;p&gt;There are two phases of event propagation in the DOM&lt;br&gt;
a. Capturing Phase&lt;br&gt;
b. Bubbling Phase&lt;/p&gt;

&lt;h3&gt;
  
  
  a. Capturing Phase (outside to inside):
&lt;/h3&gt;

&lt;p&gt;In the capturing phase, the events start from the root of the DOM tree (window object) and move downward towards the target element. During this phase, any registered event listeners on the elements above the target element are triggered before the event reaches the target element.&lt;/p&gt;

&lt;p&gt;To specify that you want to listen for events during the capturing phase, you can pass true as the third argument to the addEventListener() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdqajvprngcad3i7d2wf9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdqajvprngcad3i7d2wf9.png" alt="syntax for capturing phase in event propagation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;let's add event propagation to our HTML elements below&lt;br&gt;
HTML&lt;br&gt;
The HTML structure contains two elements, the heading and the button. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl8r7ujhv8u07q2caenj5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl8r7ujhv8u07q2caenj5.png" alt="HTML structure for event propagation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;JavaScript&lt;br&gt;
To understand the capturing phase properly, let's add event listeners to the window and the document objects. &lt;/p&gt;

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

&lt;h4&gt;
  
  
  Output
&lt;/h4&gt;

&lt;p&gt;In the code snippet above, the button is the target, but the event propagation started from the window all the way down before getting to the target.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnojbt6fy79uh5e2lsqf2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnojbt6fy79uh5e2lsqf2.png" alt="output from the capturing phase"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the output above, the capturing phase starts from the root Dom (window) after clicking on the button (the target) and then moves downwards to the button.&lt;/p&gt;

&lt;h3&gt;
  
  
  b. Bubbling Phase (inside to outside)
&lt;/h3&gt;

&lt;p&gt;This is the opposite of the capturing phase; the events start from the target all the way up to the root Dom (window object).&lt;br&gt;
The bubbling phase is the more commonly used event propagation phase, as it often aligns with the way you structure your HTML and want events to be handled. By default, when you use addEventListener(), events are registered for the bubbling phase: &lt;br&gt;
There is no need for the third parameter because the event handler is by default in the bubbling phase.&lt;/p&gt;

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

&lt;p&gt;You can also add the third parameter, which is "false" to your code&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8mgf4vvs58jri72zemz2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8mgf4vvs58jri72zemz2.png" alt="adding the third parameter"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Still using the same HTML structure above, let's tweak our JavaScript code a bit by changing the third parameter.&lt;/p&gt;

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

&lt;p&gt;The JavaScript still has the same code; we just changed the true parameter to false. This will change the event propagation from the capturing phase (UP) to the bubbling phase (DOWN).&lt;/p&gt;

&lt;p&gt;OUTPUT&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzdn2nny83joitnapazj7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzdn2nny83joitnapazj7.png" alt="output of the bubbling phase"&gt;&lt;/a&gt;&lt;br&gt;
The event propagation started from the target (button) all the way up to the window object.&lt;/p&gt;

&lt;h2&gt;
  
  
  Event Delegation
&lt;/h2&gt;

&lt;p&gt;Event delegation allows you to attach a single event listener to a parent element that adds it to all of its present and future descendants that match a selector.&lt;/p&gt;

&lt;p&gt;HTML structure&lt;/p&gt;

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

&lt;p&gt;JavaScript&lt;/p&gt;

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

&lt;p&gt;Output&lt;/p&gt;

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

&lt;p&gt;The event listener is added to the parent element of the list, which has a class of sports, and then it adds the listener to all of its child elements. Instead of adding the event listener to each child element of sports, this can significantly reduce the number of event listeners in your application and improve performance.&lt;/p&gt;

&lt;p&gt;In conclusion, event handling plays a pivotal role in modern software development and user interface design. Whether you're developing a web application, a desktop program, or a mobile app, effectively managing and responding to events is essential for creating a seamless and interactive user experience.&lt;br&gt;
Throughout this article, we've explored the fundamental concepts of event handling, including event types, event listeners, event propagation, and event delegation. We've also discussed best practices for event handling, such as using event delegation to improve performance and maintainability and ensuring accessibility by providing keyboard and screen reader support.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Objects in JavaScript: A Comprehensive Look</title>
      <dc:creator>Akinnimi Stefan Emmanuel</dc:creator>
      <pubDate>Thu, 31 Aug 2023 18:29:24 +0000</pubDate>
      <link>https://dev.to/akinnimimanuel/objects-in-javascript-a-comprehensive-look-2ikf</link>
      <guid>https://dev.to/akinnimimanuel/objects-in-javascript-a-comprehensive-look-2ikf</guid>
      <description>&lt;p&gt;Objects are everywhere in JavaScript. They are super-important and there is so much you can do with them.&lt;br&gt;
Objects are core data structures in JavaScript. &lt;br&gt;
An object is a super important data structure because it is used to reflect real-world entities. They allow us to apply real-world logic to coding. They are data structures that are made up of properties(key: value) and methods.&lt;/p&gt;
&lt;h2&gt;
  
  
  Examples of real-world Objects with properties and methods
&lt;/h2&gt;

&lt;p&gt;An example of a real-life object is a bank account. A bank account has properties like balance and methods like withdrawal and deposit.&lt;br&gt;
Another example is a car, which has properties like car color, make, model, and methods like car start, car brake, and car drive.&lt;/p&gt;
&lt;h2&gt;
  
  
  Differences Between Properties and Methods in JavaScript
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Properties
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;They are variables in an object&lt;/li&gt;
&lt;li&gt;Data are stored in a property&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Methods
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;They are functions in an object&lt;/li&gt;
&lt;li&gt;Actions are stored in methods&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can store, operate with, and send data across a network with JavaScript objects. You can store comprehensive, composite, and sophisticated data in objects.&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating New Objects
&lt;/h2&gt;
&lt;h3&gt;
  
  
  1. Using Object Initializers
&lt;/h3&gt;

&lt;p&gt;Creating an object is relatively easy. To create an object, all you need is a set of curly braces &lt;code&gt;{ }&lt;/code&gt; and within that, you have to write &lt;code&gt;key: value&lt;/code&gt; pairs separated with a comma &lt;code&gt;,&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4xltlugdns38st4u8wrj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4xltlugdns38st4u8wrj.png" alt="Creating an object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Using the constructor function
&lt;/h3&gt;

&lt;p&gt;Alternatively, you can create an object by writing a constructor function and then creating an instance of the object with the 'new' keyword.&lt;/p&gt;

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

&lt;p&gt;Notice the use of the 'this' keyword to assign values to the object property based on the value of the object passed to the function.&lt;/p&gt;

&lt;p&gt;This statement creates Mydetails and assigns it the specified values for its properties. Then the value of&lt;br&gt;
 Mydetails.Surname is the string "Akinnimi", &lt;br&gt;
 Mydetails.FirstName is the string "Stefan", &lt;br&gt;
 Mydetails.Age is the integer 20. &lt;br&gt;
 My.details.FavouriteColor is the string “blue”&lt;/p&gt;

&lt;p&gt;NOTE: Arguments and parameters should be given in the same sequence.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4x2uqurt515qny8h2zt4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4x2uqurt515qny8h2zt4.png" alt="console output"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Adding Items to an Object
&lt;/h2&gt;

&lt;p&gt;To add items to an object in JavaScript, you select the properties of the object and then assign a value to it using the equal sign.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftmlhfju29dij155ho4dr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftmlhfju29dij155ho4dr.png" alt="Adding Items to an object"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw22ktofu77f13l9tsu9b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw22ktofu77f13l9tsu9b.png" alt="console output"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Deleting Items in an Object
&lt;/h2&gt;

&lt;p&gt;To delete an item in an object, you will use the delete keyword, followed by the object name and properties. This will remove the selected object properties and values from the object.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4k4krfa3wa69lv86clbe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4k4krfa3wa69lv86clbe.png" alt="Deleting an item from an object"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
Surname and Age have been removed from the object.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr5gwgo9lcknhxrny5au0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr5gwgo9lcknhxrny5au0.png" alt="console output of the deleted object items"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Accessing Items In an Object
&lt;/h2&gt;

&lt;p&gt;Should you require access to any of the object's properties? A property's 'key' can be used to gain access to its value. The properties of the object can be accessed in one of two ways:&lt;/p&gt;
&lt;h3&gt;
  
  
  Dot Notation
&lt;/h3&gt;

&lt;p&gt;The name of the object and the name of the property are separated with a dot sign.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3fwfdq8c6z8794sx4qa8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3fwfdq8c6z8794sx4qa8.png" alt="Dot notation"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  The bracket notation
&lt;/h3&gt;

&lt;p&gt;You can use bracket notation to replace the dot(&lt;code&gt;.&lt;/code&gt;) with square brackets &lt;code&gt;[ ]&lt;/code&gt; and then convert the &lt;code&gt;key&lt;/code&gt; name to a &lt;code&gt;string&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5zg2oklvogpb71tjxiu1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5zg2oklvogpb71tjxiu1.png" alt="Bracket Notation"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Nested objects or Arrays
&lt;/h2&gt;

&lt;p&gt;A nested object is one that is contained within another object. An Array can also be nested inside an object.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fslqpfhgox3oop5vak7yt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fslqpfhgox3oop5vak7yt.png" alt="Nesting an array and object inside of another object"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example above, you will notice we have an array called ‘Hobbies’ and another object called ‘Networth’ nested in the ‘Myobject’ object.&lt;/p&gt;
&lt;h2&gt;
  
  
  Copying an Object Using the Spread Operator
&lt;/h2&gt;

&lt;p&gt;Objects can also be deep copied to another variable by using the spread operator.&lt;br&gt;
After copying an object, you can proceed to add or delete the items inside the copied objects; the items won't be deleted from the object where they were copied.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Futcg8pmakk8nlamv14un.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Futcg8pmakk8nlamv14un.png" alt="Copying an Object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Object methods
&lt;/h2&gt;

&lt;p&gt;Creating functions inside of objects is referred to as creating methods in JavaScript.&lt;/p&gt;

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

&lt;p&gt;NOTE: The 'this' keyword used in the method is a way of calling the parent object.&lt;br&gt;
The ‘this’ keyword is referring to the MyObject in this case. Is just like saying,&lt;br&gt;
MyObject.Surname + ' ' + MyObject.FirstName for the first method&lt;br&gt;
OR&lt;br&gt;
Myobject.Networth.assets  -  Myobject.Networth.Liability for the second method&lt;/p&gt;

&lt;p&gt;You can invoke or call a function (method) in an object after creating it by using the dot notation and an empty parenthesis.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fop8aa7eq62gh4wllator.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fop8aa7eq62gh4wllator.png" alt="calling a method in an object"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Object destructuring (ES6)
&lt;/h2&gt;

&lt;p&gt;Object destructuring, a useful feature of JavaScript, allows you to extract properties from objects and bind them to variables. The order in which you arrange the properties does not matter, but the key matters. &lt;/p&gt;

&lt;p&gt;It is capable of extracting many properties in one statement, accessing properties from nested objects, and setting a default value in the absence of a property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Syntax
const { property } = object; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;In the above example, Line 14 will throw an error because FavoriteColor is not part of the properties of MyObjects, which were destructured, i.e., FavoriteColor was not destructured.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Objects serve as a building block for structuring and organizing data in JavaScript.&lt;br&gt;
An object is very powerful, it enables a developer to create real-life scenarios with code. As you continue your journey in JavaScript, the insights gained from this introduction to objects will serve as a solid foundation upon which you can build more complex and innovative applications.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>newbie</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Introduction To Python Programming - part 5</title>
      <dc:creator>Akinnimi Stefan Emmanuel</dc:creator>
      <pubDate>Tue, 15 Aug 2023 15:28:34 +0000</pubDate>
      <link>https://dev.to/akinnimimanuel/introduction-to-python-programming-2ol9</link>
      <guid>https://dev.to/akinnimimanuel/introduction-to-python-programming-2ol9</guid>
      <description>&lt;p&gt;Hello, and welcome to the last part of the series “Introduction to Python Programming.” If you have gone through the series chronologically, you are now on your way to becoming a Python Ninja.&lt;/p&gt;

&lt;p&gt;If you have not gone through the previous episode, kindly find the links below.&lt;br&gt;
&lt;a href="https://dev.to/akinnimimanuel/introduction-to-python-programming-1ie2"&gt;Introduction to Python Programming - part one&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/akinnimimanuel/introduction-to-python-programming-part-2-3f36"&gt;Introduction to Python programming - part two&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/akinnimimanuel/introduction-to-python-programming-part-3-32ma"&gt;introduction to Python programming - part three&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/akinnimimanuel/introduction-to-python-programming-part-4-1d10"&gt;introduction to Python programming - part four&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Python Function
&lt;/h1&gt;

&lt;p&gt;A function only executes when called. You can supply parameters or data, to a function. As a result, a function may return data.&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating a Function
&lt;/h2&gt;

&lt;p&gt;The Python def keyword is used to define functions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def my_function():
  print("Hello World")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Calling a Function
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def my_function():
  print("Hello World")

my_function()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Arguments
&lt;/h2&gt;

&lt;p&gt;Information can be passed into functions as arguments. Add as many arguments as you like; just be sure to space them out with a comma.&lt;br&gt;
The function in the next example only takes one argument, "Myname". The function receives a name as a parameter when it is called, and uses it to print the "Hello + name":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def my_function(Myname):
  print("Hello", + Myname)

my_function("Emmanuel")
my_function("Stefan")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Parameters or Arguments?
&lt;/h2&gt;

&lt;p&gt;Both parameters and arguments can be used to describe data that is passed into a function.&lt;/p&gt;

&lt;p&gt;A parameter is listed inside the parentheses, while an argument is the value sent to the function when it is called.&lt;/p&gt;

&lt;h2&gt;
  
  
  Number of Arguments
&lt;/h2&gt;

&lt;p&gt;By default, the correct number of parameters must be used to invoke a function. In other words, you must call your function with 2 arguments, not more or less, if it needs 2 arguments.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#A function expects two arguments and gets two arguments
def my_function(FirstName, LastName):
  print(Firstname + " " + Lastname)

my_function("Emmanuel", "Akinnimi")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An error will occur if you attempt to call the function with just one or three arguments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def my_function(FitstName, LastName):
  print(Firstname + " " + Lastname)

my_function("Emmanuel")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Arbitrary Arguments, *args
&lt;/h2&gt;

&lt;p&gt;If you don't know the number of arguments your function will receive, add a * before the parameter name.&lt;br&gt;
The function will then be provided with a tuple of parameters and will have access to the parts as required:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def my_function(*colour):
  print("The colour of the ball is " + colour[2])

my_function("red", "Green", "white")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Keyword Arguments
&lt;/h2&gt;

&lt;p&gt;You can send parameters with the key = value syntax as well. The arguments' chronological arrangement is irrelevant.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def my_function(food1, food2, food3):
  print("I love eating" + food2)

my_function(food1 = "rice", food2 = "beans", food3 = "noodles")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Arbitrary Keyword Arguments, **kwargs
&lt;/h2&gt;

&lt;p&gt;If you are unclear about the number of keyword arguments your function will accept, place two asterisks before the parameter name in the function definition: **.&lt;/p&gt;

&lt;p&gt;In doing so, the function will be able to effectively access the objects after receiving a dictionary of arguments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def my_function(**city):
  print(city["city2"]+ " is located in europe")

my_function(city1 = "Lagos", city2 = "Paris", city3 = "California")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Default Parameter Value&lt;br&gt;
Without arguments, the function will use its default value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def my_function(country = "Belgium"):
  print("I am from " + country)

my_function("Nigeria")
my_function("India")
my_function()
my_function("South korea")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Passing a Tuple as an Argument
&lt;/h2&gt;

&lt;p&gt;You can supply any data type as an argument in Python (list, tuple, dictionary, strings, numbers, etc.).&lt;/p&gt;

&lt;p&gt;If a Tuple is given as an argument, for example, it will still be a Tuple when it reaches the function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def my_function(Country):
  for a in Country:
    print(a)

cities = ["New York", "London", "Cairo", "Algiers"]
my_function(cities)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Return Values
&lt;/h2&gt;

&lt;p&gt;To make sure your function return a value or data, you will use the return keyword.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def my_function(a):
  return 10 * a


print(my_function(200))
print(my_function(50))
print(my_function(98))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The pass Statement
&lt;/h2&gt;

&lt;p&gt;If your function won't contain any data, you can use the pass keyword to bypass the error Python will throw for an empty function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def myfunction():
    pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M9CaG7Ty--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j1u8ny3t3jma0en849ue.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M9CaG7Ty--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j1u8ny3t3jma0en849ue.jpg" alt="congratulations image" width="275" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations to everyone for completing this series with me. We have discussed so many things in Python, and you have written a lot of code.&lt;/p&gt;

&lt;h1&gt;
  
  
  Next step
&lt;/h1&gt;

&lt;p&gt;The beauty of Python is that it can be used in virtually all departments of programming. After this introduction to Python, you can deepen your knowledge in Python by building a lot of projects, this will help solidify what you have learnt so far. Deepen your understanding of programming concepts by learning data structures, algorithms, and design patterns. Dive into web development using frameworks like Django or Flask. Explore data science and machine learning with libraries like NumPy, Pandas, and Scikit-Learn. Venture into GUI application development using tools like PyQt or Tkinter. Learn about cloud computing with platforms like AWS or Azure. Expand your knowledge with other languages like JavaScript for front-end web development or C++ for system programming. Ultimately, your choice should align with your interests and career goals, enabling you to create innovative applications and solutions.&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Introduction To Python Programming - part 4</title>
      <dc:creator>Akinnimi Stefan Emmanuel</dc:creator>
      <pubDate>Tue, 15 Aug 2023 11:28:37 +0000</pubDate>
      <link>https://dev.to/akinnimimanuel/introduction-to-python-programming-part-4-1d10</link>
      <guid>https://dev.to/akinnimimanuel/introduction-to-python-programming-part-4-1d10</guid>
      <description>&lt;p&gt;Hello, and welcome to Part 4 of the series “Introduction to Python Programming.” If you have not gone through the previous episode, kindly find the links below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/akinnimimanuel/introduction-to-python-programming-part-3-32ma"&gt;Introduction to Python programming - part 3&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/akinnimimanuel/introduction-to-python-programming-part-2-3f36"&gt;Introduction to Python programming - part 2&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/akinnimimanuel/introduction-to-python-programming-1ie2"&gt;Introduction to Python programming - part 1&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Python If ... Else
&lt;/h1&gt;

&lt;p&gt;Python Conditions and If statements&lt;br&gt;
We can use logical operations in Python&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Equals: a == b
Not Equals: a != b
Less than: a &amp;lt; b
Less than or equal to: a &amp;lt;= b
Greater than: a &amp;gt; b
Greater than or equals to: a &amp;gt;= b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These conditions can be used in IF statements and LOOPS&lt;/p&gt;

&lt;h2&gt;
  
  
  If Statements
&lt;/h2&gt;

&lt;p&gt;We write if statements using the IF keyword&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 120
b = 2000
if b &amp;gt; a:
    print("b is greater than a")
#We used variable to check which number is greater between a and b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Indentation
&lt;/h3&gt;

&lt;p&gt;Indentation (whitespace) is very important. Without proper indentation in Python, the code will not work.&lt;br&gt;
If statement without indentation, it will raise an error.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OPn70r1n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yfeuyv5gc44q7kxk7a2n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OPn70r1n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yfeuyv5gc44q7kxk7a2n.png" alt="An image showing a proper indentation in Python&amp;lt;br&amp;gt;
Elif" width="800" height="478"&gt;&lt;/a&gt;&lt;br&gt;
fig1: An image showing a proper indentation in Python&lt;/p&gt;
&lt;h3&gt;
  
  
  Elif
&lt;/h3&gt;

&lt;p&gt;The elif keyword is used for running the second block of code after the if statements. You are simply telling Python to run this code in the elif block if the previous condition was not met.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 200
b = 200
if b &amp;gt; a:
  print("b is greater than a")
elif a == b:
  print("a and b are equal")

'''
In this example the elif code block will 
run because the IF condition is not met.
'''
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Else
&lt;/h3&gt;

&lt;p&gt;The else block will run when the two previous conditions are NOT met.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yam = 24000
Potato = 20000

if Potato &amp;gt; yam:
  print("Potato is more expensive than yam")
elif Potato == yam:
  print("The two prices are equal")
else:
  print("Yam is more expensive than potato")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As the yam price is greater than the potato price in this example, the first condition is false as well as the elif condition; therefore, we move on to the else condition and print "Yam is more expensive than potato" on the screen.&lt;br&gt;
NOTE: You can have an else block without elif&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 360
b = 120

if b &amp;gt; a:
  print("b is greater than a")
else:
  print("b is not greater than a")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Short Hand If
&lt;/h3&gt;

&lt;p&gt;If there is only one sentence that needs to be executed, it can be placed on the same line as the if statement.&lt;br&gt;
One line IF statement&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 20
b = 400

if a &amp;gt; b: print("Python is the best")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Short Hand If ... Else&lt;br&gt;
You can put both the if and else statements on the same line if you only need to execute one statement:&lt;br&gt;
One line if else statement&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 20
b = 400

print("This is awesome") if a &amp;gt; b else print("We move")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Additional else statements may appear on the same line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 200
b = 200

print("My Name is akinnimi stefan") if a &amp;gt; b else print("I love programming") if a == b else print("You will love it here also")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  And
&lt;/h2&gt;

&lt;p&gt;And is a logical operator. It is used in Python to combine and compare two conditional statements.&lt;br&gt;
Check if yam is greater than potato AND if yam is greater than onions&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yam = 4000
potato = 2500
onions = 500

if yam &amp;gt; potato or yam &amp;gt; onions:
  print("The yam is more expensive than potato and onions")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Or
&lt;/h2&gt;

&lt;p&gt;OR is a logical operator. It is used in Python to combine and compare two conditional statements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Rice = 4000
Noodles = 2500
Oats = 5000

if Rice &amp;gt; Noodles or Rice &amp;gt; Oats:
  print("The Rice is more expensive than either Noodles or Oats")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Not
&lt;/h2&gt;

&lt;p&gt;NOT is a logical operator. It is used in Python to reverse conditional results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 400
b = 2500
c = 500

if not a &amp;gt; b:
  print("a is NOT greater than b")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Nested If
&lt;/h2&gt;

&lt;p&gt;You can put an IF statements inside of another IF statements. This process is called Nesting. Just make sure to indent it properly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 900

if a &amp;gt; 850:
  print("A is Above eight-hundred")
  if a &amp;gt; 850:
    print("A is Above eight-hundred and fifty,")
  else:
    print("A is below eight-hundred.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The pass Statement
&lt;/h2&gt;

&lt;p&gt;Add the pass statement if your if statement is empty for whatever reason to avoid receiving an error. If clauses can't be left empty.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 33
b = 200

if b &amp;gt; a:
  pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Python Loops
&lt;/h1&gt;

&lt;p&gt;Python has two primitive loop commands:&lt;br&gt;
while loops&lt;br&gt;
for loops&lt;/p&gt;
&lt;h2&gt;
  
  
  The while Loop
&lt;/h2&gt;

&lt;p&gt;The while loop allows a series of statements to be executed while a condition is true.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#As long as i is less than 10, the code will continue to run.
i = 1
while i &amp;lt; 10:
  print(i)
  i += 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;NOTE: Unless you remember to increase i, the cycle will never end.&lt;/p&gt;

&lt;h3&gt;
  
  
  The break Statement
&lt;/h3&gt;

&lt;p&gt;The break statement is used to stop the loop even when the while condition is true.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Exit the loop when i is 3
i = 1
while i &amp;lt; 10:
  print(i)
  if i == 5:
    break
  i += 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The continue Statement
&lt;/h3&gt;

&lt;p&gt;The condition statement is used to stop the current iteration and continue with the next&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Continue to the next iteration if i is 10
i = 0
while i &amp;lt; 20:
  i += 1
  if i == 10:
    continue
  print(i)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The else Statement
&lt;/h3&gt;

&lt;p&gt;The else statement is used to run a block of code when the condition is no longer true.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Whenever the condition is false, print a message.
i = 1
while i &amp;lt; 10:
  print(i)
  i += 1
else:
  print("i is no longer less than ten")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Python For Loops
&lt;/h2&gt;

&lt;p&gt;The for loop allows us to run a series of instructions once for each element of a list, tuple, set, etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Print each fruit in a colour list
colours = ["red", "blue", "purple", "green"]

for x in colours:
  print(x)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Looping Through a String
&lt;/h3&gt;

&lt;p&gt;Strings are iterable objects since they are made up of a series of characters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Looping thorugh the chatracters in the word "purple"
for x in "purple":
  print(x)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The break Statement
&lt;/h3&gt;

&lt;p&gt;The loop is terminated with the break statement before it has iterated over all of the objects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Exit the loop when x is white
colours = ["red", "blue", "purple", "white", "green", "orange"]

for x in colours:
  print(x)
  if x == "white":
    break
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exit the loop when x is “white”, but this time the break comes before the print&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;colours = ["red", "blue", "purple", "white", "green", "orange"]

for x in colours:
  if x == "white":
    break
  print(x)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The continue Statement
&lt;/h3&gt;

&lt;p&gt;The continue statement is used to stop a current block of code and continue the next one&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Do not print blue
colours = ["red", "blue", "purple", "white", "green", "orange"]

for x in colours:
  if x == "blue":
    continue
  print(x)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The range() Function
&lt;/h3&gt;

&lt;p&gt;The range() function can be used to repeatedly loop through a block of code.&lt;br&gt;
The range() function returns a series of numbers that, by default, starts at 0 and increments by 1 before stopping at a predetermined value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for x in range(6):
    print(x)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;NOTE: The range in this case is not the values of 0 to 6, but the values 0 to 5&lt;/p&gt;

&lt;p&gt;The initial value for the range() function is 0 by default, but a starting value can be specified by adding a parameter: range(3, 7), which indicates values from 3 to 7 (but excluding 7):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Using the starting parameter
for x in range(3, 7):
  print(x)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By default, the range() function increases the series by 1, but a third parameter can be used to provide a different increment amount, as in range(2, 20, 2):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#The sequence will be advanced by 2 (the default is 1).
for x in range(2, 20, 2):
    print(x)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Else in For Loop
&lt;/h3&gt;

&lt;p&gt;When using a for loop, the else keyword designates a piece of code that will run after the loop has finished:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Print all numbers from 0 to 9, and print a message when the loop has ended

for x in range(10):
      print(x)
else:
  print("Finished counting!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a break statement is used to end the loop, the else block will not be executed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Break the loop when x = 5, and see what happens with the else block
for x in range(10):
  if x == 5: break
  print(x)
else:
  print("finished counting")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Nested Loops
&lt;/h3&gt;

&lt;p&gt;The ability to nest a loop inside another loop is what makes Python very powerful.&lt;br&gt;
The "inner loop" will only be executed once for each iteration of the "outer loop":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Print each colour for every fruit
colour = ["red", "green", "white"]
fruits = ["apple", "banana", "cherry"]

for x in colour:
  for y in fruits:
    print(x, y)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The pass Statement
&lt;/h3&gt;

&lt;p&gt;For some reason, if there is an empty for loop, add the pass statement to prevent an error from occurring. For loops cannot be empty.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for x in [0, 1, 2]:
  pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>python</category>
      <category>programming</category>
    </item>
    <item>
      <title>Introduction To Python Programming - part 3</title>
      <dc:creator>Akinnimi Stefan Emmanuel</dc:creator>
      <pubDate>Sat, 12 Aug 2023 14:25:28 +0000</pubDate>
      <link>https://dev.to/akinnimimanuel/introduction-to-python-programming-part-3-32ma</link>
      <guid>https://dev.to/akinnimimanuel/introduction-to-python-programming-part-3-32ma</guid>
      <description>&lt;p&gt;Hello, and welcome to Part 3 of the series “Introduction to Python Programming” If you have not gone through the previous episode, kindly find the links below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/akinnimimanuel/introduction-to-python-programming-1ie2"&gt;introduction to Python programming - part one&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/akinnimimanuel/introduction-to-python-programming-part-2-3f36"&gt;Introduction to Python programming - part two&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Boolean Values
&lt;/h2&gt;

&lt;p&gt;You can evaluate any expression in Python and get one of two answers, True or False.&lt;br&gt;
Python delivers the Boolean result after evaluating the expression when two values are being compared:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(20 &amp;gt; 10)    #returns True
print(20 == 10)   #returns False    
print(20 &amp;lt; 10)    #returns False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also check the comparison of two values with a conditional statement.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 1000
b = 100
if b &amp;gt; a:


  print("b is greater than a")


else:


print("b is not greater than a")


#prints out b is not greater than a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Evaluate Values and Variables
&lt;/h3&gt;

&lt;p&gt;You can evaluate any value using the &lt;strong&gt;bool()&lt;/strong&gt; function, and it will return either True or False.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(bool("Hello"))    #returns True
print(bool(200))        #returns True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Most Values are True
&lt;/h3&gt;

&lt;p&gt;If a value has content of any kind, it is evaluated to True almost immediately. Any string is True, except empty strings. Any number is True, except 0. Except for empty ones, every list, tuple, set, and dictionary are True.&lt;br&gt;
The following will return true:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bool("Earth")   #returns True
bool(4456)      #returns True
bool(["apple", "cherry", "banana"])    #returns True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Certain values are false. Except for empty values like (), [], " ", the number 0, and the value None, there aren't many values that evaluate to False.&lt;br&gt;
The following will be evaluated as false.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bool(False)  #returns False
bool(None)   #returns False
bool(0)      #returns False
bool("")     #returns False
bool(())     #returns False
bool([])     #returns False
bool({})     #returns False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Brace up, people, because we will be using the remaining part of this series to talk about Python data collections. They are very powerful tools at our disposal that will enable us to perform and create beautiful applications with Python. The four Python collections are&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Lists&lt;/li&gt;
&lt;li&gt;Tuple&lt;/li&gt;
&lt;li&gt;Sets&lt;/li&gt;
&lt;li&gt;Dictionary&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Python Lists
&lt;/h2&gt;

&lt;p&gt;Lists allow multiple elements to be maintained in a single variable.&lt;br&gt;
Lists are created using square brackets.&lt;br&gt;
Creating a list&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Cities = ["Sydney", "New York", "London", "Paris"]
print(cities)    #returns Sydney New York London Paris
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  List Items
&lt;/h3&gt;

&lt;p&gt;List items can have duplicate values and are ordered and changeable.&lt;br&gt;
List items are indexed; the first item has an index [0], the second item has an index [1], etc.&lt;/p&gt;
&lt;h3&gt;
  
  
  Properties of a list
&lt;/h3&gt;

&lt;p&gt;a. Lists are ordered, which means the items in a list have a defined order in which they are arranged. When a new item is added to a list, it will be placed at the end of the list.&lt;br&gt;
b. List items are changeable. You can add, or remove a list item after its creation.&lt;br&gt;
c. Lists allow duplicates of list items, i.e., you can have the same items in a list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mylist = ["Sydney", "New York,", "London", "Paris", "New York", "London"]
print(Mylist)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;d. You can determine the length of a list by using the len() function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(len(Mylist))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;e. Any data type can be used for list items:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list1 = ["carrot", "pearl", "apple"] #list string data type
list2 = [10, 5, 2, 400, 3] #numeric list data type
list3 = [True, False, False] #boolean list data type
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;f. A list can contain different data types:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list1 = ["Hello", 600, False, 100, "male"]    
#list with strings,numeric and boolean data types.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;g. List() constructor: We can also use the list() constructor to create a new list instead of the square bracket.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;thislist = list(("apple", "samsung", "xiaomi")) 
# note the double round-brackets
print(thislist)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;h. Finding items on a list: You can access list items by using the index number, which is listed with each item:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Printing the third item on the list
thislist = ["apple", "samsung", "xiaomi"]
print(thislist[2]) #returns Xiaomi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;NOTE: the first number has an index number of 0&lt;/p&gt;

&lt;h3&gt;
  
  
  Negative Indexing
&lt;/h3&gt;

&lt;p&gt;Negative indexing means starting from the end&lt;br&gt;
The last and next-to-last items are indicated by the numerals -1 and -2, respectively.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Printing out the last item of a list
thislist = ["apple", "samsung", "xiaomi"]
print(thislist[-1]) #returns xiaomi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Range of Indexes
&lt;/h3&gt;

&lt;p&gt;You can provide a range of indexes by indicating the range's beginning and ending points.&lt;br&gt;
A new list containing the requested items will be returned when a range is specified.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Return the third, fourth, and fifth item in the list
thislist = ["apple", "samsung", "xiaomi", "blackberry", "Nokia", "Tecno", "sony"]
print(thislist[2:5]) #returns xiaomi, blackberry and nokia
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the start value is omitted, the range will begin with the first item:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;thislist = ["apple", "samsung", "xiaomi", "blackberry", "Nokia", "Tecno", "sony"]
print(thislist[:4])
#This code returns the items from the beginning but will exclude Nokia
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The range will continue to the end of the list if the end value is omitted:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;thislist = ["apple", "samsung", "xiaomi", "blackberry", "Nokia", "Tecno", "sony"]
#This code returns the items from “xiaomi” to the end
print(thislist[2:])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Range of Negative Indexes
&lt;/h3&gt;

&lt;p&gt;If you want to start the search at the end of the list, enter negative indexes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;thislist = ["apple", "Samsung", "Xiaomi", "blackberry", "Nokia", "Tecno", "Sony"]
#This code returns the items from “blackberry” (-4) to, but NOT including “sony” (-1)

print(thislist[-4:-1])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Python Tuples
&lt;/h2&gt;

&lt;p&gt;A tuple is a collection that is ordered and unchangeable.&lt;br&gt;
Tuples are written in round brackets.&lt;/p&gt;

&lt;p&gt;Creating a tuple&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;thistuple = ("java", "javascript", "python")
print(thistuple)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Tuple Items
&lt;/h3&gt;

&lt;p&gt;Duplicate values are permitted for tuple items, which are ordered and immutable.&lt;br&gt;
The first item in a tuple is indexed [0], and the second item is indexed [1], etc. The major difference between a list and a tuple, apart from how they are created, is that a list item can be changed, but a tuple item can't be changed.&lt;/p&gt;

&lt;p&gt;To determine the tuple length, the &lt;strong&gt;len()&lt;/strong&gt; function is also used.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(len(thistuple))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python will not recognize a single item as a tuple unless you add a comma after the item to make it a tuple.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;thistuple = ("apple",)
print(type(thistuple))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Data types:
&lt;/h3&gt;

&lt;p&gt;Any data type can be used for tuples. A tuple can contain numeric, string, or boolean values&lt;/p&gt;

&lt;h3&gt;
  
  
  The tuple() Constructor
&lt;/h3&gt;

&lt;p&gt;Like a list, it is also possible to use the tuple() constructor to make a tuple.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Using the tuple constructor to make a tuple
thistuple = tuple(("newyork", "lagos", "capetown"))
# note the double round-brackets
print(thistuple)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Set
&lt;/h2&gt;

&lt;p&gt;Sets are written with curly brackets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;thisset = {"apple", "banana", "cherry"}
print(thisset)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sets are unordered, so you cannot be sure in which order the items will appear&lt;/p&gt;

&lt;h3&gt;
  
  
  Set Items
&lt;/h3&gt;

&lt;p&gt;Set items don't allow duplicate values, are unsorted, and can't be changed.&lt;/p&gt;

&lt;p&gt;Set  items can be of any data type, and a set can contain different data types&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set1 = {"Europe", 324, True, 460, "male"}
print(set1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The set() Constructor
&lt;/h3&gt;

&lt;p&gt;It is also possible to use the set() constructor to make a set.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;thisset = set(("apple", "mango", "pineaple")) 
#note the double round-brackets
print(thisset)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Python Dictionaries
&lt;/h2&gt;

&lt;p&gt;Python dictionaries make use of key: value pair storage for storing their data.&lt;br&gt;
A dictionary is ordered, the items can be changed, and it doesn't allow duplicates of items.&lt;br&gt;
The key: value pairs of data are wrapped inside a curly bracket.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Creating a dictionary
thisdict = {
“Brand”: “Apple”,
“Model”: “Macbook pro”
“Year”: 2023
}
print(thisdict)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Dictionary Items
&lt;/h3&gt;

&lt;p&gt;Items in the dictionary are arranged, editable, and do not permit duplication.&lt;br&gt;
Key: value pairs are used to exhibit dictionary entries, and the key name can be used to refer to a particular entry.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Print the “model” value of the dictionary
thisdict = {
“Brand”: “Apple”,
“Model”: “macbook pro”
“Year”: 2023
}
print(thisdict["brand"])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Dictionary Length
&lt;/h3&gt;

&lt;p&gt;Use the &lt;strong&gt;len()&lt;/strong&gt; function to find out how many items a dictionary has.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data type in Dictionary
&lt;/h3&gt;

&lt;p&gt;Items in dictionaries may have values of any data type.&lt;/p&gt;

&lt;h3&gt;
  
  
  The dict() Constructor
&lt;/h3&gt;

&lt;p&gt;We can also use the dict() constructor to create a dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Using the dict constructor to make a dictionary
thisdict = dict(name = "Akinnimi", age = 27, country = "Nigeria")
print(thisdict)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  SUMMARY OF THE DIFFERENCES BETWEEN THE FOUR PYTHON DATA TYPE COLLECTIONS
&lt;/h2&gt;

&lt;p&gt;Lists, tuples, sets, and dictionaries are all different types of data structures in Python, each with their own unique properties:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Lists:
Mutable: After creation, elements may be added, deleted, or updated.
Ordered: Elements keep the order in which they were inserted.
Allows elements to be duplicated.&lt;/li&gt;
&lt;li&gt;Tuples
Immutable: Once created, an element cannot be altered.
Ordered: Like lists, elements keep the order in which they were inserted.
allows elements to be duplicated.&lt;/li&gt;
&lt;li&gt;Sets:
Mutable: After creation, elements can be added or removed.
Unordered: There is no innate order in the elements.
prohibits the use of elements twice.&lt;/li&gt;
&lt;li&gt;Dictionary
Mutable: After creation, key-value pairs may be added, changed, or eliminated.
Unordered: Prior to Python 3.7, there was no assurance of order for dictionaries. Insertion order is preserved in Python 3.7 and beyond.
Keys must be unchangeable and distinct.
Values may include duplicate values and be of any type.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In conclusion, dictionaries are collections of key-value pairs with the option of order preservation, sets are unordered collections of unique components, and lists are flexible and ordered collections. Tuples are similar to lists but immutable.&lt;/p&gt;

&lt;p&gt;There is a whole lot we can still do with the four data structures; I will recommend you read more about them in the official Python documentation.  &lt;/p&gt;

&lt;p&gt;&lt;a href="//docs.python.org"&gt;Python official documentation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Introduction To Python Programming - part 2</title>
      <dc:creator>Akinnimi Stefan Emmanuel</dc:creator>
      <pubDate>Wed, 09 Aug 2023 16:48:59 +0000</pubDate>
      <link>https://dev.to/akinnimimanuel/introduction-to-python-programming-part-2-3f36</link>
      <guid>https://dev.to/akinnimimanuel/introduction-to-python-programming-part-2-3f36</guid>
      <description>&lt;p&gt;Hello, and welcome to Part Two of the series “Introduction to Python Programming.” If you have not gone through the previous episode, kindly find the link below to part one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/akinnimimanuel/introduction-to-python-programming-1ie2"&gt;Introduction to Python programming - part one&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Python Variables
&lt;/h1&gt;

&lt;p&gt;Variables are containers for storing data values.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Variables
&lt;/h3&gt;

&lt;p&gt;Python has no command for declaring a variable. You just need the equals to ‘=’ sign to assign a variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Name = "Akinnimi"
Age = 20
print(age) #retuns 20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unlike some other programming languages, variables in Python can change after they have been set.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = 200        # x is of type int
x = "Stefan"   # x is now of type str

print(x)       #returns Stefan 
               #x will overwrite x

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Casting
&lt;/h3&gt;

&lt;p&gt;You can change the data type of a particular variable by &lt;br&gt;
typecasting it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = str(6)    # a will be '6'
b = int(6)    # b will be 6
c = float(6)  # c will be 6.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Case-Sensitive
&lt;/h3&gt;

&lt;p&gt;Variable names are case-sensitive.&lt;/p&gt;

&lt;p&gt;This will create two variables&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 4
A = "Sally"

#A will not overwrite a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Comments
&lt;/h3&gt;

&lt;p&gt;To make comments in Python, the &lt;strong&gt;#&lt;/strong&gt; symbol is placed in front of the sentence. Python reads and ignores the sentence.&lt;/p&gt;

&lt;p&gt;The purpose of comments is for code documentation. It can also be used to explain what a particular code is doing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#printing out Hello World!
print("Hello, World!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Multiline Comments
&lt;/h3&gt;

&lt;p&gt;To add a multi-line comment, you could insert a &lt;strong&gt;#&lt;/strong&gt; for each line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#This is a comment
#written in
#more than just one line

print("Hello, World!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use a multiline string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"""
Writing out my first Python program

Printing out Hello World!

This is going to be fun

"""
print("Hello, World!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python will read the code but ignore it if the text is not assigned to a variable, and you have written a multiline comment.&lt;/p&gt;

&lt;h1&gt;
  
  
  Python Data Types
&lt;/h1&gt;

&lt;p&gt;Data types in Python specify the kind of value a variable can hold.&lt;/p&gt;

&lt;p&gt;Python has several built-in data types:&lt;/p&gt;

&lt;p&gt;a. Numeric Types:&lt;/p&gt;

&lt;p&gt;int: Integers, e.g., 5, -10.&lt;/p&gt;

&lt;p&gt;float: Floating-point numbers, e.g., 3.14, -0.5.&lt;/p&gt;

&lt;p&gt;b. Text Type:&lt;/p&gt;

&lt;p&gt;str: Strings, e.g., "Hello, World!".&lt;/p&gt;

&lt;p&gt;c. Boolean Type:&lt;/p&gt;

&lt;p&gt;Boolean values are TRUE or FALSE&lt;/p&gt;

&lt;p&gt;d. Sequence Types:&lt;/p&gt;

&lt;p&gt;list: Ordered, mutable collections, e.g., [1, 2, 3].&lt;/p&gt;

&lt;p&gt;tuple: Ordered, immutable collections, e.g., (1, 2, 3).&lt;/p&gt;

&lt;p&gt;e. Mapping Type:&lt;/p&gt;

&lt;p&gt;dict: Key-value mappings, e.g., {'name': 'Alice', 'age': 30}.&lt;/p&gt;

&lt;p&gt;f. Set Types:&lt;/p&gt;

&lt;p&gt;set: Unordered, variable collections of one-of-a-kind elements.&lt;/p&gt;

&lt;p&gt;frozen set: Unordered, immutable groupings of distinct components.&lt;/p&gt;

&lt;p&gt;g. Binary Types:&lt;/p&gt;

&lt;p&gt;bytes: Unchangeable sequences of bytes, such as b'programming'.&lt;/p&gt;

&lt;p&gt;bytearray: Mutable sequences of bytes.&lt;/p&gt;

&lt;p&gt;memoryview: Provides a view into the memory of an object supporting the buffer protocol.&lt;/p&gt;

&lt;p&gt;h. Custom Types:&lt;/p&gt;

&lt;p&gt;User-defined classes and objects.&lt;/p&gt;

&lt;p&gt;i. Special Types:&lt;/p&gt;

&lt;p&gt;NoneType: Represents the absence of a value, denoted by None.&lt;/p&gt;

&lt;h2&gt;
  
  
  Python Numbers
&lt;/h2&gt;

&lt;p&gt;There are three numeric types in Python:&lt;/p&gt;

&lt;p&gt;int&lt;/p&gt;

&lt;p&gt;float&lt;/p&gt;

&lt;p&gt;complex&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 50     # int
b = 3.5    # float
C = 18j    #complex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Get the type
&lt;/h3&gt;

&lt;p&gt;In Python, use the &lt;strong&gt;type()&lt;/strong&gt; method to determine the type of any object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(type(a))   #returns &amp;lt;class 'int'&amp;gt;

print(type(b))   #returns &amp;lt;class 'float'&amp;gt;

print(type(c))   #returns &amp;lt;class 'complex'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Int
&lt;/h3&gt;

&lt;p&gt;An integer is a whole number, positive or negative, with no digits and an infinite length.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 5
b = 4566677788889
c = -456667

print(type(a))    #returns &amp;lt;class 'int'&amp;gt;

print(type(b))    #returns &amp;lt;class 'int'&amp;gt;

print(type(c))    #returns &amp;lt;class 'int'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Float
&lt;/h3&gt;

&lt;p&gt;A float, often known as a "floating point number," is a positive or negative number with one or more decimals.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 1.20
b = 2.5
c = -50.8

print(type(a))    #returns &amp;lt;class 'float'&amp;gt;

print(type(b))    #returns &amp;lt;class 'float'&amp;gt;

print(type(c))    #returns &amp;lt;class 'float'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Complex
&lt;/h3&gt;

&lt;p&gt;Complex numbers are denoted by a "j" as the imaginary part:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 16+5j
b = 3j
c = -10j

print(type(a)) #returns &amp;lt;class 'complex'&amp;gt;

print(type(b))    #returns &amp;lt;class 'complex'&amp;gt;

print(type(c))    #returns &amp;lt;class 'complex'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Type Conversion
&lt;/h3&gt;

&lt;p&gt;You can convert from one type to another with the int() and float() methods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 5    # int
b = 5.3  # float
c = -10j #complex

#convert from int to float:

x = float(a)

#convert from float to int:

y = int(b)

#convert from int to complex:
z = complex(a)

#printing out their values
print(x)  #returns 5.0
print(y) #returns 5
print(z) #returns (-0-10j)

#checking their data type
print(type(x))    #returns &amp;lt;class 'int'&amp;gt;
print(type(y))    #returns &amp;lt;class 'float'&amp;gt;
print(type(z))    #returns &amp;lt;class 'complex'&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Python Strings
&lt;/h2&gt;

&lt;p&gt;In Python, strings are wrapped by either single or double quotation marks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;‘world’ is the same as "world".
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using the print() function, you can display a string literal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("Hello")    #returns Hello
print('Hello')    #returns Hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Assign String to a Variable&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = "Hello"
print(a)    #returns Hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Multiline Strings
&lt;/h3&gt;

&lt;p&gt;Using three quotes, you can assign a multiline string to a variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = """ Lorem derrym dssaawe ddfrty,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt."""

print(a)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or three single quotes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = ' ' ' Lorem derrym dssaawe ddfrty,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt.' ' '

print(a)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  String Length
&lt;/h3&gt;

&lt;p&gt;Use the &lt;strong&gt;len()&lt;/strong&gt; method to determine the length of a string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = "Hello, World!"
print(len(a))    #returns 13 
#you will notice the whitespace between the Hello World is also counted.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  String Concatenation
&lt;/h3&gt;

&lt;p&gt;To concatenate or combine two strings, use the + operator.&lt;/p&gt;

&lt;p&gt;Merging two variables together with the + sign&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = "Hello"
b = "World"
c = a + b

print(c)    #returns HelloWorld

#notice there is no space in between the hello world. 
#We will solve that in the next section.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To add space between the Hello World, add two “ “&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;first_name = "Emmanuel"
Last_name = "Akinnimi"
My_name =first_name  + " " + Last_name

print(My_name)    #returns Emmanuel Akinnimi
                  #space is now added
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Modifying Strings
&lt;/h3&gt;

&lt;p&gt;To modify a string, you have to call a string method on it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;strip() #removes whitespace in strings
capitalize()  #Converts the first letter of each word to capital letter 
upper() #converts all the letters in the word to capital case.
lower() #converts all the letters in the word to lowercase.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Name = “akinnimi stefan”
print(Name.capitalize()) #returns Akinnimi Stefan
print(Name.upper()) #returns AKINNIMI STEFAN
print(Name.lower()) #returns akinnimi stefan

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Check String
&lt;/h3&gt;

&lt;p&gt;We can use the method &lt;strong&gt;IN&lt;/strong&gt; to see if a specific phrase or character is contained in a string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;favorite= "My favorite food is mash potatoes"
print("food" in Favorite )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Python: Escape Characters
&lt;/h3&gt;

&lt;p&gt;Use an escape character to insert characters that are not allowed into a string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"""You will get an error when nesting double 
quotes inside another double quote.
"""
txt = “I am going to the “stadium” to watch the football match”
print(txt)   #returns an error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The solution is to use the \ backlash before the illegal character is inserted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;txt = “I am going to the \“stadium\” to watch the football match”
print(txt)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Escape Characters
&lt;/h3&gt;

&lt;p&gt;Other escape characters used in Python:&lt;/p&gt;

&lt;p&gt;Code                           Result&lt;/p&gt;

&lt;p&gt;\'                             Single Quote&lt;/p&gt;

&lt;p&gt;\                              Backslash&lt;/p&gt;

&lt;p&gt;\n                             New Line&lt;/p&gt;

&lt;p&gt;\t                             Tab&lt;/p&gt;

&lt;p&gt;\b                             Backspace&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
      <category>python3</category>
    </item>
    <item>
      <title>Introduction To Python Programming - part 1</title>
      <dc:creator>Akinnimi Stefan Emmanuel</dc:creator>
      <pubDate>Mon, 31 Jul 2023 14:51:06 +0000</pubDate>
      <link>https://dev.to/akinnimimanuel/introduction-to-python-programming-1ie2</link>
      <guid>https://dev.to/akinnimimanuel/introduction-to-python-programming-1ie2</guid>
      <description>&lt;p&gt;Python is a popular, high-level, general-purpose programming language. Guido van Rossum invented it in 1991, and the Python Software Foundation continued to advance it. &lt;br&gt;
Because of its syntax, which was developed with code readability in mind, programmers may be able to express their ideas in fewer lines of code.&lt;br&gt;
Python is a computer language that facilitates rapid development and more efficient system integration.&lt;br&gt;
Python 2 and Python 3 are the two most popular versions. Both are different.&lt;/p&gt;

&lt;h2&gt;
  
  
  Beginning with Python programming:
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Finding an Interpreter:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Using an Integrated Development Environment ( IDLE)
Before we start Python programming, we need an interpreter to convert and execute our programs. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Windows: The Python software downloaded from &lt;a href="http://python.org"&gt;http://python.org&lt;/a&gt; comes with IDLE (Integrated Development Environment), one of many free interpreters that can be used to run Python scripts.&lt;/p&gt;

&lt;p&gt;Linux: Python is preinstalled on many Linux distributions, including Fedora and Ubuntu. Type "python" in the terminal emulator to see what version of Python you're using. When it launches, the interpreter should print the version number.&lt;/p&gt;

&lt;p&gt;Python 2.7 is typically preinstalled on macOS. Python 3 must be manually installed from &lt;a href="http://python.org"&gt;http://python.org&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Open the command line and enter Python --version to see if Python is installed on your computer. This will display the Python version that is currently installed on your computer. &lt;br&gt;
If any other message apart from that shows, then Python is not installed on your device. You’ll have to install Python manually from &lt;a href="http://python.org/"&gt;http://python.org/&lt;/a&gt;. &lt;br&gt;
Follow my other article, where I walk you through the process of installing Python on a Windows computer.&lt;br&gt;
&lt;a href="https://dev.to/akinnimimanuel/python-installation-guide-for-windows-11-o48"&gt;Python installation guide for Windows 11&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using a code editor 
Alternatively to an IDLE or an interpreter (command line), Python codes can also be written in a code editor. 
Code editors are applications used for writing, editing, and executing Python code. Examples are Visual studio code, PyCharm, Sublime text, Atom, etc. 
For the remainder of this tutorial, I will use Visual Studio Code as my code editor for Python programming. You can easily download and install Visual Studio Code on their official website.
&lt;a href="https://code.visualstudio.com/download"&gt;Download Visual Studio Code&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1jMM46hL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8vfhhi9fohkrtvd5m4tk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1jMM46hL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8vfhhi9fohkrtvd5m4tk.png" alt="Official website of visual studio code" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 1a: Official website of visual studio code&lt;/p&gt;

&lt;h3&gt;
  
  
  Writing our first program:
&lt;/h3&gt;

&lt;p&gt;Step 1: After downloading the VSC editor, open the code editor and click on the three dashes at the top left.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yf4gSP5---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dfc6zmj7m1y5u2i9ydze.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yf4gSP5---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dfc6zmj7m1y5u2i9ydze.png" alt="A diagram displaying the VSC editor's user interface" width="557" height="411"&gt;&lt;/a&gt;&lt;br&gt;
Fig 1b: A diagram displaying the VSC editor's user interface&lt;/p&gt;

&lt;p&gt;Step 2: Click on the file and then the new file to name your first Python file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lUOrir67--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8dddh7u1knspf71g2b92.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lUOrir67--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8dddh7u1knspf71g2b92.png" alt="A diagram displaying the VSC editor's user interface" width="800" height="441"&gt;&lt;/a&gt;&lt;br&gt;
Fig. 1c: A diagram displaying the VSC editor's user interface&lt;/p&gt;

&lt;p&gt;Step 3: You can use any naming scheme for your file, but make sure it ends with .Py extension.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BxZOLMY6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vg46yvkr2nxv8upac3k4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BxZOLMY6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vg46yvkr2nxv8upac3k4.png" alt="A diagram displaying the VSC editor's user interface" width="800" height="451"&gt;&lt;/a&gt;&lt;br&gt;
Fig. 1d: A diagram displaying the VSC editor's user interface&lt;/p&gt;

&lt;p&gt;Step 4: Just type in the following code after naming your Python file: The codes shown below will be explained later in this tutorial &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iEOdAbUZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q7t5qn3sbsphal4m36vl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iEOdAbUZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q7t5qn3sbsphal4m36vl.png" alt="Python codes written in the Visual Studio code editor" width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig. 1e: Python codes written in the Visual Studio code editor&lt;/p&gt;

&lt;p&gt;Line 1: print(‘hello, world’) &lt;br&gt;
Line 2: print(‘Python is awesome and simple’)&lt;br&gt;
Line 3: print(‘My name is Akinnimi Stefan’)&lt;br&gt;
NOTE: I used single quotes here  ' '; you can also use       double" " quotes. But for consistency, you need to choose one and stick to it.&lt;br&gt;
To print something on the console, the print() function is used.&lt;/p&gt;

&lt;p&gt;Step 5: Executing or interpreting the code&lt;br&gt;
After typing in the codes, the next step is for you to click on the Run Python File button in the upper-right corner of the editor.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tsRAWQZ3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mglityoy46u1x8mr9rha.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tsRAWQZ3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mglityoy46u1x8mr9rha.png" alt="Executing our first Python program" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig. 1f: Executing our first Python program&lt;/p&gt;

&lt;p&gt;Step 6: A Terminal will open (similar to the command line on a Windows or Mac OS laptop), your program will be executed, and the results will be shown as seen below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R_rgKnNz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hs78pzliatmctffdr5je.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R_rgKnNz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hs78pzliatmctffdr5je.png" alt="A diagram showing the output of the first Python program" width="800" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig. 1f: A diagram showing the output of the first Python program&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
The output of Line 1 - Hello World.&lt;br&gt;
The output of Line 2 -  Python is awesome and simple.&lt;br&gt;
The output of line 3 - My name is Akinnimi Stefan&lt;/p&gt;

&lt;p&gt;Congratulations! &lt;br&gt;
Your first Python program has been created and run successfully.&lt;/p&gt;

&lt;h2&gt;
  
  
  Python Syntax
&lt;/h2&gt;

&lt;p&gt;Syntax means rules that govern the use of a particular programming language. &lt;br&gt;
The print Program&lt;br&gt;
The print() function prints the specified message to the screen or other standard output device.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fYhHyoXE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/icw7d0qsd1zu6ui5bmoq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fYhHyoXE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/icw7d0qsd1zu6ui5bmoq.png" alt="Python codes written in the visual studio code editor" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig. 2a: Python codes written in the visual studio code editor&lt;/p&gt;

&lt;h2&gt;
  
  
  Python Indentation
&lt;/h2&gt;

&lt;p&gt;Indentation is the term used to describe the spaces at the start of a code line.&lt;br&gt;
Whereas in other programming languages, the indentation in code is for readability only, the indentation in Python is significant.&lt;br&gt;
A block of code is identified in Python through indentation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KCt2VQMV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0gc9k8ooelnjffn2r4ub.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KCt2VQMV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0gc9k8ooelnjffn2r4ub.png" alt="A diagram showing the indentation" width="800" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig. 2b: A diagram showing the indentation (four spaces or two tabs).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KDtrR0yK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bzjaomiy1mc41jynnvil.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KDtrR0yK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bzjaomiy1mc41jynnvil.png" alt="Output of a successfully written Python code with indentation" width="800" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig. 2c: Output of a successfully written Python code with indentation&lt;/p&gt;

&lt;p&gt;NOTE: If you omit the indentation, Python will throw an error as seen in the image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D9P1K4At--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iwcgh71ac2q0siobq1dk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D9P1K4At--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iwcgh71ac2q0siobq1dk.png" alt="Visual Studio Code showing an error because of the absence of a proper indentation" width="800" height="431"&gt;&lt;/a&gt;&lt;br&gt;
Fig. 2d: Visual Studio Code showing an error because of the absence of a proper indentation&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---UsHe1lM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0y8xvqew2pc7rbjxgxqg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---UsHe1lM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0y8xvqew2pc7rbjxgxqg.png" alt="Output of an executed Python program without proper indentation " width="800" height="196"&gt;&lt;/a&gt;&lt;br&gt;
Fig. 2e: Output of an executed Python program without proper indentation &lt;/p&gt;

&lt;p&gt;As a programmer, you can choose the number of spaces; the most usual use is four, although there must be at least one.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Python Installation Guide For Windows 11</title>
      <dc:creator>Akinnimi Stefan Emmanuel</dc:creator>
      <pubDate>Wed, 26 Jul 2023 23:45:37 +0000</pubDate>
      <link>https://dev.to/akinnimimanuel/python-installation-guide-for-windows-11-o48</link>
      <guid>https://dev.to/akinnimimanuel/python-installation-guide-for-windows-11-o48</guid>
      <description>&lt;p&gt;You should first make sure Python is correctly installed and added to the environment's path variable before attempting to run any Python programs on your Windows operating system.&lt;/p&gt;

&lt;p&gt;I'll demonstrate how to verify if Python is installed for you in this article. If not, I will also demonstrate how to correctly install it on Windows for you. The technique works for other versions of Windows as well, however, I'll be using Windows 11 for this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;##Step 1: How to Check if You Have Python Installed in Your Windows Operating System&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use the following command to check the Python version in CMD or PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python --version

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ojkzwgef91jqwb8g75n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ojkzwgef91jqwb8g75n.png" alt="PowerShell showing the version of python installed"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your machine can run any Python application just fine if you receive the version of Python that looks like the result above. The Python version in your situation can be different.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2m9mbx68toio3zwa0s74.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2m9mbx68toio3zwa0s74.png" alt="PowerShell showing an error message"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, if you encounter the result you see above, it could indicate any of the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You did not have Python installed on your computer, or&lt;/li&gt;
&lt;li&gt;Python's directory has not been added to the path of the &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If Python is not installed on your Windows PC, you can follow the procedure below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;##Step 2: How to Install Python on Windows&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To begin with, we must visit Python's official website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.python.org/" rel="noopener noreferrer"&gt;Python's Official website&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6rtc7x2mw7ct4xr5ky7t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6rtc7x2mw7ct4xr5ky7t.png" alt="An image showing the home page of python"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the Downloads section.&lt;/p&gt;

&lt;p&gt;This page contains the most recent version. Simply click on Python 3.11.4 Download. Python may have been updated by the time you read this article, in which case the version would be different. Just download the version that is displayed.&lt;/p&gt;

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

&lt;p&gt;Once the file has been downloaded, you will receive an executable file similar to this in your downloads folder. The installation wizard will launch when you simply double-click that file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnyglufgrsotf8bpexzq3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnyglufgrsotf8bpexzq3.png" alt="Python installation wizard pop-up"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on Customize Installation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvx9a7w6zlh2wkiqn6qtc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvx9a7w6zlh2wkiqn6qtc.png" alt="Python installation set up wizard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Check all the boxes as indicated above. Then click on the next button.&lt;br&gt;
The screen below will then appear. You can check every box if you so choose. The debugging symbols and binaries are not necessary for me. Therefore, I won't check the latter two boxes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgrqsbym5cl0p80bfiyn0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgrqsbym5cl0p80bfiyn0.png" alt="Python installation pop up menu showing the advanced option"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Additionally, I advise against moving the installation's position. Keep in mind the installation location in case you need it later. Here, we directly add Python to the environment variables. Then click Install.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjugooel7zzbg9n59qafb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjugooel7zzbg9n59qafb.png" alt="Python installation setup in progress"&gt;&lt;/a&gt;&lt;br&gt;
Let the installation finish (it will take about two to three minutes)…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqc4xy2y5znn3xs1i8vd7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqc4xy2y5znn3xs1i8vd7.png" alt="Python installation setup in progress"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Simply check the button if you receive a prompt asking you to disable the path length limit. By removing the restriction on the MAX_PATH variable, it disables the path length restriction.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2fbeawxiowoo4g3rd8z8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2fbeawxiowoo4g3rd8z8.png" alt="Python setup was successful"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Nothing will be damaged or changed negatively as a result of this change. Only long path names will be supported by Python. It is advised to turn off the path length limit.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fswm0snr0rfx4rewezmd1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fswm0snr0rfx4rewezmd1.png" alt="Python setup was successful"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The installation has been completed successfully.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;##Step 3: How to Check the Python Version Again to Confirm Python has been Installed&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We must now confirm once again whether Python was correctly installed and added to the environment variables' path. launch CMD or PowerShell in order to verify that. Next, we can check the availability of Python on our machine with the following command:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz6c61lmh42xxgwe33un3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz6c61lmh42xxgwe33un3.png" alt="Windows PowerShell showing the version of Python installed"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Python has been installed, and the path has also been added to the environment variables successfully!&lt;/p&gt;

&lt;p&gt;Now, to the last step.....&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;##Step 4: How to Check the Path of the Environment Variables&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you want to manually check the path variables, you have to open the Advanced System Settings. You can search for Advanced System Settings or open that from the Control Panel.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa72nsy30ol556l662651.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa72nsy30ol556l662651.png" alt="Window's 11 control panel"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go to System and Security.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs4e729lmr05g0b7cr6tr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs4e729lmr05g0b7cr6tr.png" alt="Window's 11 control panel"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on System.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw7n6mm80c33joxtjax5d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw7n6mm80c33joxtjax5d.png" alt="Window's 11 control panel"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From here, click on Advanced System Settings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F39uqi65zzzco018mekag.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F39uqi65zzzco018mekag.png" alt="window's 11 about section"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on Environment Variables.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffsa9g4y2vsbsdaxtn3db.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffsa9g4y2vsbsdaxtn3db.png" alt="A pop up menu showing the advanced system settings"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on Path, and then click Edit.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftcmna7jh1sctzm5urxpj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftcmna7jh1sctzm5urxpj.png" alt="Image showing the environmental variables"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will see that the root directory of Python311 and the scripts directory of Python311 have already been added in the installation process, as we checked the box to do these during the installation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv3dk9tc2t8mfmtw6jfuu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv3dk9tc2t8mfmtw6jfuu.png" alt="Image showing the python environment variable"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Congratulations! By following the steps above, you now have Python installed on your machine. You can now pick any IDE suitable for Python and start writing and executing Python code.&lt;/em&gt;&lt;/p&gt;

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