<?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: Namima Islam</title>
    <description>The latest articles on DEV Community by Namima Islam (@namimai).</description>
    <link>https://dev.to/namimai</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%2F2130734%2Fcd0123b1-a98e-4760-9413-dee92192bd71.png</url>
      <title>DEV Community: Namima Islam</title>
      <link>https://dev.to/namimai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/namimai"/>
    <language>en</language>
    <item>
      <title>Why Flask Is One of the Most Popular Web Frameworks Today</title>
      <dc:creator>Namima Islam</dc:creator>
      <pubDate>Fri, 28 Feb 2025 17:35:59 +0000</pubDate>
      <link>https://dev.to/namimai/why-flask-is-one-of-the-most-popular-web-frameworks-today-19m9</link>
      <guid>https://dev.to/namimai/why-flask-is-one-of-the-most-popular-web-frameworks-today-19m9</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Flask is a flexible web framework for Python that makes it easy to build web applications. It was designed to be simple and easy to use. Flask provides the essential tools for handling routes, requests, and templates.&lt;/p&gt;

&lt;p&gt;Whether you're creating a small personal project, a REST API, or a full-fledged web application, Flask gives you the freedom to structure your code however you like. It's minimalist design, combined with powerful extensions, makes it a favorite among developers who want speed, scalability, and ease of use.&lt;/p&gt;

&lt;p&gt;In this blog, we'll explore why Flask is one of the most popular web frameworks today and how it can help you build efficient and scalable web applications with minimal hassle and maybe we'll uncover why the logo for Flask looks like a Jalapeño.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Can Flask be used for?
&lt;/h2&gt;

&lt;p&gt;Flask framework is versatile, it gives developers the ability to build a range of web applications. Developers can create things like simple prototypes and full web services. Its simple and flexible design has made it convenient for developers to use it for building web applications, develop RESTful APIs, prototyping and MVPs, Data Driven Applications and Automating and Scripting. Here is how developers may use Flask for each case. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Building Web Applications&lt;/strong&gt; – Developers can create interactive websites with dynamic content using Flask’s built-in routing and templating features.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developing RESTful APIs&lt;/strong&gt; – Flask is widely used to create APIs for mobile apps, frontend applications, and micro-services due to its simplicity and ability to handle JSON based requests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prototyping and MVPs&lt;/strong&gt; – Startups and developers often use Flask to quickly build and test ideas without the complexity of a full-stack framework.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Driven Applications&lt;/strong&gt; – With integration capabilities for databases like SQLite, PostgreSQL, and MySQL, Flask is useful for applications that require data storage and retrieval.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Automation and Scripting&lt;/strong&gt; – Flask can be used to create lightweight automation tools or dashboards for data visualization. &lt;/p&gt;

&lt;h2&gt;
  
  
  How can we implement Flask?
&lt;/h2&gt;

&lt;p&gt;Flask is used with Python, so to implement Flask you will need to set up a Python environment. Once installing Flask you will have to define routes to handle different web requests. You can start with a single file and late scale up with a modular structure. Flask also supports template rendering through Jinja, a template engine for Python projects, this makes it easier to generate dynamic web pages. &lt;/p&gt;

&lt;p&gt;To deploy your Flask application you can use WSGI servers. For database management and authentication Flask-SQLAlchemy and Flask-Login can we used. &lt;/p&gt;

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

&lt;p&gt;We have dived into the basics of Flask and what it can be used for and how to implement it. Flask’s ability to adapt to different use cases, whether for personal projects or large scale applications, is one of the key reasons it remains a popular choice in web development today.&lt;/p&gt;

&lt;p&gt;Now, to answer a really important question. Is the logo for Flask a jalapeño? &lt;/p&gt;

&lt;p&gt;Many developers have debated whether the Flask logo looks like a jalapeno, but in reality it's a stylized drinking horn! &lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.istockphoto.com/photo/portrait-of-a-full-jalape%D5%B1no-pepper-gm179299479-5327186" rel="noopener noreferrer"&gt;Cover Image&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://flask.palletsprojects.com/en/stable/" rel="noopener noreferrer"&gt;Content&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://greyli.com/what-is-flask-logo/" rel="noopener noreferrer"&gt;Flask Logo Origin&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flask</category>
      <category>webdev</category>
      <category>programming</category>
      <category>coding</category>
    </item>
    <item>
      <title>Complete Python Object Oriented Programming Guide</title>
      <dc:creator>Namima Islam</dc:creator>
      <pubDate>Mon, 02 Dec 2024 21:32:32 +0000</pubDate>
      <link>https://dev.to/namimai/complete-python-object-oriented-programming-guide-5a6a</link>
      <guid>https://dev.to/namimai/complete-python-object-oriented-programming-guide-5a6a</guid>
      <description>&lt;p&gt;So you want to learn Python? Well, you've come to the right place! This blog will cover everything a beginner Python student or developer needs to know about Object Oriented Programming in Python.   &lt;/p&gt;

&lt;h2&gt;
  
  
  But first, what is python?
&lt;/h2&gt;

&lt;p&gt;Python is a powerful, high-level programming language that emphasizes simplicity and readability. It includes built-in data structures like lists and dictionaries, and supports dynamic typing, which makes it ideal for rapid application development, scripting, and prototyping.&lt;/p&gt;

&lt;h2&gt;
  
  
  What can Python do?
&lt;/h2&gt;

&lt;p&gt;Python is great for building server-side applications, web scrapers, games, and command-line interfaces (CLIs). It can also read and write files, handle network requests and send responses, and connect too databases to access and update data. Whether you're building web servers, automation scripts, or creating data driven applications, Python is the perfect language for it! &lt;/p&gt;

&lt;p&gt;One of the main features of python is OOP. OOP stands for object oriented programming, it allows developers to structure their code in a way that makes it modular and reusable. In Python, OOP revolves around objects and classes. An object is an instance of a class, which serves as a blueprint that defines its structure and behavior. Objects represent real world entities, like a book or car and uses data and functionality to perform actions. Objects store data in the form of attributes (also called properties) and methods (functions associated with an object).&lt;/p&gt;

&lt;p&gt;OOP is all about reusing and organizing code by grouping related functionality together, making it easier to manage, maintain, and extend. &lt;/p&gt;

&lt;h2&gt;
  
  
  The key concepts of OOP in Python include:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;strong&gt;init&lt;/strong&gt;() Method:&lt;/strong&gt; This special method is called when an object is created, allowing for the initialization of attributes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Attributes:&lt;/strong&gt; The properties or data associated with an object.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Classes and Instances:&lt;/strong&gt; A class is a blueprint for creating objects. An instance is a specific object created from a class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Instance Methods:&lt;/strong&gt; Functions that belong to an object and operate on its data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Instance Variables:&lt;/strong&gt; Variables that are unique to each instance of the class.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now that we covered what the key concepts of Python are, lets' dive into how we can use them. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;init&lt;/strong&gt;():
&lt;/h2&gt;

&lt;p&gt;Whenever we have a new object, we have to initialize it. To initialize we use the double underscore methods(also known as dunder method). The &lt;strong&gt;init&lt;/strong&gt;() method is a convention, it is a special method in Python classes, commonly referred to as a constructor. It's called automatically when an object is created from a class. This method allows you to initialize the object's attributes with values when the object is instantiated.&lt;/p&gt;

&lt;h2&gt;
  
  
  Attributes:
&lt;/h2&gt;

&lt;p&gt;An attribute is a variable that belongs to an object. Attributes are typically defined inside the &lt;strong&gt;init&lt;/strong&gt;() method and are associated with individual instances. They represent the state of the object and can be accessed and modified throughout the object's lifecycle. &lt;/p&gt;

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

&lt;p&gt;In the example above, the &lt;strong&gt;init&lt;/strong&gt; method is initializing the parameters author, magazine, title, and below the init, the attributes are being defined using self. &lt;/p&gt;

&lt;h2&gt;
  
  
  Classes and Instances:
&lt;/h2&gt;

&lt;p&gt;A class is like a blueprint for creating objects. A Python class defines the structure and behavior of its objects. Once the class is defined, you can create individual instances also called objects based on that blueprint. &lt;/p&gt;

&lt;p&gt;An instance is also referred to as an object. An instance is a single occurrence of an object that refers to the individual objects produced from the class. &lt;/p&gt;

&lt;p&gt;In my example below, class Article is the class, it is creating the blueprint for creating objects. Article1 is my instance of the class, it is the object that has been created from the class. &lt;/p&gt;

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

&lt;h2&gt;
  
  
  Instance Methods:
&lt;/h2&gt;

&lt;p&gt;Instance methods are functions defined inside a class that operate on an instance of that class. These methods can access the instances attributes through the self parameter and modify the instance's attributes. They allow objects to perform actions and interact with their own data. &lt;/p&gt;

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

&lt;p&gt;In the example above, the summary method defines our instance method because it operates on an individual instance of the Article class. It's using self to access the instances attributes and uses string interpolation to create the formatted string.   &lt;/p&gt;

&lt;h2&gt;
  
  
  Instance Variables:
&lt;/h2&gt;

&lt;p&gt;Instance variables are attributes that are unique to each instance of a class. They store data specific to that object. Instance variables are accessed using dot notation.&lt;/p&gt;

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

&lt;p&gt;In the example above, our instance variable word_count is using dot notation and is tracking the word count of the article. &lt;/p&gt;

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

&lt;p&gt;Object Oriented Programming is a fundamental part of python. It uses objects to make python programs more dynamic and re-usable. If you follow the steps above you'll be a pro at OOP in no time! &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Python Error Types Explained: Troubleshooting for Beginners</title>
      <dc:creator>Namima Islam</dc:creator>
      <pubDate>Thu, 14 Nov 2024 18:53:21 +0000</pubDate>
      <link>https://dev.to/namimai/python-error-types-explained-troubleshooting-for-beginners-4o76</link>
      <guid>https://dev.to/namimai/python-error-types-explained-troubleshooting-for-beginners-4o76</guid>
      <description>&lt;p&gt;Python is an interpreted, object-oriented programming language. Its high-level built-in data structures and dynamic typing make it highly useful for the rapid development of new applications, as well as for scripting or "glue" code that integrates components written in different languages.&lt;/p&gt;

&lt;p&gt;Python's simple, easy-to-learn syntax emphasizes readability, which helps reduce the cost and complexity of long-term program maintenance. Additionally, Python's rich set of error types simplifies the debugging process, enabling coders to identify and resolve issues more efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Error Types In Python
&lt;/h2&gt;

&lt;p&gt;Python error types are essential for diagnosing problems, handling unexpected situations, and ensuring code quality.&lt;/p&gt;

&lt;p&gt;Some common error types in Python are, syntax errors, logic errors, assertion errors, index error, key error, name error, type error.&lt;/p&gt;

&lt;p&gt;Error types are like clues that guide you on how to fix the problem. Here are some examples of the different error types. &lt;/p&gt;

&lt;h2&gt;
  
  
  Syntax errors
&lt;/h2&gt;

&lt;p&gt;Syntax errors are the result of incorrect syntax, kind of like a typo.&lt;/p&gt;

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

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



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

&lt;p&gt;Here, python is saying that on line 115 there is an extra or misplaced character. The "*" character is causing Python to raise a syntax error because it’s unexpected in this context. Syntax errors can include missing colons, unclosed parentheses, or unmatched quotation marks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Logic Errors
&lt;/h2&gt;

&lt;p&gt;Logic errors are not perceived as errors by Python. To find a logic error a programmer will need to utilize tools like pdb.&lt;/p&gt;

&lt;p&gt;One instance of a logic error, is if a function is meant to add two numbers but it is subtracting them instead, Python won’t raise an error, but the output will be incorrect. &lt;/p&gt;

&lt;h2&gt;
  
  
  Assertion errors
&lt;/h2&gt;

&lt;p&gt;An assertion error, is raised when an assert statement fails, meaning that an expected condition was not met. &lt;/p&gt;

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

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

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

&lt;p&gt;Assertions are commonly used in testing and debugging to ensure certain conditions are met during runtime. If an assertion fails, Python immediately raises an error with a custom message, which can be helpful for tracking down logical issues.&lt;/p&gt;

&lt;h2&gt;
  
  
  Index error
&lt;/h2&gt;

&lt;p&gt;Index errors are raised when you try to access an element at an index past the end of the list. &lt;/p&gt;

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

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

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

&lt;p&gt;In the example above we are trying to access the value 10 but it is not available in the list.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Key error
&lt;/h2&gt;

&lt;p&gt;A key error is raised when trying to access a dictionary key that doesn’t exist. This happens if you reference a key not present in the dictionary. &lt;/p&gt;

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

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

&lt;h2&gt;
  
  
  Name error
&lt;/h2&gt;

&lt;p&gt;A name error occurs when you try to use a variable or function name that hasn’t been defined or is out of scope.&lt;/p&gt;

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

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

&lt;h2&gt;
  
  
  Type error
&lt;/h2&gt;

&lt;p&gt;A type error is when an operation or function is applied to an object of the wrong type. &lt;/p&gt;

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

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

&lt;p&gt;In the example above we have a type error because "123" and 123 are different data types.&lt;/p&gt;

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

&lt;p&gt;In conclusion, understanding Python errors might seem intimidating at first but understanding these common types can simplify the debugging process and improve your coding confidence. Each error type serves as a clue, guiding you toward a solution and helping you write more robust code. The next time you encounter an error, use it as a learning tool, it’s just Python’s way of showing you the path to a more refined program. Python encompasses a broader range of error types than those mentioned above. Attached below is a comprehensive list of additional error types.  &lt;/p&gt;

&lt;p&gt;References: &lt;br&gt;
Cover Photo: &lt;a href="https://realpython.com/python312-error-messages/" rel="noopener noreferrer"&gt;https://realpython.com/python312-error-messages/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Information: &lt;a href="https://realpython.com/python312-error-messages/" rel="noopener noreferrer"&gt;https://realpython.com/python312-error-messages/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;List of Error Types: &lt;a href="https://docs.python.org/3/library/exceptions.html" rel="noopener noreferrer"&gt;https://docs.python.org/3/library/exceptions.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>coding</category>
    </item>
    <item>
      <title>React "State" for Beginners</title>
      <dc:creator>Namima Islam</dc:creator>
      <pubDate>Sun, 20 Oct 2024 17:23:38 +0000</pubDate>
      <link>https://dev.to/namimai/react-state-for-beginners-57b7</link>
      <guid>https://dev.to/namimai/react-state-for-beginners-57b7</guid>
      <description>&lt;p&gt;React has become a powerful tool amongst developers, it's used by large companies like Facebook, Tesla, Airbnb and many more. React has revolutionized the way developers create dynamic web applications. One of the core concepts that makes React so powerful is state. &lt;/p&gt;

&lt;h2&gt;
  
  
  But what is state?
&lt;/h2&gt;

&lt;p&gt;State refers to the data in a component, such as strings, arrays, objects, or even functions, that determines how the component behaves and renders. It can store anything you want to keep track of in your application, such as user inputs, API responses, or toggled settings. Unlike a prop, state is dynamic and changes as the user interacts with the webpage and can be changed within a component. A prop is read-only and is information passed down from a parent to a child and can be any data type(strings, numbers, objects, functions). Some examples of what makes state change is user inputs, responses from APIs, and toggling.&lt;/p&gt;

&lt;p&gt;State is mutable, it lets us maintain and update information within a component independently, without needing the parent component to send updated data. With state, you can control what is displayed on the screen based on changes in data or user activity, making your web applications feel more responsive and engaging.&lt;/p&gt;

&lt;p&gt;State seems incredibly useful, but how can we implement it?&lt;/p&gt;

&lt;h2&gt;
  
  
  Using State
&lt;/h2&gt;

&lt;p&gt;There are several ways State can be stored and managed. Starting with the hook useState, useState is a special function that gives a component the ability to track dynamic data and automatically re-renders the component whenever the state changes. &lt;/p&gt;

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

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

&lt;p&gt;&lt;u&gt;Explanation:&lt;/u&gt; In the example above, useState must first be imported from React to manage the components state. This is essential for functional components. &lt;/p&gt;

&lt;h2&gt;
  
  
  Initializing and Setting State
&lt;/h2&gt;

&lt;p&gt;After state has been imported, we must declare, initialize and set. In React, initializing is defining and setting the values for a components state when it is created, this determines how the component renders and behaves.   &lt;/p&gt;

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

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

&lt;p&gt;&lt;u&gt;Explanation:&lt;/u&gt; Our example utilizes array de-structuring, we have a state variable called isDarkMode with the value of true, which means that when the App component first renders, the isDarkMode variable will be initialized to true. isDarkMode being initialized to true means the application will start in dark mode. isDarkMode is the current state value and setIsDarkMode is used to update the isDarkMode state. &lt;/p&gt;

&lt;p&gt;To set our state, we must use the keyword set. In our example it is referred to as "setIsDarkMode". Our toggleDarkMode function is changing the value of isDarkMode between true and false each time it is called. Our setIsDarkMode(current =&amp;gt; !current) updates the state by calling the setIsDarkMode function, current is the current state value of isDarkMode when setIsDarkMode is called, !current takes the value of current which is a boolean(true or false) and negates it. If current is true, !current evaluates too false, but if current is false, !current evaluates too true.&lt;/p&gt;

&lt;p&gt;To summarize, the state variable isDarkMode with a value of true using the useState hook, the setIsDarkMode function is used to update this state. The toggleDarkMode function outlines the logic for toggling the value of isDarkMode, ensuring that the component will re-render with the new value whenever it is called.&lt;/p&gt;

&lt;p&gt;There are two approaches when setting state in React. You can pass a new value directly to the setter function, which will replace the current state value or by using a functional form.&lt;/p&gt;

&lt;p&gt;When you need to update the state based on its current value, it's better to use the functional form of the setter function. In this form, you pass a function to the setter that takes the current state value as an argument and returns the new state value. For example, setIsDarkMode(current =&amp;gt; !current) ensures that the state update uses the most recent value of isDarkMode.&lt;/p&gt;

&lt;p&gt;The functional form is built into React's useState hook and helps manage state accurately by ensuring that the internal workings of React always use the most recent state value. &lt;/p&gt;

&lt;p&gt;One important thing to note about state and setting state is that setting state is asynchronous, when you call the state update function (like setIsDarkMode), the new state value might not be immediately available for use right after the call.&lt;/p&gt;

&lt;p&gt;Now that we imported, initialized and set our state we can render our component.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rendering the component
&lt;/h2&gt;

&lt;p&gt;Rendering a component is react calling your component to display something on your application. When the state changes, React re-renders the component to reflect the updated state. &lt;/p&gt;

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

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

&lt;p&gt;&lt;u&gt;Explanation:&lt;/u&gt; First we assign the class, the className of the div element is set based on the value of isDarkMode. If isDarkMode is true, the class will be "App"; if false, it will be "App light". This can be useful for changing the appearance of the application. &lt;/p&gt;

&lt;p&gt;isDarkMode={isDarkMode} allows the Header component to access the current state of dark mode, enabling it to render content conditionally based on whether dark mode is active. toggleDarkMode={toggleDarkMode} allows the Header to invoke the toggleDarkMode function, providing a way to change the dark mode state from within the Header component.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Completed code:&lt;/u&gt; &lt;/p&gt;

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

&lt;h2&gt;
  
  
  Conclusion: Why is state important?
&lt;/h2&gt;

&lt;p&gt;State is crucial to building dynamic webpages in React, it allows components to create, manage and respond to changing data that the user interacts with on a page, it allows you to control what is displayed on the screen based on changes in data or user activity. Mastering state can be complicated, but if you follow the steps above you can create dynamic user interfaces.&lt;/p&gt;

&lt;p&gt;If you would like to explore state more in depth, checkout react.dev(&lt;a href="https://react.dev/learn/managing-state" rel="noopener noreferrer"&gt;https://react.dev/learn/managing-state&lt;/a&gt;). &lt;/p&gt;

&lt;p&gt;Sources: &lt;/p&gt;

&lt;p&gt;Cover Photo: &lt;a href="https://www.linkedin.com/pulse/introducing-react-19-revolutionizing-development-muhammad-zain-o7mwf/" rel="noopener noreferrer"&gt;https://www.linkedin.com/pulse/introducing-react-19-revolutionizing-development-muhammad-zain-o7mwf/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Understanding DOM Events</title>
      <dc:creator>Namima Islam</dc:creator>
      <pubDate>Mon, 30 Sep 2024 08:35:46 +0000</pubDate>
      <link>https://dev.to/namimai/understanding-dom-events-4126</link>
      <guid>https://dev.to/namimai/understanding-dom-events-4126</guid>
      <description>&lt;p&gt;Ever use a webpage and wonder, "WOAH!! how was I able to click on that image, or how was I able to like that pic!" &lt;/p&gt;

&lt;p&gt;Well, I'm here to tell you about this cool thing called DOM Events!  &lt;/p&gt;

&lt;p&gt;DOM Events is a great way to make a webpage interactive. Some examples of how DOM events make a page interactive is by typing on a page, clicking, tapping, submitting forms and many more!  &lt;/p&gt;

&lt;p&gt;In this article we will simplify DOM Events and learn how we can use them to create dynamic webpages. &lt;/p&gt;

&lt;h2&gt;
  
  
  What are DOM Events?
&lt;/h2&gt;

&lt;p&gt;First, let's start by defining what D.O.M. stands for. &lt;br&gt;
DOM stands for - Document Object Model. DOM is a programming interface that allows us to create, change, or remove elements from the document. &lt;/p&gt;

&lt;p&gt;An event in Javascript, has the ability to "listen" for what is happening inside the browser.&lt;/p&gt;

&lt;p&gt;In simple terms, DOM Events are actions or occurrences that happen in a web page, which JavaScript can detect and respond to. The events allows your web page to be interactive by triggering specific functions when a user interacts with elements on the page.&lt;/p&gt;
&lt;h2&gt;
  
  
  Listening to an event using &lt;em&gt;addEventListener&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;For JavaScript to handle an event, we need to tell it to listen for that event. To do this we start by calling the method, addEventListener. We then need to pass in two arguments. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The name of the event to listen for.&lt;/li&gt;
&lt;li&gt;A callback function to "handle" the event.
&lt;/li&gt;
&lt;/ol&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;`img.addEventListener('click', (e) =&amp;gt; handleClick(cocktail));`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the code above, the img references the element, the addEventListener is attaching an event to the element, the click is the type of event it is listening for, the (e) is the event object, followed by the arrow function which is necessary to pass the specific argument to the handle click function(if not used handle click would be called immediately), then we have the handleClick which is the callback function, and once the cocktail is passed to the handleClick the data displays.  &lt;/p&gt;

&lt;p&gt;The click event is triggered when a user clicks on an element. This event is commonly used on buttons, links, and images. The click event is also a mouse event(will be covered later in the blog).  &lt;/p&gt;

&lt;p&gt;addEventListener detects and responds to specific events on a webpage, we saw an example using click but what about other events?&lt;/p&gt;

&lt;p&gt;DOMContentLoaded is another DOM Event that can be ran with JavaScript Code.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Using DOMContentLoaded
&lt;/h2&gt;

&lt;p&gt;The DOMContentLoaded event ensures your JavaScript runs only after the DOM is fully loaded, preventing errors from trying to access elements before they're available.&lt;/p&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;document.addEventListener('DOMContentLoaded', main);

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

&lt;/div&gt;



&lt;p&gt;DOMContentLoaded, is an event that fires when the initial HTML document has been completely loaded and parsed, without waiting for stylesheets, images, or other external resources to fully load.&lt;/p&gt;

&lt;p&gt;It ensures that the DOM is fully built and accessible, so you can safely interact with elements in the HTML, such as adding event listeners or manipulating the DOM.&lt;/p&gt;

&lt;p&gt;In the code above, the browser is telling you, that the document is now available and the user can start interacting with it.&lt;/p&gt;

&lt;p&gt;Another common DOM Event are Mouse Events. &lt;/p&gt;

&lt;h2&gt;
  
  
  Mouse Events
&lt;/h2&gt;

&lt;p&gt;We previously named one mouse event(click), here are some other common mouse events:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;click&lt;/strong&gt; - Triggered when the user clicks a mouse button over an element. Used for buttons, links, and any interactive elements where a user action is required.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;dblclick&lt;/strong&gt; - Triggered when the user double-clicks on an element. Used for actions that require confirmation or selection, such as editing text or opening files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;mousedown&lt;/strong&gt; - Triggered when the mouse button is pressed down on an element. Used to initiate drag-and-drop operations or to create custom interactions that respond to mouse button presses.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;mouseup&lt;/strong&gt; - Triggered when the mouse button is released over an element. Often used with mousedown to complete an action, like dropping an item after dragging.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;mousemove&lt;/strong&gt; - Triggered when the mouse pointer moves within the bounds of an element. Used for interactive graphics, creating drawing applications, or for displaying dynamic information based on mouse position.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Mouse events are crucial for creating interactive user interfaces, they create instant reactions to a page, they make using a webpage user friendly and are engaging. &lt;/p&gt;

&lt;p&gt;Our list of DOM Events doesn't stop there! There are many more events that can make a webpage interactive, if you want to read more on DOM Event types you can visit any of these sources: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/DOM_event" rel="noopener noreferrer"&gt;Wiki&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events" rel="noopener noreferrer"&gt;Mozilla.org&lt;/a&gt;   &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Summary:
&lt;/h2&gt;

&lt;p&gt;DOM Events are actions or occurrences that happen in a web page, which JavaScript can detect and respond too. The events allows your web page to be interactive by triggering specific functions when a user interacts with elements on the page, including keyboard actions and form submissions.&lt;/p&gt;

&lt;p&gt;addEventListener detects and responds to specific events on a webpage.&lt;/p&gt;

&lt;p&gt;Mouse events create instant reactions to a page. &lt;/p&gt;

&lt;p&gt;DOMContentLoaded, ensures that the DOM is ready for JavaScript code to safely manipulate elements, add event listeners, or modify the content of the page. It's commonly used to run scripts after the page's structure is available and to ensure no errors occur due to trying to access elements that haven't yet been created.&lt;/p&gt;

&lt;p&gt;Congratulations! You are now an expert in DOM Events!&lt;/p&gt;

&lt;p&gt;Sources:  &lt;/p&gt;

&lt;p&gt;Cover Photo: &lt;a href="https://www.pexels.com/search/web%20development/" rel="noopener noreferrer"&gt;https://www.pexels.com/search/web%20development/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.w3schools.com/js/js_events.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/js/js_events.asp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
