<?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: Dipsan Kadariya</title>
    <description>The latest articles on DEV Community by Dipsan Kadariya (@dipsankadariya).</description>
    <link>https://dev.to/dipsankadariya</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%2F1997034%2Fb4218250-7b43-411d-85f5-7882821ad3e1.jpg</url>
      <title>DEV Community: Dipsan Kadariya</title>
      <link>https://dev.to/dipsankadariya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dipsankadariya"/>
    <language>en</language>
    <item>
      <title>Machine Learning</title>
      <dc:creator>Dipsan Kadariya</dc:creator>
      <pubDate>Thu, 20 Feb 2025 14:42:33 +0000</pubDate>
      <link>https://dev.to/dipsankadariya/machine-learning-15pf</link>
      <guid>https://dev.to/dipsankadariya/machine-learning-15pf</guid>
      <description>&lt;h2&gt;
  
  
  Supervised Learning
&lt;/h2&gt;

&lt;p&gt;Supervised learning involves learning through data with input and output, finding the relationship between them, and using that relationship to predict outputs for new inputs.&lt;/p&gt;

&lt;p&gt;In this case, we have both input and output. In supervised learning, we train the machine to learn from the given data and predict whether, for certain IQ and CGPA values, there will be a placement or not.&lt;/p&gt;

&lt;h3&gt;
  
  
  Types of Supervised Learning:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Regression&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Classification&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Data Types
&lt;/h2&gt;

&lt;p&gt;Data is generally of two types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Numerical&lt;/strong&gt;: Age, weight, CGPA, IQ&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Categorical&lt;/strong&gt;: Gender, nationality, brand, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Regression (Supervised Learning)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If the output is numerical, it is called &lt;strong&gt;regression&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Example: For a certain IQ and CGPA, let's say we predict a salary package of 50,000. Since the output column (package) is numerical, this is regression.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Classification (Supervised Learning)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If the output is categorical, it is called &lt;strong&gt;classification&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Example: Given certain CGPA and IQ values, we predict whether a student will get placed or not. Since the output is categorical (Yes/No), this is classification.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Unsupervised Learning
&lt;/h2&gt;

&lt;p&gt;Unsupervised learning is used when we have only input data and no corresponding output.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;

&lt;p&gt;In this example, we only have inputs and no output. We don't know what to predict.&lt;/p&gt;

&lt;p&gt;In unsupervised learning, we perform one of the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Clustering&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dimensionality Reduction&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Anomaly Detection&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Association Rule Learning&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Clustering
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Let's say we plot IQ and CGPA.&lt;/li&gt;
&lt;li&gt;A clustering algorithm detects which students belong to the same group.&lt;/li&gt;
&lt;li&gt;Example: We can categorize students into different groups such as:

&lt;ul&gt;
&lt;li&gt;High IQ, low CGPA&lt;/li&gt;
&lt;li&gt;Low IQ, low CGPA&lt;/li&gt;
&lt;li&gt;High IQ, high CGPA&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Dimensionality Reduction
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If there are a lot of input columns (e.g., 1000), the algorithm runs slow, and at some point, adding more columns does not improve results.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dimensionality Reduction (DR)&lt;/strong&gt; removes unnecessary columns to improve efficiency.&lt;/li&gt;
&lt;li&gt;Example: If we need to predict house price based on the number of rooms and washrooms, DR combines these into a single feature, reducing the number of input columns.&lt;/li&gt;
&lt;li&gt;DR also helps in visualizing high-dimensional data by reducing it to 2D or 3D.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Anomaly Detection
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Used for finding errors and detecting outliers in data.&lt;/li&gt;
&lt;li&gt;Helps in fraud detection, network security, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Association Rule Learning
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A technique in unsupervised learning used to find relationships or patterns between variables in large datasets.&lt;/li&gt;
&lt;li&gt;Example: Market Basket Analysis (identifying which products are frequently bought together).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Semi-Supervised Learning
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Semi-supervised learning lies between supervised and unsupervised learning.&lt;/li&gt;
&lt;li&gt;It involves a small amount of labeled data and a large amount of unlabeled data.&lt;/li&gt;
&lt;li&gt;The labeled data helps guide the learning process of the unlabeled data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Reinforcement Learning
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Reinforcement learning is where an agent learns how to make decisions by interacting with an environment.&lt;/li&gt;
&lt;li&gt;The agent performs actions and receives feedback in the form of rewards or penalties.&lt;/li&gt;
&lt;li&gt;The goal is to maximize cumulative rewards over time.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Categories Based on Production
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Batch Machine Learning
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Code runs on a server (offline learning).&lt;/li&gt;
&lt;li&gt;The model is trained once using the "entire dataset" and then deployed.&lt;/li&gt;
&lt;li&gt;convential way of training model.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Process:&lt;/strong&gt; data → model → train → test → server → run&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Problems with Batch Learning:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The model is static and does not evolve with new data,since
it is trained offline.&lt;/li&gt;
&lt;li&gt;Requires periodic retraining with merged new and old data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Online Machine Learning
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Done incrementally (model learns continuously).&lt;/li&gt;
&lt;li&gt;Data is fed in small batches (mini-batches) sequentially.&lt;/li&gt;
&lt;li&gt;Model is trained online.&lt;/li&gt;
&lt;li&gt;The model improves with interactions and new data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Process:&lt;/strong&gt; small data → model → train → test → server&lt;/p&gt;

&lt;p&gt;&amp;lt;--- Continuous new data&lt;/p&gt;

&lt;h3&gt;
  
  
  Predictions on New Data
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The model continues learning from new data.&lt;/li&gt;
&lt;li&gt;Examples: Chatbots like GPT, YouTube video recommendations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  When to Use Online Learning?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Concept Drift&lt;/strong&gt;: When concepts change over time (e.g., e-commerce trends).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost-Effective&lt;/strong&gt;: Continuous learning without expensive retraining.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Faster Solution&lt;/strong&gt;: Adaptability in real-time applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Out-of-Core Learning
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Used when the dataset is too large to fit in memory.&lt;/li&gt;
&lt;li&gt;The dataset is split into batches and processed in chunks.&lt;/li&gt;
&lt;li&gt;Though performed offline, it follows an online learning approach.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Disadvantage:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;More complex and can be risky if not implemented correctly.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Based on Learning
&lt;/h1&gt;

&lt;p&gt;Machine learning can be categorized based on how it learns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;By Memorizing&lt;/strong&gt; (Instance-Based Learning)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;By Generalizing&lt;/strong&gt; (Understanding concepts, Model-Based Learning)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  1. Instance-Based Learning
&lt;/h2&gt;

&lt;p&gt;Instance-based learning does not actually learn patterns but stores training data and responds based on the nearest neighbors.&lt;/p&gt;

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

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;IQ&lt;/th&gt;
&lt;th&gt;CGPA&lt;/th&gt;
&lt;th&gt;Placement&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7.0&lt;/td&gt;
&lt;td&gt;7.3&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;In instance-based learning, the model does not learn anything. It just stores the data.&lt;/li&gt;
&lt;li&gt;When a new query comes, it looks at the nearest data points to decide.&lt;/li&gt;
&lt;li&gt;If the nearby points mostly have placements, the answer is "Yes"; otherwise, it's "No".&lt;/li&gt;
&lt;li&gt;There is no training or learning—just pattern matching.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Point:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It focuses on simple pattern matching, where the model stores examples and instantly answers based on the nearest matching data point.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. Model-Based Learning
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The model learns from data using algorithms.&lt;/li&gt;
&lt;li&gt;It understands the pattern and draws a boundary.&lt;/li&gt;
&lt;li&gt;The boundary helps predict answers for new inputs.&lt;/li&gt;
&lt;li&gt;Unlike instance-based learning, model-based learning finds a mathematical relation between input and output.&lt;/li&gt;
&lt;li&gt;Even if we don’t have training data points, we can predict using the learned boundary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Point:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This refers to building an internal model of the relationships in the data, which can then be used to make predictions.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Differences Between Instance-Based and Model-Based Learning
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Usual/Conventional Machine Learning&lt;/th&gt;
&lt;th&gt;Instance-Based Learning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Prepare data for model training.&lt;/td&gt;
&lt;td&gt;No model training.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Train models to generalize patterns.&lt;/td&gt;
&lt;td&gt;No training—only stores data.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Can make predictions using learned models.&lt;/td&gt;
&lt;td&gt;Predictions based on stored examples.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Results in a generalizable model.&lt;/td&gt;
&lt;td&gt;No generalization—just stores past data.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Missing attributes are handled better.&lt;/td&gt;
&lt;td&gt;Every new input needs complete data.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Challenges in Machine Learning
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Data collection issues&lt;/li&gt;
&lt;li&gt;Insufficient labeled data&lt;/li&gt;
&lt;li&gt;Non-representative data&lt;/li&gt;
&lt;li&gt;Poor quality data&lt;/li&gt;
&lt;li&gt;Irrelevant features&lt;/li&gt;
&lt;li&gt;Overfitting&lt;/li&gt;
&lt;li&gt;Underfitting&lt;/li&gt;
&lt;li&gt;Software integration issues&lt;/li&gt;
&lt;li&gt;High costs involved&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Machine Learning Development Lifecycle (MLDLC)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Problem Definition&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Identify the problem, customer needs, and expected outcomes.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Data Gathering&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Collect relevant data from sources such as APIs, sensors, or databases.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Data Preprocessing&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Remove duplicates, fill missing values, and convert data into a usable format.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Exploratory Data Analysis (EDA)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understand data distribution, relationships, and visualizations.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Feature Engineering &amp;amp; Selection&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create new features and remove unnecessary ones.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Model Training, Evaluation, and Selection&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Train models and tune hyperparameters for better performance.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Model Deployment&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Convert trained models into software for real-world use.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Testing&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Perform beta testing, optimize performance, and retrain if needed.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Tensor in Machine Learning
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Tensors are data structures used to store numerical data.&lt;/li&gt;
&lt;li&gt;They can be &lt;strong&gt;0D, 1D, 2D, 3D, or ND tensors&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Types of Tensors&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;0D Tensor&lt;/strong&gt; (Scalar): A single number.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;1D Tensor&lt;/strong&gt; (Vector): A single row of numbers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;2D Tensor&lt;/strong&gt; (Matrix): A table-like structure with rows and columns.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;3D Tensor&lt;/strong&gt;: A collection of 2D matrices.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ND Tensor&lt;/strong&gt;: Higher-dimensional tensor for complex data processing.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Data Link layer</title>
      <dc:creator>Dipsan Kadariya</dc:creator>
      <pubDate>Wed, 13 Nov 2024 08:16:39 +0000</pubDate>
      <link>https://dev.to/dipsankadariya/data-link-layer-1788</link>
      <guid>https://dev.to/dipsankadariya/data-link-layer-1788</guid>
      <description>&lt;h1&gt;
  
  
  The Data Link Layer (DLL)
&lt;/h1&gt;

&lt;p&gt;The Data Link Layer (DLL) is the second layer of the OSI model, responsible for ensuring direct, reliable communication between two nodes in a network. By handling functions like error detection, flow control, and framing, the Data Link Layer allows data to move securely and in the right order between neighboring devices, preventing data loss or corruption.&lt;/p&gt;

&lt;h2&gt;
  
  
  Functions of the Data Link Layer
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: The Data Link Layer establishes and maintains reliable links between directly connected devices, or "nodes." It ensures data is transferred without errors, regulates the flow of data, and segments data into smaller pieces called "frames."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Example&lt;/strong&gt;: Imagine wrapping a fragile item in protective material before shipping it. This way, the item arrives safely and undamaged. The Data Link Layer provides similar protection for data, "wrapping" each data packet with information that ensures its safe delivery.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Components of the Data Link Layer
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Logical Link Control (LLC)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: The LLC is a sub-layer that controls how devices interact at the data link level. It oversees data flow between devices and ensures error-free delivery.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function&lt;/strong&gt;: LLC adds information to each data packet so the receiving device knows how to handle the data. It’s especially important in multi-device networks where clear, organized communication is essential.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Media Access Control (MAC)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: The MAC sub-layer prevents data collisions when multiple devices try to communicate over the same network channel.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function&lt;/strong&gt;: MAC ensures each device waits its turn or "accesses" the communication channel without interfering with other devices, reducing network congestion.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Core Concepts in the Data Link Layer
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Framing
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: Framing is a process that organizes data into manageable packets or "frames." Each frame has headers and trailers with additional information for error-checking and addressing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Example&lt;/strong&gt;: Just as a photo is placed within a frame for better presentation and protection, data packets are framed for orderly transmission.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Error Control Techniques
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Stop-and-Wait ARQ&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: A flow control mechanism where the sender transmits one frame and waits for an acknowledgment (ACK) before sending the next.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function&lt;/strong&gt;: Prevents overload by ensuring each frame is received before the next is sent, though it can slow down transmission in high-speed networks.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Go-Back-N ARQ&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: The sender can transmit multiple frames before waiting for an acknowledgment, but if an error is detected, it resends all frames from the erroneous one onward.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Example&lt;/strong&gt;: Similar to sending several items in one shipment; if one item is damaged, all items from that point are returned and resent.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Selective Repeat ARQ&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: The sender retransmits only the frames with errors, rather than all subsequent frames.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Benefit&lt;/strong&gt;: More efficient than Go-Back-N, as only the frames needing correction are resent.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Channel Allocation Techniques
&lt;/h3&gt;

&lt;p&gt;Channel allocation methods determine how multiple devices share a communication channel without causing interference.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Technique&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ALOHA&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Devices transmit whenever they have data, leading to a high chance of collisions.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Slotted ALOHA&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Time is divided into slots, so devices transmit only at specific times, reducing collisions.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CSMA&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Devices listen to the channel before transmitting, reducing the likelihood of collisions.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CSMA/CD&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Detects collisions during transmission and allows devices to stop and retry after a delay.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CSMA/CA&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;In wireless networks, devices avoid collisions by signaling before transmitting data.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Example for CSMA/CD&lt;/strong&gt;: Similar to stopping when hearing a crash while crossing the street, waiting, and then trying again.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Ethernet Standards in the Data Link Layer
&lt;/h2&gt;

&lt;p&gt;Ethernet standards are protocols that dictate how data is transmitted over networks, enabling devices to communicate through shared standards.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. 802.3 CSMA/CD (Carrier Sense Multiple Access with Collision Detection)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: This standard for Ethernet uses CSMA/CD to control access and prevent collisions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function&lt;/strong&gt;: When multiple devices access a shared network, CSMA/CD listens for clear signals and detects potential collisions, retrying transmission after a delay.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. 802.4 Token Bus
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: A standard where devices are organized in a bus topology and send data only when they have a token.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Benefit&lt;/strong&gt;: Prevents collisions by controlling data transmission in an orderly fashion, though devices may have to wait for the token.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. 802.5 Token Ring
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: Devices form a ring topology, passing a token around, and only the device holding the token can transmit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function&lt;/strong&gt;: Ensures organized, sequential data transmission, minimizing chances of collisions.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Wireless LAN Technologies
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Bluetooth
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: A short-range wireless technology for connecting devices within a limited area, such as a headset to a smartphone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Application&lt;/strong&gt;: Useful for quick, local connections with limited interference from other devices.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Wi-Fi
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: Wi-Fi enables devices to connect to each other or the internet using radio waves.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function&lt;/strong&gt;: Provides high-speed, wireless connectivity over a larger range than Bluetooth, ideal for home and office networks.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Virtual Circuit Switching
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: Virtual Circuit Switching establishes a logical path for data between devices, giving the appearance of a dedicated line despite shared resources.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Example&lt;/strong&gt;: Similar to a telephone call where a virtual circuit connects two phones, creating a continuous connection during the call.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Frame Relay
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: A high-speed data communication protocol for connecting networks over a wide area using fixed-size frames.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Application&lt;/strong&gt;: Frequently used for connecting different local area networks (LANs) across a broad area network (WAN).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ATM (Asynchronous Transfer Mode)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: A protocol using fixed-size cells for reliable, high-speed communication.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Benefit&lt;/strong&gt;: Enables efficient data transfer, supporting both voice and video services with minimal delay.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Data Link Layer Protocols
&lt;/h2&gt;

&lt;h3&gt;
  
  
  HDLC (High-Level Data Link Control)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: A data link layer protocol for reliable communication over serial links, incorporating error detection and flow control.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function&lt;/strong&gt;: HDLC uses a structured frame format to manage how data packets are transmitted and ensures accuracy in data delivery.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  PPP (Point-to-Point Protocol)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: A protocol used for direct communication between two network nodes, providing authentication and encapsulation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Application&lt;/strong&gt;: Widely used in direct internet connections, such as those between a computer and an internet service provider.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;The Data Link Layer plays a critical role in managing direct data transfer between neighboring devices, ensuring smooth, reliable communication across networks. By breaking data into frames, managing access to communication channels, and using error-checking methods, it forms the backbone for dependable data transmission.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Database Management System(DBMS)</title>
      <dc:creator>Dipsan Kadariya</dc:creator>
      <pubDate>Thu, 31 Oct 2024 15:03:48 +0000</pubDate>
      <link>https://dev.to/dipsankadariya/database-management-systemdbms-4fhl</link>
      <guid>https://dev.to/dipsankadariya/database-management-systemdbms-4fhl</guid>
      <description>&lt;h1&gt;
  
  
  Understanding Database Management Systems (DBMS)
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Data: The Raw Information
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt; Data is raw information that, on its own, doesn't provide any meaning. It can be anything from numbers, words, dates, or measurements, without any added context.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; Imagine you have a list of numbers, like "25," "100," and "60." Without additional information, these numbers don't tell us much. They are just raw facts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Database: Structured Information Storage
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt; A database is a structured collection of data that is stored so it can be easily accessed, managed, and updated. In a database, information is organized in a way that makes it simple to find, edit, or analyze.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Purpose:&lt;/strong&gt; The purpose of a database is to help users store information systematically. This means they can quickly find the information they need and use it as needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; Think of a library catalog. It's a database of books where you can look up the title, author, and location of each book, making it easy to find the book you want.&lt;/p&gt;

&lt;h2&gt;
  
  
  Database Management System (DBMS)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt; A Database Management System, or DBMS, is a software that allows users to create, retrieve, update, and manage data in a database. Instead of manually organizing and searching through data, a DBMS lets users perform these tasks more quickly and accurately.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples:&lt;/strong&gt; Popular DBMSs include MySQL, MongoDB, Oracle, and PostgreSQL. These systems are widely used in businesses and other organizations to handle data efficiently.&lt;/p&gt;

&lt;h3&gt;
  
  
  Functions of DBMS:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Data Storage:&lt;/strong&gt; DBMS helps store large amounts of data in an organized way.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Retrieval:&lt;/strong&gt; Users can easily search and retrieve specific data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Manipulation:&lt;/strong&gt; Allows for updating, adding, or deleting data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Security:&lt;/strong&gt; Protects data so that only authorized users can access it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Applications of DBMS
&lt;/h2&gt;

&lt;p&gt;DBMS is used in various fields to manage data effectively:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Banking:&lt;/strong&gt; Banks use DBMS to manage customer information, account details, and transaction records. This allows for quick access to customer accounts and secure transaction processing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Education:&lt;/strong&gt; Schools and universities use DBMS to keep records of students, courses, grades, and staff details, making it easy to access and update information.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Healthcare:&lt;/strong&gt; Hospitals use DBMS to store patient records, medical histories, and treatment information, helping doctors and staff access important information quickly and securely.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Telecommunication:&lt;/strong&gt; Telecom companies use DBMS to keep track of user data, call records, and billing information, ensuring accurate billing and customer management.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Advantages of DBMS
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Data Integrity:&lt;/strong&gt; DBMS ensures that data is accurate and consistent across the database. For example, if a bank account balance is updated, it will be reflected in all relevant records.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Security:&lt;/strong&gt; DBMS allows access to be controlled, so only authorized users can see or edit the data. This is especially important for sensitive information like personal details or financial data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reduced Redundancy:&lt;/strong&gt; DBMS avoids the need to store the same information in multiple places, reducing duplication and making data management easier.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Sharing:&lt;/strong&gt; Multiple users can access and work on the data at the same time without interfering with each other. This allows teams to collaborate more efficiently.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Disadvantages of DBMS
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Complexity:&lt;/strong&gt; A DBMS can be complicated to set up and manage, requiring specialized knowledge and skills.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; Installing and maintaining a DBMS can be expensive, as it may involve purchasing software and hiring qualified personnel.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Increased Storage Requirements:&lt;/strong&gt; A DBMS often requires more storage space and memory than simpler systems, especially if it includes backup and security features.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maintenance Needs:&lt;/strong&gt; Regular updates and maintenance are necessary to keep the DBMS running smoothly, which can be time-consuming.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  File Management System (Flat File System)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt; A File Management System, often called a flat file system, is a way of organizing data into individual files. Each file might represent a different data category, and there is no central structure to connect these files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; Think of a file cabinet where each drawer holds a different type of document. There is no easy way to relate information across different drawers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Limitations of Flat File System
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Data Redundancy:&lt;/strong&gt; The same data may be stored in multiple files, causing duplicate information and taking up unnecessary space.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Isolation:&lt;/strong&gt; It's hard to access related data stored in separate files, making data retrieval slow and inefficient.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security Issues:&lt;/strong&gt; Flat file systems lack sophisticated security measures, making data vulnerable to unauthorized access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inconsistency:&lt;/strong&gt; Data may be different in various files, leading to errors.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Advantages of Flat File System
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Simplicity:&lt;/strong&gt; It is straightforward to use, with each file stored separately, making it easy to understand.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Low Cost:&lt;/strong&gt; Compared to DBMS, it is inexpensive as it does not require special software.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Less Hardware:&lt;/strong&gt; It usually requires less memory and storage, making it suitable for smaller data needs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Advantages of DBMS over File Management System
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Data Consistency:&lt;/strong&gt; DBMS keeps all data consistent and avoids duplication, reducing errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Improved Security:&lt;/strong&gt; DBMS provides a secure environment, ensuring only authorized users can access or modify the data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy Access:&lt;/strong&gt; It is easy to retrieve and update information as all data is stored centrally.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Better Integration:&lt;/strong&gt; DBMS connects data, allowing for more powerful data analysis and reporting.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Difference Between File-Based System and Database System
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;File-Based System&lt;/th&gt;
&lt;th&gt;Database System (DBMS)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Redundancy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;High; data often duplicated&lt;/td&gt;
&lt;td&gt;Low; data is stored centrally&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Integrity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Harder to maintain&lt;/td&gt;
&lt;td&gt;Enforced through constraints&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Security&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Limited security options&lt;/td&gt;
&lt;td&gt;Strong security controls&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Sharing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Difficult to share&lt;/td&gt;
&lt;td&gt;Easy multi-user access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Backup &amp;amp; Recovery&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Manual and unreliable&lt;/td&gt;
&lt;td&gt;Automated and reliable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Access Speed&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Slower due to file searches&lt;/td&gt;
&lt;td&gt;Faster through optimized queries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cost&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Lower but less efficient&lt;/td&gt;
&lt;td&gt;Higher but more efficient&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Participants in a Database Management System
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Actors on the Scene
&lt;/h3&gt;

&lt;p&gt;These are the primary users of the database system:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;End-Users:&lt;/strong&gt; The people who interact with the database applications to access data, like customers or employees using a bank's online system.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Application Programmers:&lt;/strong&gt; They develop applications that interact with the database, ensuring data retrieval, updates, and smooth operation for users.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database Administrators (DBAs):&lt;/strong&gt; They manage the entire database system, handle backups, ensure data security, and set user permissions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database Designers:&lt;/strong&gt; They design the database structure, decide on data types, relationships, and overall data organization to meet business needs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Workers Behind the Scene
&lt;/h3&gt;

&lt;p&gt;These individuals don't interact with the database directly but support its functionality:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;System Analysts:&lt;/strong&gt; They assess the organization's data needs, design specifications, and ensure that the database system aligns with these needs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;System Programmers:&lt;/strong&gt; These are software engineers who maintain the DBMS software itself, often working on updates, fixes, and performance improvements.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>What Exactly Is a Domain Name Server (DNS) 🌐 🔑? And How Does It Really Work? Simplified Explanation 🔍</title>
      <dc:creator>Dipsan Kadariya</dc:creator>
      <pubDate>Fri, 06 Sep 2024 17:06:42 +0000</pubDate>
      <link>https://dev.to/dipsankadariya/what-exactly-is-a-domain-name-server-dns-and-how-does-it-really-work-simplified-explanation-4iea</link>
      <guid>https://dev.to/dipsankadariya/what-exactly-is-a-domain-name-server-dns-and-how-does-it-really-work-simplified-explanation-4iea</guid>
      <description>&lt;p&gt;On the Internet, computers identify each other using unique numbers called IP addresses. An IP address (Internet Protocol address) is a unique identifier assigned to each device on a network. Since computers don't understand human language, you might wonder how websites load when you type something into a web browser, like &lt;a href="http://www.youtube.com" rel="noopener noreferrer"&gt;www.youtube.com&lt;/a&gt;. This is where DNS comes into play.&lt;/p&gt;

&lt;p&gt;If two people speak different languages, they need a translator for effective communication. Similarly, on the Internet, while computers understand IP addresses and numeric values, we are generally more familiar with English and alphabets. DNS acts as a translator between humans and computers.&lt;/p&gt;

&lt;p&gt;DNS maps domain names to their IP addresses. For example, DNS maps &lt;a href="http://www.google.com" rel="noopener noreferrer"&gt;www.google.com&lt;/a&gt; to its IP address, such as 108.177.122.139. So when a user wants to browse and look up Google, instead of remembering the IP address, we can simply use the domain name.&lt;/p&gt;

&lt;p&gt;When we type google.com into the web browser, DNS translates it into the web browser's language, which is an IP address, and provides it to the web browser. The web browser then understands that we want to access google.com, so it contacts the Google server and loads google.com on the computer.&lt;/p&gt;

&lt;p&gt;Now that we know what DNS is, To understand how DNS works internally, we need to know about DNS servers. Servers are specialized computers or software systems that provide services, resources, or data to other computers or clients over a network. Servers are computers storing HTML files, images, sounds, videos, and other file types. Servers that work together to provide the IP address of the requested website to the web browser are called DNS servers.&lt;/p&gt;

&lt;p&gt;There are four types of DNS:&lt;br&gt;
DNS recursive resolver or DNS resolver, root name server, top-level domain (TLD) name server, and authoritative name server.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. DNS Recursive Resolver (DNS Resolver)
&lt;/h2&gt;

&lt;p&gt;The DNS recursive resolver is the first point of contact in the DNS query process. It acts as an intermediary between the client (your computer or device) and other DNS servers.&lt;/p&gt;

&lt;p&gt;Key points about DNS recursive resolvers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They receive DNS queries (A DNS query is a request for information sent from a DNS client (such as your computer or smartphone) to a DNS server) from client machines through applications like web browsers.&lt;/li&gt;
&lt;li&gt;Its primary function is to find the IP address associated with a given domain name.&lt;/li&gt;
&lt;li&gt;It can cache DNS information (previous history) to speed up future requests for the same or similar queries.&lt;/li&gt;
&lt;li&gt;If the requested information isn't in their cache, they initiate a series of requests to other DNS servers to find the required information.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example scenario:&lt;br&gt;
When you type "&lt;a href="http://www.youtube.com" rel="noopener noreferrer"&gt;www.youtube.com&lt;/a&gt;" into your browser, your computer first sends this query to a DNS recursive resolver, typically provided by your Internet Service Provider (ISP).&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Root Name Server
&lt;/h2&gt;

&lt;p&gt;Root name servers are at the top of the DNS hierarchy and can be thought of as the starting point for DNS queries.&lt;/p&gt;

&lt;p&gt;Key points about root name servers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Root servers don't know the IP addresses of individual websites.&lt;/li&gt;
&lt;li&gt;Instead, they provide information about the Top-Level Domain (TLD) servers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example scenario:&lt;br&gt;
If the DNS resolver doesn't have the IP address for "&lt;a href="http://www.youtube.com" rel="noopener noreferrer"&gt;www.youtube.com&lt;/a&gt;" cached, it will ask a root server for the address of the .com TLD server.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Top-Level Domain (TLD) Name Server
&lt;/h2&gt;

&lt;p&gt;TLD name servers are responsible for maintaining information for all domain names that share a common domain extension (e.g., .com, .org).&lt;/p&gt;

&lt;p&gt;Key points about TLD name servers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They manage the next level in the hierarchy after the root servers.&lt;/li&gt;
&lt;li&gt;Common TLDs include .com, .org, .net, .edu, and country-code TLDs like .uk, .ca, .jp.&lt;/li&gt;
&lt;li&gt;They store the IP addresses of authoritative name servers for domains under their TLD.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example scenario:&lt;br&gt;
The .com TLD name server doesn't know the IP address of "&lt;a href="http://www.youtube.com" rel="noopener noreferrer"&gt;www.youtube.com&lt;/a&gt;", but it knows the address of the authoritative name server for the "youtube.com" domain.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Authoritative Name Server
&lt;/h2&gt;

&lt;p&gt;The authoritative name server is the final stop in the DNS query journey. It's the server that actually has the needed information about a specific domain.&lt;/p&gt;

&lt;p&gt;Key points about authoritative name servers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They host the DNS records for a specific domain.&lt;/li&gt;
&lt;li&gt;These records include the IP addresses associated with the domain and its subdomains.&lt;/li&gt;
&lt;li&gt;They are typically managed by the domain owner or their hosting provider.&lt;/li&gt;
&lt;li&gt;There are usually at least two authoritative name servers for each domain for redundancy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example scenario:&lt;br&gt;
The authoritative name server for "youtube.com" knows the IP address for "&lt;a href="http://www.youtube.com" rel="noopener noreferrer"&gt;www.youtube.com&lt;/a&gt;" and provides this information back through the chain to your computer.&lt;/p&gt;

&lt;h2&gt;
  
  
  The DNS Resolution Process in Detail
&lt;/h2&gt;

&lt;p&gt;Simple walk through of how DNS Work:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;User Input: You type "&lt;a href="http://www.youtube.com" rel="noopener noreferrer"&gt;www.youtube.com&lt;/a&gt;" into your web browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check Local Cache: Your computer first checks its local DNS cache to see if it has recently looked up this domain.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Query DNS Resolver: If the domain is not found locally, your computer sends a request to the DNS recursive resolver provided by your ISP.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check Resolver Cache: The resolver checks its own cache to see if it has the IP address for "&lt;a href="http://www.youtube.com." rel="noopener noreferrer"&gt;www.youtube.com.&lt;/a&gt;"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Query Root Server: If the IP address is not in the resolver's cache, it sends a query to a root name server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Root Server Response: The root server responds with the address of the TLD DNS server for .com domains.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Query TLD Server: The resolver then queries the .com TLD server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TLD Server Response: The TLD server responds with the IP address of the authoritative name server for "youtube.com."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Query Authoritative Server: The resolver queries the authoritative name server for "youtube.com."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Authoritative Server Response: The authoritative name server responds with the IP address for "&lt;a href="http://www.youtube.com." rel="noopener noreferrer"&gt;www.youtube.com.&lt;/a&gt;"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Resolver Response: The DNS resolver sends this information back to your computer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Local Storage and Browser Usage: Your computer stores the IP address in its local cache and your browser uses this IP address to access "&lt;a href="http://www.youtube.com." rel="noopener noreferrer"&gt;www.youtube.com.&lt;/a&gt;"&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thanks for reading the blog.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Computer Networks 101 💡| Understanding the Fundamentals in Networking.📶🌐</title>
      <dc:creator>Dipsan Kadariya</dc:creator>
      <pubDate>Fri, 06 Sep 2024 05:55:39 +0000</pubDate>
      <link>https://dev.to/dipsankadariya/computer-networks-101-understanding-the-fundamentals-in-networking-5ddk</link>
      <guid>https://dev.to/dipsankadariya/computer-networks-101-understanding-the-fundamentals-in-networking-5ddk</guid>
      <description>&lt;h2&gt;
  
  
  Computer Network
&lt;/h2&gt;

&lt;p&gt;Computer Network is a group of computers and other hardware devices that are linked together via communication channels to process communication and enable resource sharing among a wide range of users.&lt;/p&gt;

&lt;h2&gt;
  
  
  Uses:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Enable multiple users to share a single hardware devices like printer, scanner&lt;/li&gt;
&lt;li&gt;Enable communication among wide range of uses&lt;/li&gt;
&lt;li&gt;Easy data sharing and communication&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Advantages:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Highly flexible&lt;/li&gt;
&lt;li&gt;Inexpensive&lt;/li&gt;
&lt;li&gt;Allows resource sharing&lt;/li&gt;
&lt;li&gt;Cost efficient&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Disadvantages:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Low security&lt;/li&gt;
&lt;li&gt;Centralized &lt;/li&gt;
&lt;li&gt;Doorway for viruses and malware&lt;/li&gt;
&lt;li&gt;Requires a handler&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Network Topology
&lt;/h2&gt;

&lt;p&gt;Network Topology refers to the physical or logical layout of network. It defines the way different nodes (computer) are placed and interconnected with each other. Network Topology helps to describes the way the data is transferred into these nodes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bus topology
&lt;/h2&gt;

&lt;p&gt;Type of Network Topology where devices are connected sequentially to the same transmission line.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Low cost &lt;/li&gt;
&lt;li&gt;Simple to use&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Low security&lt;/li&gt;
&lt;li&gt;If wire fails, the network is down&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Star Topology
&lt;/h2&gt;

&lt;p&gt;Nodes are connected to a central devices like switch via cable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Most preferred way and most popular&lt;/li&gt;
&lt;li&gt;Easy to use&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If hub is down, network is also down&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Ring topology
&lt;/h2&gt;

&lt;p&gt;Nodes are connected sequentially same as bus topology but the transmission line ends at the starting node, forming a circular ring.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Overcomes the limitation of bus&lt;/li&gt;
&lt;li&gt;Fast &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Costly because of wire&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tree topology
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Nodes are connected in hierarchical network structure resembling a tree&lt;/li&gt;
&lt;li&gt;The first node is the parent node (central node, has it has multiple sub nodes connected to it)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Advantages:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;High security&lt;/li&gt;
&lt;li&gt;Scalable&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Expensive&lt;/li&gt;
&lt;li&gt;Maintenance&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Mesh Topology
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Nodes are interconnected to each other in decentralized manner&lt;/li&gt;
&lt;li&gt;Each node directly connects to multiple other devices forming a mesh like structure&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Advantages:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Flexible&lt;/li&gt;
&lt;li&gt;Scalable&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;High cost&lt;/li&gt;
&lt;li&gt;Complex structure&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Types of network:
&lt;/h2&gt;

&lt;h2&gt;
  
  
  1. Personal area network (PAN)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Small and basic network&lt;/li&gt;
&lt;li&gt;Uses mobile smartphones as the networking devices&lt;/li&gt;
&lt;li&gt;Connect devices within an individual space with few meter range&lt;/li&gt;
&lt;li&gt;Average speed and cost&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Local Area Network (LAN)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Also Simple and basic network&lt;/li&gt;
&lt;li&gt;Uses router as a networking device&lt;/li&gt;
&lt;li&gt;Connects within a limited range such as home, school or building&lt;/li&gt;
&lt;li&gt;High speed and low cost&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Wide area network (WAN)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Spans over a large geographical area, often country or continent&lt;/li&gt;
&lt;li&gt;Connects multiple LAN or MAN&lt;/li&gt;
&lt;li&gt;Used by big organizations with multiple location for connecting to the internet&lt;/li&gt;
&lt;li&gt;Uses satellite links, MPLS (Multiprotocol label switching) for networking&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Metropolitan area network (MAN)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Covers large geographical area than LAN but smaller than WAN, typically covering city or large campus&lt;/li&gt;
&lt;li&gt;Connects multiple LANs within a WAN&lt;/li&gt;
&lt;li&gt;Uses fiber optic cables or wireless broadband&lt;/li&gt;
&lt;li&gt;Used by school, campus and hospital&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Types of Networking
&lt;/h2&gt;

&lt;h2&gt;
  
  
  1. Peer to Peer Networking (p2p)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Each computer, or "peer," acts as both a client and a server&lt;/li&gt;
&lt;li&gt;No central server or administrator, instead, all peers are equal and communicate directly with each other&lt;/li&gt;
&lt;li&gt;Peers can perform all the functions of a server and a client, such as requesting data from other peers, providing data to other peers, and performing processing tasks&lt;/li&gt;
&lt;li&gt;Highly decentralized model&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Client-Server Network
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A central server or a group of servers, provide data, resources and services to multiple clients&lt;/li&gt;
&lt;li&gt;Clients are typically end-users that request services or resources from the server&lt;/li&gt;
&lt;li&gt;The server processes these requests and sends the required data or services back to the clients&lt;/li&gt;
&lt;li&gt;This establishes a clear distinction between the service providers (servers) and the service consumers (clients)&lt;/li&gt;
&lt;li&gt;Servers are dedicated machines that run server software to handle various tasks, such as hosting websites, managing databases, running applications, or controlling network access. Clients use client software to interact with the server and utilize the provided services.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Network Protocols
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Established set of rules that determine how data is transmitted between different devices&lt;/li&gt;
&lt;li&gt;Allows to connect and communicate with other users and devices&lt;/li&gt;
&lt;li&gt;Is the reason we are able to communicate easily all around the world&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Commonly used Networking Protocols
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. HTTP
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Hypertext transfer protocol&lt;/li&gt;
&lt;li&gt;Defines how data is transmitted over the internet and determines how the web browsers respond to the commands&lt;/li&gt;
&lt;li&gt;Appears at the beginning of various URLs or web address online&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. SSH (Secure Shell protocol)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Provides secure access to a computer, even on an unsecured network&lt;/li&gt;
&lt;li&gt;Particularly useful for network administrators who need to manage the system remotely&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. SMS (Short message services)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Service that allows users all around the world to communicate via text over cell&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The key elements to the protocols are:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Syntax: Structure or format of the data&lt;/li&gt;
&lt;li&gt;Semantics: Meaning of each section&lt;/li&gt;
&lt;li&gt;Timing: Time for sending data&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Networking Standards
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Standard agreed upon rules for data communications&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Types:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;De facto: Rules that are not approved as standard (not approved as a standard)&lt;/li&gt;
&lt;li&gt;De jure: Approved by the law (official)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  OSI model
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Stands for Open System Interconnection model&lt;/li&gt;
&lt;li&gt;Developed by ISO (International Standard Organization)&lt;/li&gt;
&lt;li&gt;Developed to Standardize the functions of a telecommunication or computing system into seven distinct layers for better communication between different systems and networks&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Application Layer (Layer 7)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Manages human-computer interaction and network services&lt;/li&gt;
&lt;li&gt;Handles: Services and programs that use the network to transmit and receive data, such as web browsers and email clients&lt;/li&gt;
&lt;li&gt;Includes protocols like HTTP, FTP, SMTP&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Presentation Layer (Layer 6)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Formats and encrypts data for the application layer&lt;/li&gt;
&lt;li&gt;Handles services like compression (reducing data size), encryption (unreadable format so that secure and back to the original format upon receiving)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Session Layer (Layer 5)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Manages sessions and authentication between devices&lt;/li&gt;
&lt;li&gt;Handles services like session establishment, authentication and authorization (Ensuring that connections are secure and that users have permission to access resources)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Transport Layer (Layer 4)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Ensures reliable data transfer and manages ports &lt;/li&gt;
&lt;li&gt;Handles services like managing ports and data segmentation&lt;/li&gt;
&lt;li&gt;Has protocols like TCP (Transfer Control Protocol) for reliability&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Network Layer (Layer 3)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Responsible for packet forwarding and routing between different networks&lt;/li&gt;
&lt;li&gt;Handles traffic control and logical addressing i.e., managing IP addresses&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Data Link Layer (Layer 2)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Responsible for node-to-node data transfer and error detection&lt;/li&gt;
&lt;li&gt;Handles MAC Addressing: Uses MAC addresses to identify devices on a local network&lt;/li&gt;
&lt;li&gt;Error Detection and Correction: Detects and corrects errors from the Physical layer and data formatting&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Physical Layer (Layer 1)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Responsible for: Transmitting data over a physical medium&lt;/li&gt;
&lt;li&gt;Handles the transmission and reception of raw binary data&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The TCP/IP Model
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The TCP/IP model combines OSI layers 1&amp;amp;2 (Physical, Data Link) into a single layer 1 (Network Access)&lt;/li&gt;
&lt;li&gt;Similarly layer 5,6,7 (Application, Presentation, Session) into a single layer 4 (Application)&lt;/li&gt;
&lt;li&gt;It also renames the network layer (layer 3) into Internet&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Layer 1 - Network Access
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Combines OSI layers 1 &amp;amp; 2 (Physical and Data Link)&lt;/li&gt;
&lt;li&gt;Handles the physical transmission of data and hardware-level protocols&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Layer 2 - Internet
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Renamed from the OSI Network layer (layer 3)&lt;/li&gt;
&lt;li&gt;Deals with logical addressing and routing&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Layer 3 - Transport
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Equivalent to OSI layer 4 (Transport)&lt;/li&gt;
&lt;li&gt;Manages end-to-end communication and data flow&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Layer 4 - Application
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Combines OSI layers 5, 6, &amp;amp; 7 (Session, Presentation, and Application)&lt;/li&gt;
&lt;li&gt;Handles high-level protocols and user interfaces&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Key points to remember:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The TCP/IP model is more compact than the OSI model&lt;/li&gt;
&lt;li&gt;It merges multiple OSI layers into single layers in some cases&lt;/li&gt;
&lt;li&gt;The "Internet" layer in TCP/IP is essentially a renamed "Network" layer from OSI&lt;/li&gt;
&lt;li&gt;This model is more closely aligned with how networks actually operate in practice&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Addressing in Networks
&lt;/h2&gt;

&lt;p&gt;Addressing refers to process of identifying devices or endpoints within a network.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Physical address
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Known as MAC address&lt;/li&gt;
&lt;li&gt;Used in NIC, most LAN uses 6 bytes (48 bits), each byte containing two bits, separated by colon&lt;/li&gt;
&lt;li&gt;Written as 12 hexadecimal digits&lt;/li&gt;
&lt;li&gt;Example: 07:08:1B:2C:55:7D (6 byte, 2 bits each)&lt;/li&gt;
&lt;li&gt;Included in Data Link layer&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Logical address
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A logical or IP address is used to identify a host or a network interface within a network and across networks&lt;/li&gt;
&lt;li&gt;It's assigned by software (usually dynamically via DHCP or statically)&lt;/li&gt;
&lt;li&gt;Logical addresses can change, unlike physical addresses&lt;/li&gt;
&lt;li&gt;IPv4: A 32-bit address divided into four octets (e.g., 192.168.1.1)&lt;/li&gt;
&lt;li&gt;IPv6: A 128-bit address&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Port Address
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;16 bit address represented by one decimal&lt;/li&gt;
&lt;li&gt;Port addresses are used to identify specific processes or services on a host within a network&lt;/li&gt;
&lt;li&gt;They are associated with the transport layer protocols, such as TCP and UDP, and help direct data to the correct application&lt;/li&gt;
&lt;li&gt;Example: 753&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Backbone Network
&lt;/h2&gt;

&lt;p&gt;A backbone network is the central part of a network that interconnects various smaller networks, providing a path for the exchange of information between different LANs, WANs, or subnetworks. It's responsible for carrying the bulk of data traffic across large distances or within a complex network structure.&lt;/p&gt;

&lt;p&gt;Key Points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scalability&lt;/li&gt;
&lt;li&gt;Centralized Connectivity&lt;/li&gt;
&lt;li&gt;High Capacity&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Types of Networking Devices
&lt;/h2&gt;

&lt;h2&gt;
  
  
  a) Router
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Device that connects different networks and routes data between them&lt;/li&gt;
&lt;li&gt;Uses IP address to find the best path for the data&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  b) Hub
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Connects multiple devices in a network and broadcasts the data to all&lt;/li&gt;
&lt;li&gt;There is no data filtering, so it may lead to collisions&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  c) Switch
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Connects devices and directs data to a specific destination within a network&lt;/li&gt;
&lt;li&gt;Uses MAC address to reduce collisions&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  d) Repeater
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Extends network range by amplifying signals&lt;/li&gt;
&lt;li&gt;Regenerates weakened signal over long distances&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  e) Bridge
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Connects and filters traffic between network segments&lt;/li&gt;
&lt;li&gt;Reduces traffic by forwarding data only to the correct segment&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Types of Transmission Media
&lt;/h2&gt;

&lt;h2&gt;
  
  
  a) Twisted Pair Cable
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Transmits data via copper wires twisted together to reduce interference&lt;/li&gt;
&lt;li&gt;Inexpensive and widely used for short to medium distances&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unshielded Twisted Pair (UTP): Has ability to block interference. Common in LANs (e.g., Ethernet cables)&lt;/li&gt;
&lt;li&gt;Shielded Twisted Pair (STP): Uses extra shielding to reduce electromagnetic interference&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  b) Coaxial Cable
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Transmits data through a single copper conductor surrounded by insulation and shielding&lt;/li&gt;
&lt;li&gt;Provides better shielding than twisted pair cables&lt;/li&gt;
&lt;li&gt;Commonly used in cable TV networks and older Ethernet networks&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  c) Fiber Optic Cable
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Transmits data as light pulses through glass or plastic fibers&lt;/li&gt;
&lt;li&gt;High-speed, long-distance transmission with minimal signal loss&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Single-Mode Fiber (SMF): Used for long-distance transmission (e.g., telecom networks)&lt;/li&gt;
&lt;li&gt;Multi-Mode Fiber (MMF): Used for shorter distances (e.g., within buildings)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  d) Wireless
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Electromagnetic waves that can be transmitted in all directions&lt;/li&gt;
&lt;li&gt;3kHz to 1kHz&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  e) Microwaves
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Uses microwaves for sending and receiving signals&lt;/li&gt;
&lt;li&gt;Cheaper&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Switching
&lt;/h2&gt;

&lt;p&gt;For large networks, or if very long distance transmission has to take place, it is difficult to do it without any external hardware devices. We need a dedicated path for the data to travel. Since there are many paths to take, we need to select a particular path. Selecting the path on which the data packets will be transmitted is called switching.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Circuit Switching
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A dedicated communication path is established between two devices for the duration of the session&lt;/li&gt;
&lt;li&gt;The entire bandwidth is reserved for the connection, ensuring consistent data transmission&lt;/li&gt;
&lt;li&gt;Example: Traditional telephone networks&lt;/li&gt;
&lt;li&gt;Three phases: Setup, data transfer and teardown phase&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Packet Switching
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Data is broken into smaller packets, which are sent independently across the network&lt;/li&gt;
&lt;li&gt;Packets may take different paths and are reassembled at the destination&lt;/li&gt;
&lt;li&gt;Efficient use of network resources, as no dedicated path is required&lt;/li&gt;
&lt;li&gt;Example: The Internet&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Message Switching
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Entire messages are sent from one device to another, stored temporarily at intermediate nodes, and then forwarded&lt;/li&gt;
&lt;li&gt;No dedicated path; messages are sent when a path is available&lt;/li&gt;
&lt;li&gt;Can lead to delays due to the store-and-forward nature&lt;/li&gt;
&lt;li&gt;Example: Older telegraph networks&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  DNS (Domain Name System)
&lt;/h2&gt;

&lt;p&gt;On the Internet, computers identify each other using unique numbers called IP addresses. An IP address (Internet Protocol address) is a unique identifier assigned to each device on a network. Since computers don't understand human language, you might wonder how websites load when you type something into a web browser, like &lt;a href="http://www.youtube.com" rel="noopener noreferrer"&gt;www.youtube.com&lt;/a&gt;. This is where DNS comes into play.&lt;/p&gt;

&lt;p&gt;If two people speak different languages, they need a translator for effective communication. Similarly, on the Internet, while computers understand IP addresses and numeric values, we are generally more familiar with English and alphabets. DNS acts as a translator between humans and computers.&lt;/p&gt;

&lt;p&gt;DNS maps domain names to their IP addresses. For example, DNS maps &lt;a href="http://www.google.com" rel="noopener noreferrer"&gt;www.google.com&lt;/a&gt; to its IP address, such as 108.177.122.139. So when a user wants to browse and look up Google, instead of remembering the IP address, we can simply use the domain name.&lt;/p&gt;

&lt;p&gt;When we type google.com into the web browser, DNS translates it into the web browser's language, which is an IP address, and provides it to the web browser. The web browser then understands that we want to access google.com, so it contacts the Google server and loads google.com on the computer.&lt;/p&gt;

&lt;p&gt;Now that we know what DNS is, to understand how DNS works internally, we need to know about DNS servers. Servers are specialized computers or software systems that provide services, resources, or data to other computers or clients over a network. Servers are computers storing HTML files, images, sounds, videos, and other file types. Servers that work together to provide the IP address of the requested website to the web browser are called DNS servers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Working of DNS
&lt;/h2&gt;

&lt;p&gt;DNS Working in Short:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;User Request: You type a domain name (e.g., &lt;a href="http://www.example.com" rel="noopener noreferrer"&gt;www.example.com&lt;/a&gt;) into your browser&lt;/li&gt;
&lt;li&gt;DNS Query: The browser checks its cache; if not found, it sends a query to a DNS resolver&lt;/li&gt;
&lt;li&gt;Resolver Process:

&lt;ul&gt;
&lt;li&gt;The resolver queries the root DNS server, which directs it to the TLD server (e.g., .com)&lt;/li&gt;
&lt;li&gt;The TLD server directs the query to the authoritative DNS server for the domain&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;IP Address Return: The authoritative DNS server provides the IP address for the domain&lt;/li&gt;
&lt;li&gt;Connection: The browser uses the IP address to connect to the website's server&lt;/li&gt;
&lt;li&gt;Caching: The IP address is cached for faster access in the future&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>Cover All Python Fundamentals with these 7 projects🔥 | From Quizzes to Password Manager. 🔐</title>
      <dc:creator>Dipsan Kadariya</dc:creator>
      <pubDate>Thu, 05 Sep 2024 15:17:54 +0000</pubDate>
      <link>https://dev.to/dipsankadariya/cover-all-python-fundamentals-with-these-7-projects-from-quizzes-to-password-manager-4ocp</link>
      <guid>https://dev.to/dipsankadariya/cover-all-python-fundamentals-with-these-7-projects-from-quizzes-to-password-manager-4ocp</guid>
      <description>&lt;p&gt;Making projects is the best way to take what you learn and put it into action. While these projects may seem simple and easy, they play a crucial role in building a strong foundation in Python programming. I've created these projects to cover most of the fundamentals in Python, ensuring that anyone can learn and improve their coding skills through hands-on practice.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Quiz Game
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is it?&lt;/strong&gt; A simple quiz game where the computer asks questions and the player answers them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concepts used:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lists and tuples&lt;/li&gt;
&lt;li&gt;Random module&lt;/li&gt;
&lt;li&gt;Loops&lt;/li&gt;
&lt;li&gt;Conditional statements&lt;/li&gt;
&lt;li&gt;User input handling&lt;/li&gt;
&lt;li&gt;Score tracking&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt; The game starts by welcoming the player and asking if they want to play. It then presents a series of randomized questions from a predefined list. The player's answers are checked, and their score is updated accordingly. The game provides feedback on each answer and displays the final score at the end.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;  &lt;span class="c1"&gt;# Import the random module for shuffling
&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Welcome to the Quiz Game&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Print welcome message
&lt;/span&gt;&lt;span class="n"&gt;wanna_play&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Do you want to play the game (yes/no): &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;# Ask if the user wants to play
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;wanna_play&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;yes&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# If user does not want to play, quit
&lt;/span&gt;    &lt;span class="nf"&gt;quit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Okay, then! Let&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s play&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Print message to start the game
&lt;/span&gt;
&lt;span class="c1"&gt;# Creating a list of tuples containing questions and answers 
&lt;/span&gt;&lt;span class="n"&gt;question_answer_pairs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What does CPU stand for?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Central Processing Unit&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Which programming language is known as the &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;mother of all languages&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;C&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What does HTML stand for?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;HyperText Markup Language&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="c1"&gt;# ... (more questions)
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;# Shuffle the list of tuples to ensure random order
&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;shuffle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;question_answer_pairs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="c1"&gt;# Iterate through the shuffled list of tuples 
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;correct_answer&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;question_answer_pairs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;user_answer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;# Ask the question and get user input
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;user_answer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;correct_answer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;  &lt;span class="c1"&gt;# Check if the answer is correct
&lt;/span&gt;        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Correct answer&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;  &lt;span class="c1"&gt;# Increase score for a correct answer
&lt;/span&gt;    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Incorrect answer. The correct answer is: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;correct_answer&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;  &lt;span class="c1"&gt;# Decrease score for an incorrect answer
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Current Score: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Print the final score
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Quiz over! Your final score is &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;question_answer_pairs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Number Guessing Game (Computer Guesses)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is it?&lt;/strong&gt; A number guessing game where the computer tries to guess a number chosen by the user.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concepts used:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;li&gt;Loops&lt;/li&gt;
&lt;li&gt;Conditional statements&lt;/li&gt;
&lt;li&gt;User input handling&lt;/li&gt;
&lt;li&gt;Binary search algorithm&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt; The user defines a range and chooses a number within that range. The computer then uses a binary search approach to guess the number, with the user providing feedback on whether the guess is too high, too low, or correct. The game continues until the computer guesses correctly or determines that the number is outside the specified range.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;guess_number&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Function where the computer attempts to guess a number chosen by the user within a specified range.

    The user defines the lower and upper bounds of the range and provides a number for the computer to guess.
    The computer uses a binary search approach to guess the number and the user provides feedback to guide it.
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="c1"&gt;# Get the lower bound of the range from the user
&lt;/span&gt;    &lt;span class="n"&gt;low&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter the lower range: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="c1"&gt;# Get the upper bound of the range from the user
&lt;/span&gt;    &lt;span class="n"&gt;high&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter the higher range: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="c1"&gt;# Check if the provided range is valid
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;low&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Invalid range. The higher range must be greater than the lower range.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;  &lt;span class="c1"&gt;# Exit the function if the range is invalid
&lt;/span&gt;
    &lt;span class="c1"&gt;# Get the number from the user that the computer will attempt to guess
&lt;/span&gt;    &lt;span class="n"&gt;Your_number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter your number for the computer to guess between &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; and &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="c1"&gt;# Check if the number entered by the user is within the specified range
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;Your_number&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;low&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;Your_number&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The number you entered is out of the specified range.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;  &lt;span class="c1"&gt;# Exit the function if the number is out of the range
&lt;/span&gt;
    &lt;span class="c1"&gt;# Initialize the computer's guess variable
&lt;/span&gt;    &lt;span class="n"&gt;computer_guess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;

    &lt;span class="c1"&gt;# Loop until the computer guesses the correct number
&lt;/span&gt;    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;computer_guess&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;Your_number&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Compute the computer's guess as the midpoint of the current range
&lt;/span&gt;        &lt;span class="n"&gt;computer_guess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The computer guesses: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;computer_guess&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# Get feedback from the user about the computer's guess
&lt;/span&gt;        &lt;span class="n"&gt;feedback&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Is &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;computer_guess&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; too low, too high, or correct? (Enter &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;h&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; for higher, &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;l&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; for lower, &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;c&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; for correct): &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

        &lt;span class="c1"&gt;# Process the user's feedback to adjust the guessing range
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;feedback&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;c&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;computer_guess&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;Your_number&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The computer guessed your number correctly! Congrats!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt;  &lt;span class="c1"&gt;# Exit the function once the correct number is guessed
&lt;/span&gt;            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;  
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;feedback&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;h&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;high&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;computer_guess&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;  &lt;span class="c1"&gt;# If the guess is too high, lower the upper range
&lt;/span&gt;        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;feedback&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;l&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;low&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;computer_guess&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;  &lt;span class="c1"&gt;# If the guess is too low, increase the lower range
&lt;/span&gt;        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Invalid feedback, please enter &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;h&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;, &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;l&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;, or &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;c&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Handle invalid feedback
&lt;/span&gt;
&lt;span class="c1"&gt;# Call the function to start the guessing game
&lt;/span&gt;&lt;span class="nf"&gt;guess_number&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Number Guessing Game (User Guesses)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is it?&lt;/strong&gt; A number guessing game where the user tries to guess a randomly generated number.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concepts used:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;li&gt;Random module&lt;/li&gt;
&lt;li&gt;Loops&lt;/li&gt;
&lt;li&gt;Conditional statements&lt;/li&gt;
&lt;li&gt;Exception handling&lt;/li&gt;
&lt;li&gt;User input validation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt; The computer generates a random number within a specified range. The user then makes guesses, and the program provides feedback on whether the guess is too high or too low. The game continues until the user guesses the correct number or decides to quit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;  &lt;span class="c1"&gt;# Import the random module to use its functions for generating random numbers
&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;guess_random_number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Function to allow the user to guess a random number between 1 and the specified `number`.
    This function generates a random integer between 1 and the provided `number` (inclusive).
    It then repeatedly prompts the user to guess the random number, providing feedback on whether
    the guess is too high or too low, until the correct number is guessed. The function handles
    invalid inputs by catching exceptions and informing the user to enter a valid integer.
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="c1"&gt;# Generate a random number between 1 and the specified `number` (inclusive)
&lt;/span&gt;    &lt;span class="n"&gt;random_number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;randint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;guess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;  &lt;span class="c1"&gt;# Initialize the variable `guess` to None before starting the loop
&lt;/span&gt;
    &lt;span class="c1"&gt;# Loop until the user guesses the correct number
&lt;/span&gt;    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;random_number&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="c1"&gt;# Prompt the user to enter a number between 1 and `number`
&lt;/span&gt;            &lt;span class="n"&gt;guess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter a number between 1 and &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

            &lt;span class="c1"&gt;# Provide feedback based on whether the guess is too low or too high
&lt;/span&gt;            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;random_number&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Too low, guess a greater number.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;random_number&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Too high, guess a smaller number.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="c1"&gt;# Handle the case where the user inputs something that isn't an integer
&lt;/span&gt;            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Invalid input. Please enter a valid integer.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Congratulate the user once they guess the correct number
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You have guessed the random number correctly. Congrats!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Call the function with an upper limit of 10
&lt;/span&gt;&lt;span class="nf"&gt;guess_random_number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Hangman Game
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is it?&lt;/strong&gt; A classic word guessing game where the player tries to guess a hidden word letter by letter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concepts used:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Importing modules&lt;/li&gt;
&lt;li&gt;Random selection from a list&lt;/li&gt;
&lt;li&gt;String manipulation&lt;/li&gt;
&lt;li&gt;Loops&lt;/li&gt;
&lt;li&gt;Conditional statements&lt;/li&gt;
&lt;li&gt;List comprehension&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt; The game selects a random word from a predefined list. The player then guesses letters one at a time. Correct guesses reveal the letter's position in the word, while incorrect guesses reduce the player's remaining lives. The game ends when the player guesses the entire word or runs out of lives.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;word_list&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;words&lt;/span&gt;  &lt;span class="c1"&gt;# Import the words from word_list.py file
&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;hangman&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;random_word&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Generate the random word
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;random_word&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Print the chosen word for testing purposes; remove in production
&lt;/span&gt;
    &lt;span class="n"&gt;word_display&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;_&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;random_word&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Create blank lines "_" equal to the length of the word
&lt;/span&gt;    &lt;span class="n"&gt;guessed_letters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;  &lt;span class="c1"&gt;# Empty list to store the letters that have been guessed
&lt;/span&gt;    &lt;span class="n"&gt;lives&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;  &lt;span class="c1"&gt;# Number of lives for the player
&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Welcome to Hangman!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Print welcome statement
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;word_display&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;  &lt;span class="c1"&gt;# Display the current state of the word
&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;lives&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# The game continues to run as long as the player has more than 0 lives
&lt;/span&gt;        &lt;span class="n"&gt;user_guess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter a single letter for your guess: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;# Ask the player to input a letter
&lt;/span&gt;
        &lt;span class="c1"&gt;# Check whether the player entered a valid input
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_guess&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;user_guess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isalpha&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Invalid input. Please enter a single letter.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;

        &lt;span class="c1"&gt;# Check if the letter has already been guessed
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;user_guess&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;guessed_letters&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ve already guessed &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;user_guess&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;. Try another guess.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;

        &lt;span class="c1"&gt;# Add the guessed letter to the guessed_letters list
&lt;/span&gt;        &lt;span class="n"&gt;guessed_letters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_guess&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# Check if the guessed letter is in the random_word
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;user_guess&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;random_word&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="c1"&gt;# Update word_display with the correctly guessed letter
&lt;/span&gt;            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;letter&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;random_word&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;letter&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;user_guess&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;word_display&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;user_guess&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Good guess!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;lives&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;  &lt;span class="c1"&gt;# Reduce the number of remaining lives by 1 for an incorrect guess
&lt;/span&gt;            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Wrong guess! Remaining lives: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;lives&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# Display the current state of the word
&lt;/span&gt;        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;word_display&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

        &lt;span class="c1"&gt;# Check if the player has guessed all letters
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;_&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;word_display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Congratulations, you guessed the word!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;

    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# This runs if no lives are left
&lt;/span&gt;        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You have run out of lives. The word was: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;random_word&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;hangman&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;# Function to start the game
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5.Rock Paper Scissors
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is it?&lt;/strong&gt; A classic "Rock, Paper, Scissors" game where the user plays against the computer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concepts used:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Loops&lt;/li&gt;
&lt;li&gt;Conditional statements&lt;/li&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;li&gt; Random module&lt;/li&gt;
&lt;li&gt;User input handling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt; The user chooses either rock, paper, or scissors, while the computer randomly picks one of the options as well. The program then compares the choices, determines the winner, and asks the user if they want to play again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;  &lt;span class="c1"&gt;# Import the random module to generate random choices for the computer.
&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;playGame&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# Infinite loop to keep the game running until the user decides to stop.
&lt;/span&gt;        &lt;span class="c1"&gt;# Ask the user to enter their choice and convert it to lowercase.
&lt;/span&gt;        &lt;span class="n"&gt;user_choice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; for rock, &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;p&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; for paper, &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; for scissors: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

        &lt;span class="c1"&gt;# Check if the user input is valid (i.e., 'r', 'p', or 's').
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;user_choice&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;p&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Invalid Input. Please try again.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;  &lt;span class="c1"&gt;# If the input is invalid, restart the loop.
&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You chose &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;user_choice&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Display the user's choice.
&lt;/span&gt;
        &lt;span class="c1"&gt;# Computer randomly picks one of the choices ('r', 'p', 's').
&lt;/span&gt;        &lt;span class="n"&gt;computer_choice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;p&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The computer chose &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;computer_choice&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Display the computer's choice.
&lt;/span&gt;
        &lt;span class="c1"&gt;# Check if the user's choice is the same as the computer's choice.
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;user_choice&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;computer_choice&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;It&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s a tie.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# It's a tie if both choices are the same.
&lt;/span&gt;        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="nf"&gt;_iswinner&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_choice&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;computer_choice&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You won!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# The user wins if their choice beats the computer's choice.
&lt;/span&gt;        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You lost.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# The user loses if the computer's choice beats theirs.
&lt;/span&gt;
        &lt;span class="c1"&gt;# Ask the user if they want to play again.
&lt;/span&gt;        &lt;span class="n"&gt;play_again&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Do you want to play again? Enter &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;yes&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; or &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;no&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

        &lt;span class="c1"&gt;# If the user doesn't enter 'yes', end the game.
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;play_again&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;yes&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Thank you for playing!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Thank the user for playing.
&lt;/span&gt;            &lt;span class="k"&gt;break&lt;/span&gt;  &lt;span class="c1"&gt;# Exit the loop and end the game.
&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_iswinner&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;computer&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# Determine if the user's choice beats the computer's choice.
&lt;/span&gt;    &lt;span class="c1"&gt;# Rock ('r') beats Scissors ('s'), Scissors ('s') beat Paper ('p'), Paper ('p') beats Rock ('r').
&lt;/span&gt;    &lt;span class="nf"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;computer&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;s&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;p&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;computer&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;s&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;computer&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;p&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;  &lt;span class="c1"&gt;# Return True if the user wins.
&lt;/span&gt;
&lt;span class="c1"&gt;# Start the game by calling the playGame function.
&lt;/span&gt;&lt;span class="nf"&gt;playGame&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. 2 User Tick Tack Toe
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is it&lt;/strong&gt; Tic-Tac-Toe is a classic two-player game where players take turns marking spaces on a 3x3 grid. The goal is to be the first to get three of their marks in a row, either horizontally, vertically, or diagonally. The game ends when one player achieves this, or when all spaces on the grid are filled without a winner, resulting in a draw.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Concepts used: *&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Function Definition and Calling&lt;/li&gt;
&lt;li&gt;Data Structures (2D List)&lt;/li&gt;
&lt;li&gt;Loops (for, while)&lt;/li&gt;
&lt;li&gt;Conditional Statements (if, else)&lt;/li&gt;
&lt;li&gt;Input Handling and Validation&lt;/li&gt;
&lt;li&gt;Game State Management&lt;/li&gt;
&lt;li&gt;String Formatting&lt;/li&gt;
&lt;li&gt;Exception Handling
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;print_board&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Prints the game board in a structured format with borders.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;+---+---+---+&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Print the top border of the board
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# print each row with cell values separated by borders
&lt;/span&gt;        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;| &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; | &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; |&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="c1"&gt;# print the border after each row
&lt;/span&gt;        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;+---+---+---+&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;check_winner&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Checks for a winner or a draw.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="c1"&gt;# define all possible winning lines: rows, columns, and diagonals
&lt;/span&gt;    &lt;span class="n"&gt;lines&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt;  &lt;span class="c1"&gt;# Row 1
&lt;/span&gt;        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt;  &lt;span class="c1"&gt;# Row 2
&lt;/span&gt;        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt;  &lt;span class="c1"&gt;# Row 3
&lt;/span&gt;        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt;  &lt;span class="c1"&gt;# Column 1
&lt;/span&gt;        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt;  &lt;span class="c1"&gt;# Column 2
&lt;/span&gt;        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt;  &lt;span class="c1"&gt;# Column 3
&lt;/span&gt;        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt;  &lt;span class="c1"&gt;# Diagonal from top-left to bottom-right
&lt;/span&gt;        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;   &lt;span class="c1"&gt;# Diagonal from top-right to bottom-left
&lt;/span&gt;    &lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="c1"&gt;# Check each line to see if all three cells are the same and not empty
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;  &lt;span class="c1"&gt;# Return the player ('X' or 'O') who has won
&lt;/span&gt;
    &lt;span class="c1"&gt;# Check if all cells are filled and there is no winner
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cell&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;cell&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Draw&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;  &lt;span class="c1"&gt;# Return 'Draw' if the board is full and no winner
&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;  &lt;span class="c1"&gt;# Return None if no winner and the game is not a draw
&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Main function to play the Tic Tac Toe game.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="c1"&gt;# Initialize the board with empty spaces
&lt;/span&gt;    &lt;span class="n"&gt;board&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
    &lt;span class="n"&gt;current_player&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;X&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;  &lt;span class="c1"&gt;# Start with player 'X'
&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print_board&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Print the current state of the board
&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="c1"&gt;# Prompt the current player for their move
&lt;/span&gt;            &lt;span class="n"&gt;move&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Player &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;current_player&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, enter your move (1-9): &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;move&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;move&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Convert the input to an integer
&lt;/span&gt;
            &lt;span class="c1"&gt;# Check if the move is valid (between 1 and 9)
&lt;/span&gt;            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;move&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;move&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Invalid move, try again.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;  &lt;span class="c1"&gt;# Ask for a new move
&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="c1"&gt;# Handle cases where the input is not an integer
&lt;/span&gt;            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Invalid move, try again.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;  &lt;span class="c1"&gt;# Ask for a new move
&lt;/span&gt;
        &lt;span class="c1"&gt;# Convert the move number to board coordinates (row, col)
&lt;/span&gt;        &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;divmod&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;move&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# Check if the cell is already occupied
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Cell already occupied. Choose a different cell.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;  &lt;span class="c1"&gt;# Ask for a new move
&lt;/span&gt;
        &lt;span class="c1"&gt;# Place the current player's mark on the board
&lt;/span&gt;        &lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current_player&lt;/span&gt;

        &lt;span class="c1"&gt;# Check if there is a winner or if the game is a draw
&lt;/span&gt;        &lt;span class="n"&gt;winner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;check_winner&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;winner&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print_board&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;board&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Print the final board state
&lt;/span&gt;            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;winner&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Draw&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The game is a draw!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Player &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;winner&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; wins!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Announce the winner
&lt;/span&gt;            &lt;span class="k"&gt;break&lt;/span&gt;  &lt;span class="c1"&gt;# End the game
&lt;/span&gt;
        &lt;span class="c1"&gt;# Switch players
&lt;/span&gt;        &lt;span class="n"&gt;current_player&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;O&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;current_player&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;X&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;X&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;# Start the game
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  7. Password Manager
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is it?&lt;/strong&gt; A simple password manager that allows users to store and retrieve encrypted passwords.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concepts used:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;File I/O operations&lt;/li&gt;
&lt;li&gt;Encryption using the &lt;code&gt;cryptography&lt;/code&gt; library&lt;/li&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;li&gt;Exception handling&lt;/li&gt;
&lt;li&gt;User input handling&lt;/li&gt;
&lt;li&gt;Loops&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt; The program uses the Fernet symmetric encryption from the &lt;code&gt;cryptography&lt;/code&gt; library to securely store passwords. Users can add new passwords or view existing ones. Passwords are stored in an encrypted format in a text file, and decrypted when viewed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cryptography.fernet&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Fernet&lt;/span&gt;

&lt;span class="c1"&gt;# The write_key function generates an encryption key and saves it to a file.
# It's currently commented out, but you need to run it once to create the 'key.key' file.
&lt;/span&gt;&lt;span class="sh"&gt;'''&lt;/span&gt;&lt;span class="s"&gt;
def write_key():
    key = Fernet.generate_key()
    with open(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;key.key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;, &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;wb&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;) as key_file:
        key_file.write(key)
&lt;/span&gt;&lt;span class="sh"&gt;'''&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;load_key&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;This function loads the encryption key from the &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;key.key&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; file.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="nb"&gt;file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;key.key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;rb&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;

&lt;span class="c1"&gt;# Load the key and create a Fernet object
&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;load_key&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;fer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Fernet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Function to view stored passwords in the &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;passwords.txt&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; file&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;passwords.txt&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readlines&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rstrip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;passw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;|&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;decrypted_password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;passw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;User:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;| Password:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;decrypted_password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Function to add new account names and passwords to the &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;passwords.txt&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; file&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Account Name: &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;pwd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Password: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;passwords.txt&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;a&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;encrypted_password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pwd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;|&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;encrypted_password&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Main loop to ask the user what they want to do: view passwords, add new passwords, or quit
&lt;/span&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;mode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Would you like to add a new password or view existing ones (view, add), press q to quit? &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;q&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;view&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;add&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Invalid mode.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thanks for stopping and reading the blog.&lt;br&gt;
Github Repo : &lt;a href="https://github.com/iamdipsan/Python-Projects" rel="noopener noreferrer"&gt;https://github.com/iamdipsan/Python-Projects&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>sideprojects</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Master OS Concepts 💡 | Understanding Threads, Processes &amp; IPC 🔧</title>
      <dc:creator>Dipsan Kadariya</dc:creator>
      <pubDate>Sat, 31 Aug 2024 13:41:06 +0000</pubDate>
      <link>https://dev.to/dipsankadariya/operating-systems-understanding-threads-processes-ipc-and-more-40ek</link>
      <guid>https://dev.to/dipsankadariya/operating-systems-understanding-threads-processes-ipc-and-more-40ek</guid>
      <description>&lt;h2&gt;
  
  
  Operating Systems: Concepts and Structures
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Operating systems are the backbone of modern computing, serving as the crucial interface between hardware and software. Whether you're a seasoned developer or just starting your journey in computer science, understanding the fundamentals of operating systems is essential. In this comprehensive guide, we'll explore the core concepts, structures, and mechanisms that make operating systems tick.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Dual Role of Operating Systems
&lt;/h2&gt;

&lt;p&gt;Operating system as a extended Machine acts as a intermediate between the user and Hardware. it helps in data abstraction by hiding the unnecessary details and information and provides a user friendly interface for the user to interact with the computer system.&lt;/p&gt;

&lt;p&gt;Operating system as a resource manager manages CPU memory and input output devices. it helps efficient resources allocation by ensuring that the system resources are used optimally preventing wastage of resources and maximizing the performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of OS
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Batch processing operating system is operating system that executes jobs in batches without the user interaction. The jobs are process sequentially one after another.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Multiprogramming operating system is operating system that allows multiple programs to run simultaneously. The CPU switches between the programs to maximize utilization&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Multi tasking operating system is operating system that runs multiple task t co -currently It works by rapidly switching between the task which makes it seem like they are running simultaneously.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Multiprocessor operating system is on operating system that supports multiple processor within a single system. It Distributes tasks across multiple CPUs for better performance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Network operating system is a operating system that managers network resources and communication between computers. It enables file sharing and data access over a network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Distributed operating system is a operating system that manages a group of independent computers making them appear as a single system. It facilitates resource sharing and task distribution among computers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Real time operating system is a operating system that Provides precise and predictable task execution within strict time constraints. This OS prioritizes tasks based on importance, ensuring timely completion.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  OS structure
&lt;/h2&gt;

&lt;p&gt;OS structure includes components that make up an OS.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;includes kernel, user interface, device drivers&lt;/li&gt;
&lt;li&gt;kernel: manages core functions like memory, CPU and peripheral devices&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Monolithic Structure
&lt;/h3&gt;

&lt;p&gt;In a monolithic structure, the operating system is built as a single, large kernel where all the core functions are tightly integrated. This means that everything from file management to memory management and device drivers operates within a unified space. The advantage of this structure is its high performance since components can communicate directly with each other without intermediaries. However, because all functionalities are part of the same large kernel, debugging and maintaining the system can be more challenging. Unix and early versions of Linux are examples of monolithic operating systems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layered Structure
&lt;/h3&gt;

&lt;p&gt;The layered structure organizes the operating system into a hierarchy of layers, where each layer is built on top of the previous one. This design allows for a clear separation of concerns, as each layer has its own specific responsibilities. For instance, lower layers might handle hardware interactions, while higher layers manage user interfaces. A key benefit of this structure is modularity, which makes the OS easier to develop, manage, and debug. Each layer only interacts with the one directly below it, reducing the complexity of the system as a whole. An example of a layered OS is the Windows NT architecture.&lt;/p&gt;

&lt;h3&gt;
  
  
  Microkernel Structure
&lt;/h3&gt;

&lt;p&gt;The microkernel structure focuses on minimizing the functions that run in the kernel. Only essential services, such as basic inter-process communication (IPC) and simple I/O operations, are included in the kernel. Other services, such as file systems, network protocols, and device drivers, operate in user space. This modular approach enhances the security and stability of the system, as fewer components running in kernel mode means fewer chances for critical failures. Additionally, microkernels are more extensible and easier to update or modify. Minix and QNX are examples of microkernel-based operating systems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Client-Server Model
&lt;/h3&gt;

&lt;p&gt;In the client-server model, the operating system's functions are divided between clients (user applications) and servers (OS services). The clients make requests to the servers, which provide the necessary services through inter-process communication (IPC). This model is highly suited for distributed systems, where services may run on different machines across a network. It allows for a clear separation between user-level processes and system-level services, making the OS more modular and easier to scale. An example of an OS that uses the client-server model is the Mach kernel, which influenced the development of macOS.&lt;/p&gt;

&lt;h3&gt;
  
  
  Virtual Machine Structure
&lt;/h3&gt;

&lt;p&gt;The virtual machine structure of an operating system involves creating a virtualized environment that emulates hardware, allowing multiple OS instances to run on a single physical machine. Each virtual machine operates as if it were running on its own independent hardware, with the OS managing resources and ensuring isolation between different virtual machines. This structure is particularly useful in cloud computing and environments where resource isolation and efficient use of hardware are critical. Virtualization platforms like VMware, Microsoft Hyper-V, and Xen use this structure to allow multiple operating systems to coexist on the same hardware.&lt;/p&gt;

&lt;h3&gt;
  
  
  Open-Source Operating Systems
&lt;/h3&gt;

&lt;p&gt;An open-source operating system is a type of OS whose source code is made publicly available, allowing anyone to view, modify, and distribute it. This openness encourages community collaboration, innovation, and transparency in the development process.&lt;/p&gt;

&lt;h3&gt;
  
  
  System Calls
&lt;/h3&gt;

&lt;p&gt;A system call is a mechanism that allows a program to request a service from the operating system's kernel. It provides an interface for user applications to perform operations that require privileged access to system resources, such as hardware devices, file systems, and inter-process communication.&lt;/p&gt;

&lt;p&gt;example of system call is &lt;br&gt;
key Feature: interface between user and kernel,access to system resources.&lt;/p&gt;

&lt;h2&gt;
  
  
  Process Model
&lt;/h2&gt;

&lt;p&gt;Process Model refers to the conceptual structure that describes how processes are represented and managed within an operating system. It defines how the system views a process and organizes its operations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Concepts in the Process Model
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Single-Threaded Process
&lt;/h4&gt;

&lt;p&gt;A process that contains only one thread of execution, meaning it can only execute one sequence of instructions at a time.&lt;br&gt;
Characteristics: Simple to manage, but less efficient in utilizing system resources, as it cannot perform multiple tasks simultaneously within the same process.&lt;/p&gt;

&lt;h4&gt;
  
  
  Multi-Threaded Process
&lt;/h4&gt;

&lt;p&gt;A process that contains multiple threads, each of which can execute independently but share the same resources like memory and file handles.&lt;br&gt;
Characteristics: More efficient and responsive, as it allows concurrent execution of multiple tasks within the same process, making better use of system resources.&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits of the Process Model
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Resource sharing&lt;/li&gt;
&lt;li&gt;Modularity&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Process States
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;New: The process is being created.&lt;/li&gt;
&lt;li&gt;Ready: The process is waiting to be assigned to the CPU.&lt;/li&gt;
&lt;li&gt;Running: Instructions are being executed.&lt;/li&gt;
&lt;li&gt;Waiting: The process is waiting for some event (e.g., I/O completion&lt;/li&gt;
&lt;li&gt;Terminated: The process has finished execution.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Process Control Block (PCB)
&lt;/h3&gt;

&lt;p&gt;A data structure used by the OS to store all the information about a process.&lt;/p&gt;

&lt;h4&gt;
  
  
  Components of PCB
&lt;/h4&gt;

&lt;p&gt;1) Process State: Current state of the process (new, ready, running, etc.).&lt;br&gt;
2) Program Counter: Address of the next instruction to be executed.&lt;br&gt;
3) CPU Registers: Information about the CPU's registers when the process is not running.&lt;br&gt;
4) Memory Management Information: Details on memory allocation for the process.&lt;br&gt;
5) I/O Status Information: Details about the process's I/O devices and files.&lt;br&gt;
more are identifers etc&lt;/p&gt;

&lt;h2&gt;
  
  
  Threads
&lt;/h2&gt;

&lt;p&gt;The smallest unit of processing that can be scheduled by an operating system.&lt;/p&gt;

&lt;h3&gt;
  
  
  Types of Threads
&lt;/h3&gt;

&lt;h4&gt;
  
  
  User Threads
&lt;/h4&gt;

&lt;p&gt;Definition: Managed by user-level libraries rather than directly by the OS.Advantages: Faster context switching.&lt;br&gt;
If one thread makes a blocking system call, the entire process is blocked.&lt;/p&gt;

&lt;h4&gt;
  
  
  Kernel Threads
&lt;/h4&gt;

&lt;p&gt;Managed directly by the operating system, which schedules and handles thread execution.&lt;br&gt;
multiple threads can run simultaneously on multiple processors.&lt;br&gt;
Slower context switching compared to user threads.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inter Process Communication (IPC)
&lt;/h2&gt;

&lt;p&gt;A mechanism that allows processes to communicate and synchronize their actions when they are executing concurrently.&lt;br&gt;
Essential for resource sharing, data exchange, and process synchronization in multiprogramming environments.&lt;/p&gt;

&lt;h3&gt;
  
  
  Race Condition
&lt;/h3&gt;

&lt;p&gt;Occurs when multiple processes or threads read and write shared data, and the final outcome depends on the sequence of execution, leading to unpredictable results.&lt;br&gt;
ex..Two threads incrementing the same variable simultaneously.&lt;/p&gt;

&lt;h3&gt;
  
  
  Critical Section
&lt;/h3&gt;

&lt;p&gt;A part of the code where shared resources are accessed. Proper synchronization is required to prevent race conditions.&lt;br&gt;
soln:Mechanisms like locks, semaphores, or monitors are used to ensure only one thread enters the critical section at a time.&lt;/p&gt;

&lt;h3&gt;
  
  
  IPC PROBLEMS
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Producer-Consumer Problem
&lt;/h4&gt;

&lt;p&gt;Definition:&lt;br&gt;
The Producer-Consumer Problem is a classic synchronization problem where producers generate data and put it into a buffer, while consumers take data out of the buffer. The challenge is to coordinate between them to avoid overflows and underflows.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Sleeping Barber Problem
&lt;/h4&gt;

&lt;p&gt;Definition:&lt;br&gt;
The Sleeping Barber Problem involves a barber shop with one barber and several chairs. If no customers are present, the barber sleeps. If customers arrive and all chairs are occupied, they must wait. If chairs are available, they are served immediately.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Dining Philosophers Problem
&lt;/h4&gt;

&lt;p&gt;Definition:&lt;br&gt;
The Dining Philosophers Problem involves five philosophers sitting at a round table with a fork between each pair. They need both forks to eat. The challenge is to avoid deadlock and ensure that each philosopher gets a chance to eat.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementing Mutual Exclusion
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Techniques for Mutual Exclusion
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Busy Waiting
&lt;/h4&gt;

&lt;p&gt;Definition: A technique where a process repeatedly checks a condition to achieve synchronization, consuming CPU time while waiting.&lt;br&gt;
Drawback: Wasteful use of CPU resources.&lt;/p&gt;

&lt;h4&gt;
  
  
  Disabling Interrupts
&lt;/h4&gt;

&lt;p&gt;Definition: Prevents the OS from switching processes by disabling hardware interrupts.&lt;br&gt;
Drawback: Not practical for multi-user systems because it gives the running process control over the CPU for too long.&lt;/p&gt;

&lt;h4&gt;
  
  
  Lock Variables
&lt;/h4&gt;

&lt;p&gt;Definition: A simple flag that processes can use to signal whether a resource is in use. However, this can lead to busy waiting.&lt;/p&gt;

&lt;h4&gt;
  
  
  Strict Alternation
&lt;/h4&gt;

&lt;p&gt;Definition: A simple solution for two processes, where they take turns accessing a shared resource.&lt;br&gt;
Drawback: Not efficient for more than two processes, and can cause delays.&lt;/p&gt;

&lt;h4&gt;
  
  
  Peterson's Solution
&lt;/h4&gt;

&lt;p&gt;Definition: A classic software-based solution for two processes that ensures mutual exclusion without busy waiting.&lt;br&gt;
Key Points: Relies on two variables, flag and turn, to manage access to the critical section.&lt;/p&gt;

&lt;h4&gt;
  
  
  Test and Set Lock
&lt;/h4&gt;

&lt;p&gt;Definition: A hardware instruction that atomically tests and sets a lock variable, avoiding race conditions.&lt;/p&gt;

&lt;h4&gt;
  
  
  Sleep and Wakeup
&lt;/h4&gt;

&lt;p&gt;Definition: A synchronization mechanism where processes go to sleep (stop execution) when they can't proceed and are woken up by other processes when they can continue.&lt;/p&gt;

&lt;h4&gt;
  
  
  Semaphore
&lt;/h4&gt;

&lt;p&gt;Definition: A synchronization tool that uses counters to gain access to shared resources.&lt;br&gt;
Types:&lt;br&gt;
Binary Semaphore: Can be either 0 or 1.&lt;br&gt;
Counting Semaphore: Can take any integer value.&lt;br&gt;
Operations: wait() and signal() are the primary operations.&lt;/p&gt;

&lt;h4&gt;
  
  
  Monitors
&lt;/h4&gt;

&lt;p&gt;Definition: High-level synchronization constructs that allow threads to have both mutual exclusion and the ability to wait for a certain condition to become true.&lt;br&gt;
Components: Include condition variables for wait() and signal() operations.&lt;/p&gt;

&lt;h4&gt;
  
  
  Message Passing
&lt;/h4&gt;

&lt;p&gt;Definition: A method of IPC where processes communicate by sending and receiving messages.&lt;br&gt;
Use Case: Useful in distributed systems where processes do not share memory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Batch System Scheduling
&lt;/h2&gt;

&lt;h3&gt;
  
  
  First-Come First-Served (FCFS)
&lt;/h3&gt;

&lt;p&gt;Definition: The first process to arrive is the first to be executed.&lt;br&gt;
Issue: Can cause the "convoy effect," where short processes get stuck behind long ones.&lt;/p&gt;

&lt;h3&gt;
  
  
  Shortest Job First (SJF)
&lt;/h3&gt;

&lt;p&gt;Definition: The process with the shortest burst time is executed next.&lt;br&gt;
Issue: Can cause starvation of long processes.&lt;br&gt;
Optimality: Minimizes average waiting time in the system.&lt;/p&gt;

&lt;h3&gt;
  
  
  Shortest Remaining Time Next (SRTN)
&lt;/h3&gt;

&lt;p&gt;Definition: A preemptive version of SJF where the process with the shortest remaining time is executed next.&lt;br&gt;
Advantage: Better response time for shorter processes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Interactive System Scheduling
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Round-Robin Scheduling
&lt;/h3&gt;

&lt;p&gt;Definition: Each process is assigned a fixed time slice, and if it doesn't finish in that time, it is placed back in the queue.&lt;br&gt;
Advantage: Fair and responsive.&lt;br&gt;
Time Quantum: The choice of time quantum is crucial for balancing responsiveness and overhead.&lt;/p&gt;

&lt;h3&gt;
  
  
  Priority Scheduling
&lt;/h3&gt;

&lt;p&gt;Definition: Processes are assigned priorities, and the process with the highest priority is executed first.&lt;br&gt;
Issue: Can lead to starvation if low-priority processes are never executed.&lt;br&gt;
Solution: Aging can be used to gradually increase the priority of a process waiting in the queue.&lt;/p&gt;

&lt;h3&gt;
  
  
  Multiple Queues
&lt;/h3&gt;

&lt;p&gt;Definition: Processes are divided into several queues based on priority or other criteria, with each queue having its own scheduling algorithm.&lt;br&gt;
Example: A system might have one queue for foreground (interactive) processes and another for background (batch) processes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-Time System Scheduling
&lt;/h3&gt;

&lt;p&gt;Definition: Ensures that critical processes are completed within a specific time frame.&lt;br&gt;
Use Case: Used in systems where timing is crucial (e.g., embedded systems in medical devices).&lt;/p&gt;

</description>
      <category>learning</category>
      <category>tutorial</category>
      <category>operatingsystems</category>
      <category>threads</category>
    </item>
    <item>
      <title>Master Python with Ease 🐍 | A Beginner's Guide to Python 📚</title>
      <dc:creator>Dipsan Kadariya</dc:creator>
      <pubDate>Fri, 30 Aug 2024 10:30:43 +0000</pubDate>
      <link>https://dev.to/dipsankadariya/2024-python-full-course-blog-documentation-5k</link>
      <guid>https://dev.to/dipsankadariya/2024-python-full-course-blog-documentation-5k</guid>
      <description>&lt;h2&gt;
  
  
  Python Course Code Examples
&lt;/h2&gt;

&lt;p&gt;This is a Documentation of the python code i used and created , for learning python.&lt;br&gt;
Its easy to understand and Learn.Feel free to learn from here.&lt;br&gt;
For more advanced concepts, please refer to the github repo at&lt;br&gt;
&lt;a href="https://github.com/iamdipsan/Python-for-cybersecurity" rel="noopener noreferrer"&gt;https://github.com/iamdipsan/Python-for-cybersecurity&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;First Program&lt;/li&gt;
&lt;li&gt;Variables and Data Types&lt;/li&gt;
&lt;li&gt;Strings&lt;/li&gt;
&lt;li&gt;Numbers&lt;/li&gt;
&lt;li&gt;Getting Input from Users&lt;/li&gt;
&lt;li&gt;Building a Basic Calculator&lt;/li&gt;
&lt;li&gt;First Madlibs&lt;/li&gt;
&lt;li&gt;Lists&lt;/li&gt;
&lt;li&gt;List Functions&lt;/li&gt;
&lt;li&gt;Tuples&lt;/li&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;li&gt;Return Statement&lt;/li&gt;
&lt;li&gt;If Statements&lt;/li&gt;
&lt;li&gt;If Comparisons&lt;/li&gt;
&lt;li&gt;Guessing Game 2&lt;/li&gt;
&lt;li&gt;For Loop&lt;/li&gt;
&lt;li&gt;Exponential Function&lt;/li&gt;
&lt;li&gt;2D List and For Loops&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  First Program
&lt;/h2&gt;

&lt;p&gt;This program is use to show how  print() command works.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This is a simple "Hello World" program that demonstrates basic print statements
&lt;/span&gt;
&lt;span class="c1"&gt;# Print the string "Hello world" to the console
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello world&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Print the integer 1 to the console
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Print the integer 20 to the console
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Variables and Data Types
&lt;/h2&gt;

&lt;p&gt;A variable in Python is a reserved memory location to store values.&lt;br&gt;
Data types define the type of data a variable can hold ie  integer,float, string etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This program demonstrates the use of variables and string concatenation
&lt;/span&gt;
&lt;span class="c1"&gt;# Assign the string "Dipsan" to the variable _name
&lt;/span&gt;&lt;span class="n"&gt;_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Dipsan&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# Assign the integer 20 to the variable _age
&lt;/span&gt;&lt;span class="n"&gt;_age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;

&lt;span class="c1"&gt;# Assign the string "piano" to the variable _instrument
&lt;/span&gt;&lt;span class="n"&gt;_instrument&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;piano&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# Print a sentence using string concatenation with the _name variable
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;my name is&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;_name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Print a sentence using string concatenation, converting _age to a string
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;I&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;m&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;years old&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Converting int to string for concatenation
&lt;/span&gt;
&lt;span class="c1"&gt;# Print a simple string
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;i dont like hanging out&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Print a sentence using string concatenation with the _instrument variable
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;i love &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;_instrument&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Sequences of characters used to store and manipulate text. They are created by enclosing text in single quotes ('Hello'), double quotes ("Hello"), or triple quotes for multi-line strings ('''Hello'''). Example: "Hello, World!".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This script demonstrates various string operations
&lt;/span&gt;
&lt;span class="c1"&gt;# Assign a string to the variable 'phrase'
&lt;/span&gt;&lt;span class="n"&gt;phrase&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;DipsansAcademy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# Print a simple string
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;This is a string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Concatenate strings and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;This&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;phrase&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Convert the phrase to uppercase and print
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;phrase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;span class="c1"&gt;# Convert the phrase to lowercase and print
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;phrase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;span class="c1"&gt;# Check if the uppercase version of phrase is all uppercase and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;phrase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;isupper&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;span class="c1"&gt;# Print the length of the phrase
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;phrase&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;# Print the first character of the phrase (index 0)
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;phrase&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Print the second character of the phrase (index 1)
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;phrase&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Print the fifth character of the phrase (index 4)
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;phrase&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Find and print the index of 'A' in the phrase
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;phrase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;A&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;# Replace "Dipsans" with "kadariya" in the phrase and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;phrase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Dipsans&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;kadariya&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Numbers are used for  various numeric operations and math functions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Import all functions from the math module
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;  &lt;span class="c1"&gt;# Importing math module for additional math functions
&lt;/span&gt;
&lt;span class="c1"&gt;# This script demonstrates various numeric operations and math functions
&lt;/span&gt;
&lt;span class="c1"&gt;# Print the integer 20
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Multiply 20 by 4 and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Add 20 and 4 and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Subtract 4 from 20 and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Perform a more complex calculation and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;# Calculate the remainder of 10 divided by 3 and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Assign the value 100 to the variable _num
&lt;/span&gt;&lt;span class="n"&gt;_num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;

&lt;span class="c1"&gt;# Print the value of _num
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Convert _num to a string, concatenate with other strings, and print
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; is my fav number&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Converting int to string for concatenation
&lt;/span&gt;
&lt;span class="c1"&gt;# Assign -10 to the variable new_num
&lt;/span&gt;&lt;span class="n"&gt;new_num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;

&lt;span class="c1"&gt;# Print the absolute value of new_num
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;abs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new_num&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;  &lt;span class="c1"&gt;# Absolute value
&lt;/span&gt;
&lt;span class="c1"&gt;# Calculate 3 to the power of 2 and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;     &lt;span class="c1"&gt;# Power function
&lt;/span&gt;
&lt;span class="c1"&gt;# Find the maximum of 2 and 3 and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;     &lt;span class="c1"&gt;# Maximum
&lt;/span&gt;
&lt;span class="c1"&gt;# Find the minimum of 2 and 3 and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;     &lt;span class="c1"&gt;# Minimum
&lt;/span&gt;
&lt;span class="c1"&gt;# Round 3.2 to the nearest integer and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;3.2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;    &lt;span class="c1"&gt;# Rounding
&lt;/span&gt;
&lt;span class="c1"&gt;# Round 3.7 to the nearest integer and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;3.7&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;# Calculate the floor of 3.7 and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;3.7&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;    &lt;span class="c1"&gt;# Floor function
&lt;/span&gt;
&lt;span class="c1"&gt;# Calculate the ceiling of 3.7 and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;ceil&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;3.7&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;     &lt;span class="c1"&gt;# Ceiling function
&lt;/span&gt;
&lt;span class="c1"&gt;# Calculate the square root of 36 and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;      &lt;span class="c1"&gt;# Square root
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Getting Input from Users
&lt;/h2&gt;

&lt;p&gt;This program is used to  show how to use the &lt;code&gt;input()&lt;/code&gt; function to get user input:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This script demonstrates how to get user input and use it in string concatenation
&lt;/span&gt;
&lt;span class="c1"&gt;# Prompt the user to enter their name and store it in the 'name' variable
&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter your name : &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Prompt the user to enter their age and store it in the 'age' variable
&lt;/span&gt;&lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter your age. : &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Print a greeting using the user's input, concatenating strings
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;hello &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; Youre age is &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; .&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Building a Basic Calculator
&lt;/h2&gt;

&lt;p&gt;This program creates a simple calculator that adds two numbers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This script creates a basic calculator that adds two numbers
&lt;/span&gt;
&lt;span class="c1"&gt;# Prompt the user to enter the first number and store it in 'num1'
&lt;/span&gt;&lt;span class="n"&gt;num1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter first number : &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Prompt the user to enter the second number and store it in 'num2'
&lt;/span&gt;&lt;span class="n"&gt;num2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter second number: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Convert the input strings to integers and add them, storing the result
&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Print the result of the addition
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  First Madlibs
&lt;/h2&gt;

&lt;p&gt;This program creates a simple Mad Libs game:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This program is used to create a simple Mad Libs game.
&lt;/span&gt;
&lt;span class="c1"&gt;# Prompt the user to enter an adjective and store it in 'adjective1'
&lt;/span&gt;&lt;span class="n"&gt;adjective1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter an adjective: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Prompt the user to enter an animal and store it in 'animal'
&lt;/span&gt;&lt;span class="n"&gt;animal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter an animal: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Prompt the user to enter a verb and store it in 'verb'
&lt;/span&gt;&lt;span class="n"&gt;verb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter a verb: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Prompt the user to enter another adjective and store it in 'adjective2'
&lt;/span&gt;&lt;span class="n"&gt;adjective2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter another adjective: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Print the first sentence of the Mad Libs story using string concatenation
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;I have a &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;adjective1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;animal&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Print the second sentence of the Mad Libs story
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;It likes to &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;verb&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; all day.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Print the third sentence of the Mad Libs story
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;My &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;animal&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; is so &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;adjective2&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;A list is a collection of items in Python that is ordered and changeable. Each item (or element) in a list has an index, starting from 0. Lists can contain items of different data types (like integers, strings, or even other lists).&lt;br&gt;
A list is defined using square brackets [], with each item separated by a comma.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This script demonstrates basic list operations
&lt;/span&gt;
&lt;span class="c1"&gt;# Create a list of friends' names
&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Roi&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;alex&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;jimmy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;joseph&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;# Print the entire list
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Print the first element of the list (index 0)
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Print the second element of the list (index 1)
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Print the third element of the list (index 2)
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Print the fourth element of the list (index 3)
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Print the last element of the list using negative indexing
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Print a slice of the list from the second element to the end
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:])&lt;/span&gt;

&lt;span class="c1"&gt;# Print a slice of the list from the second element to the third (exclusive)
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Change the second element of the list to "kim"
&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;kim&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# Print the modified list
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  List Functions
&lt;/h2&gt;

&lt;p&gt;This script showcases various list methods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This script demonstrates various list functions and methods
&lt;/span&gt;
&lt;span class="c1"&gt;# Create a list of numbers
&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;88&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;34&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;# Create a list of friends' names
&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Roi&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;alex&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;jimmy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;joseph&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;kevin&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;tony&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;jimmy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;# Print both lists
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Add all elements from 'numbers' to the end of 'friends'
&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Add "hulk" to the end of the 'friends' list
&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;hulk&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Insert "mikey" at index 1 in the 'friends' list
&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mikey&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Remove the first occurrence of "Roi" from the 'friends' list
&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Roi&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Print the index of "mikey" in the 'friends' list
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mikey&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;# Remove and print the last item in the 'friends' list
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;span class="c1"&gt;# Print the current state of the 'friends' list
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Remove all elements from the 'friends' list
&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# Print the empty 'friends' list
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Sort the 'numbers' list in ascending order
&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# Print the sorted 'numbers' list
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;A tuple is a collection of items in Python that is ordered but unchangeable (immutable). Once you create a tuple, you cannot add, remove, or change its elements. Like lists, tuples can contain items of different data types.&lt;br&gt;
 A tuple is defined using parentheses (), with each item separated by a comma.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This script introduces tuples and their immutability
&lt;/span&gt;
&lt;span class="c1"&gt;# Create a tuple with two elements
&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Print the entire tuple
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Print the second element of the tuple (index 1)
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# The following line would cause an IndexError if uncommented:
# print(values[2])  # This would cause an IndexError
&lt;/span&gt;
&lt;span class="c1"&gt;# The following line would cause a TypeError if uncommented:
# values[1] = 30    # This would cause a TypeError as tuples are immutable
&lt;/span&gt;
&lt;span class="c1"&gt;# The following line would print the modified tuple if the previous line worked:
# print(values)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Functions
&lt;/h2&gt;

&lt;p&gt;A function is a block of reusable code that performs a specific task. Functions can take inputs (called arguments), process them, and return an output. Functions help organize code, make it more modular, and avoid repetition.&lt;br&gt;
n Python, a function is defined using the def keyword, followed by the function name, parentheses (), and a colon :. The code inside the function is indented. &lt;br&gt;
This code demonstrates how to define and call functions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This script demonstrates how to define and call functions
&lt;/span&gt;
&lt;span class="c1"&gt;# Define a function called 'greetings' that prints two lines
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;greetings&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;HI, Welcome to programming world of python&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;keep learning&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Print a statement before calling the function
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;this is first statement&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Call the 'greetings' function
&lt;/span&gt;&lt;span class="nf"&gt;greetings&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# Print a statement after calling the function
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;this is last statement&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Define a function 'add' that takes two parameters and prints their sum
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num2&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;# Call the 'add' function with arguments 3 and 4
&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Return Statement
&lt;/h2&gt;

&lt;p&gt;he return statement is used in a function to send back (or "return") a value to the caller. When return is executed, it ends the function, and the value specified after return is sent back to where the function was called.&lt;/p&gt;

&lt;p&gt;This program shows how to use the &lt;code&gt;return&lt;/code&gt; statement in functions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This script demonstrates the use of return statements in functions
&lt;/span&gt;
&lt;span class="c1"&gt;# Define a function 'square' that returns the square of a number
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt;
    &lt;span class="c1"&gt;# Any code after the return statement won't execute
&lt;/span&gt;
&lt;span class="c1"&gt;# Call the 'square' function with argument 2 and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;# Call the 'square' function with argument 4 and print the result
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;# Call the 'square' function with argument 3, store the result, then print it
&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;The if statement evaluates a condition (an expression that returns True or False).&lt;br&gt;
If the condition is True, the block of code under the if statement is executed.&lt;br&gt;
elif : Short for "else if," it allows you to check multiple conditions.&lt;br&gt;
It is used when you have multiple conditions to evaluate, and you want to execute a block of code for the first True condition.&lt;br&gt;
else: The else statement runs a block of code if none of the preceding if or elif conditions are True.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This script demonstrates the use of if-elif-else statements
&lt;/span&gt;
&lt;span class="c1"&gt;# Set boolean variables for conditions
&lt;/span&gt;&lt;span class="n"&gt;is_boy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="n"&gt;is_handsome&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;

&lt;span class="c1"&gt;# Check conditions using if-elif-else statements
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;is_boy&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;is_handsome&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;you are a boy &amp;amp; youre handsome&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;hehe&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;is_boy&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;is_handsome&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Youre a boy but sorry not handsome&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;youre not a boy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  If Comparisons
&lt;/h2&gt;

&lt;p&gt;This code demonstrates comparison operations in if statements:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This script demonstrates comparison operations in if statements
&lt;/span&gt;
&lt;span class="c1"&gt;# Define a function to find the maximum of three numbers
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;max_numbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num3&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;num1&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;num2&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;num1&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;num3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;num1&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;num2&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;num1&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;num2&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;num3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;num2&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;num3&lt;/span&gt;

&lt;span class="c1"&gt;# Test the max_numbers function with different inputs
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;max_numbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;max_numbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;max_numbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;For min_number&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Define a function to find the minimum of three numbers
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;min_numbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num3&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;num1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;num2&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;num1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;num3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;num1&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;num2&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;num1&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;num2&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;num3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;num2&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;num3&lt;/span&gt;

&lt;span class="c1"&gt;# Test the min_numbers function with different inputs
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;min_numbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;min_numbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;min_numbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Guessing Game 2
&lt;/h2&gt;

&lt;p&gt;This script improves the guessing game with more features:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This script improves the guessing game with more features
&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;

&lt;span class="c1"&gt;# Generate a random number between 1 and 20
&lt;/span&gt;&lt;span class="n"&gt;secret_number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;randint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Initialize the number of attempts and set a limit
&lt;/span&gt;&lt;span class="n"&gt;attempts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="n"&gt;attempt_limit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;

&lt;span class="c1"&gt;# Loop to allow the user to guess the number
&lt;/span&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;attempts&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;attempt_limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;guess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Guess the number (between 1 and 20). You have &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;attempt_limit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;attempts&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; attempts left: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;secret_number&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Congratulations! You guessed the number!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;secret_number&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Too low!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Too high!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;attempts&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="c1"&gt;# If the user does not guess correctly within the attempt limit, reveal the number
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;secret_number&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Sorry, the correct number was &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;secret_number&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  For Loop
&lt;/h2&gt;

&lt;p&gt;A for loop is used to iterate over a sequence of elements, such as a list, tuple, string, or range. &lt;br&gt;
This code introduces the for loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# List of numbers
&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;# Iterate over each number in the list
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Print the current number
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Output:
# 1
# 2
&lt;/span&gt;


&lt;span class="c1"&gt;# 3
# 4
# 5
&lt;/span&gt;
&lt;span class="c1"&gt;# List of friends
&lt;/span&gt;&lt;span class="n"&gt;friends&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Roi&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;alex&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;jimmy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;joseph&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;kevin&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;tony&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;jimmy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;# Iterate over each friend in the list
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;friend&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Print the name of the current friend
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;friend&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Output:
# Roi
# alex
# jimmy
# joseph
# kevin
# tony
# jimmy
&lt;/span&gt;
&lt;span class="c1"&gt;# Use range to generate numbers from 0 to 4
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Output:
# 0
# 1
# 2
# 3
# 4
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Exponential Function
&lt;/h2&gt;

&lt;p&gt;Exponential functions are mathematical functions where a constant base is raised to a variable exponent.&lt;br&gt;
This script shows how to use the &lt;code&gt;math.pow&lt;/code&gt; function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This script demonstrates the use of the exponential function
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;exponentialFunction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;power&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;power&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;exponentialFunction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;exponentialFunction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;exponentialFunction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;#or you can power just by
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;#number *** power
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2D List and For Loops
&lt;/h2&gt;

&lt;p&gt;A 2D list (or 2D array) in Python is essentially a list of lists, where each sublist represents a row of the matrix. You can use nested for loops to iterate over elements in a 2D list. Here’s how you can work with 2D lists and for loops:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This script demonstrates the use of 2D List and For Loops
# Define a 2D list (list of lists)
&lt;/span&gt;&lt;span class="n"&gt;num_grid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;  &lt;span class="c1"&gt;# Row 0: contains 1, 2, 3
&lt;/span&gt;    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;  &lt;span class="c1"&gt;# Row 1: contains 4, 5, 6
&lt;/span&gt;    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;  &lt;span class="c1"&gt;# Row 2: contains 7, 8, 9
&lt;/span&gt;    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;         &lt;span class="c1"&gt;# Row 3: contains a single value 0
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;# Print specific elements in num_grid
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_grid&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;   &lt;span class="c1"&gt;# Print value in the zeroth row, zeroth column (value: 1)
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_grid&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;   &lt;span class="c1"&gt;# Print value in the first row, zeroth column (value: 4)
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_grid&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;   &lt;span class="c1"&gt;# Print value in the second row, second column (value: 9)
&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;using nested for loops&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;num_grid&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is how we can use 2D List and For Loops.&lt;/p&gt;

&lt;p&gt;The reference material for this blog was from Mike form  FreeCodeCamp.org. Thank you.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
      <category>ai</category>
    </item>
    <item>
      <title>SQL 101 📊 | A Guide to Basic Commands for Beginners 💡</title>
      <dc:creator>Dipsan Kadariya</dc:creator>
      <pubDate>Thu, 29 Aug 2024 11:26:16 +0000</pubDate>
      <link>https://dev.to/dipsankadariya/introduction-to-sql-and-basic-commands-11o7</link>
      <guid>https://dev.to/dipsankadariya/introduction-to-sql-and-basic-commands-11o7</guid>
      <description>&lt;h2&gt;
  
  
  Introduction to SQL
&lt;/h2&gt;

&lt;h2&gt;
  
  
  What is SQL?
&lt;/h2&gt;

&lt;p&gt;SQL (Structured Query Language) is a standard programming language used for managing and manipulating relational databases. It allows users to create, read, update, and delete data within a database. SQL provides a way to interact with databases using simple, declarative statements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Learn SQL?
&lt;/h2&gt;

&lt;p&gt;Learning SQL is essential for several reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Data Management&lt;/strong&gt;: SQL is the primary language for managing and querying relational databases, which are widely used in various applications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Career Opportunities&lt;/strong&gt;: Proficiency in SQL is a valuable skill for many IT and data-related roles, including database administrators, data analysts, and software developers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Analysis&lt;/strong&gt;: SQL enables you to perform complex data analysis and reporting tasks, making it easier to extract valuable insights from large datasets.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Versatility&lt;/strong&gt;: SQL is used in many popular database systems, such as MySQL, PostgreSQL, and Microsoft SQL Server, making it a versatile skill across different platforms.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  SQL Database and Table Operations Guide
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Database Operations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Creating a Database
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;DATABASE&lt;/span&gt; &lt;span class="n"&gt;FirstDB&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: FirstDB is the database name.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using a Database
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;USE&lt;/span&gt; &lt;span class="n"&gt;FirstDB&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: This selects the database for use.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dropping a Database
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;DROP&lt;/span&gt; &lt;span class="k"&gt;DATABASE&lt;/span&gt; &lt;span class="n"&gt;FirstDB&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: This permanently deletes the database and all its contents.&lt;/p&gt;

&lt;h3&gt;
  
  
  Altering Database (Set to Read-Only)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;DATABASE&lt;/span&gt; &lt;span class="n"&gt;FirstDB&lt;/span&gt; &lt;span class="k"&gt;READ&lt;/span&gt; &lt;span class="k"&gt;ONLY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: This makes the database read-only, preventing any modifications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table Operations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Creating a Table
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;student&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;student_id&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;first_name&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;last_name&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;student_address&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;hourly_pay&lt;/span&gt; &lt;span class="nb"&gt;DECIMAL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;student_date&lt;/span&gt; &lt;span class="nb"&gt;DATE&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: This creates a table named 'student' with specified columns and data types.&lt;/p&gt;

&lt;h3&gt;
  
  
  Selecting All Data from a Table
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;student&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: This retrieves all rows and columns from the 'student' table.&lt;/p&gt;

&lt;h3&gt;
  
  
  Renaming a Table
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;RENAME&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;student&lt;/span&gt; &lt;span class="k"&gt;TO&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: This changes the table name from 'student' to 'students'.&lt;/p&gt;

&lt;h2&gt;
  
  
  Altering Table Structure
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Adding a New Column
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt;
&lt;span class="k"&gt;ADD&lt;/span&gt; &lt;span class="n"&gt;phone_number&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: This adds a new column 'phone_number' to the 'students' table.&lt;/p&gt;

&lt;h3&gt;
  
  
  Renaming a Column
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt;
&lt;span class="n"&gt;CHANGE&lt;/span&gt; &lt;span class="n"&gt;phone_number&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: This changes the column name from 'phone_number' to 'email' and modifies its data type.&lt;/p&gt;

&lt;h3&gt;
  
  
  Modifying a Column's Data Type
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt; 
&lt;span class="k"&gt;MODIFY&lt;/span&gt; &lt;span class="k"&gt;COLUMN&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: This changes the data type of the 'email' column to VARCHAR(100).&lt;/p&gt;

&lt;h3&gt;
  
  
  Changing a Column's Position
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt;
&lt;span class="k"&gt;MODIFY&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AFTER&lt;/span&gt; &lt;span class="n"&gt;last_name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: This moves the 'email' column to be after the 'last_name' column.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt;
&lt;span class="k"&gt;MODIFY&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;FIRST&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: This moves the 'email' column to be the first column in the table.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dropping a Column
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt;
&lt;span class="k"&gt;DROP&lt;/span&gt; &lt;span class="k"&gt;COLUMN&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: This permanently removes the 'email' column from the table.&lt;/p&gt;

&lt;h3&gt;
  
  
  Combining Multiple Operations
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt;
&lt;span class="k"&gt;MODIFY&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AFTER&lt;/span&gt; &lt;span class="n"&gt;last_name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;students&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: This changes the column position and then displays the new table structure in one operation.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>mysql</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Automate Git Commands with Shell Scripts 🚀 | Boost Your Workflow 📜</title>
      <dc:creator>Dipsan Kadariya</dc:creator>
      <pubDate>Thu, 29 Aug 2024 10:36:46 +0000</pubDate>
      <link>https://dev.to/dipsankadariya/git-commands-automation-using-shell-script-2blj</link>
      <guid>https://dev.to/dipsankadariya/git-commands-automation-using-shell-script-2blj</guid>
      <description>&lt;h2&gt;
  
  
  Git Automation Script
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;This repository contains a PowerShell script designed to automate common Git operations.This script is designed to work globally across any project on your system.Once configured, the script simplifies the process of staging changes, committing with a message, and pushing updates to a remote repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Automate Git Operations&lt;/strong&gt;: Add all changes, commit with a message, and push to the remote repository with a single command.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy to Use&lt;/strong&gt;: Run the script with a custom commit message to handle the Git workflow.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setup Instructions
&lt;/h2&gt;

&lt;p&gt;Follow these steps to set up and use the &lt;code&gt;git-automation.ps1&lt;/code&gt; script:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Create the Script
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;In a text editor, create a new file and save it as &lt;code&gt;git-automation.ps1&lt;/code&gt; (or any preferred name).&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add the following content to the file:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="kr"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;$args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Length&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-eq&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nv"&gt;$COMMIT_MSG&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Auto-commit"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;else&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nv"&gt;$COMMIT_MSG&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="bp"&gt;$args&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;commit&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-m&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$COMMIT_MSG&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  2. Create a Directory for the Script
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Open PowerShell and run:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;mkdir&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;C:\Scripts&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Move your script to this directory:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;move&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;C:\Users\dipsa\Desktop\git-automation.ps1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;C:\Scripts\&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  3. Add the Directory to PATH
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Click "Environment Variables."&lt;/li&gt;
&lt;li&gt;In "System variables," select &lt;code&gt;Path&lt;/code&gt; and click "Edit."&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click "New" and add:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Scripts
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click "OK" to save and close the dialog boxes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  4. Set Execution Policy
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Open PowerShell and run:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;Set-ExecutionPolicy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;RemoteSigned&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-Scope&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;CurrentUser&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Confirm by typing &lt;code&gt;Y&lt;/code&gt; if prompted.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;To use the script, run the following command from any project directory:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
powershell
git-automation.ps1 "commit-message"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>automation</category>
      <category>git</category>
      <category>githubactions</category>
      <category>streamline</category>
    </item>
    <item>
      <title>The OSI and TCP/IP Network Reference Models 🌐Explained 🛠️</title>
      <dc:creator>Dipsan Kadariya</dc:creator>
      <pubDate>Thu, 29 Aug 2024 10:25:47 +0000</pubDate>
      <link>https://dev.to/dipsankadariya/the-osi-and-tcpip-network-reference-models-2m60</link>
      <guid>https://dev.to/dipsankadariya/the-osi-and-tcpip-network-reference-models-2m60</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Models that provide abstract representation of how data is transmitted over a network.&lt;/li&gt;
&lt;li&gt;Each model is described by a so-called stack of layers, because each layer is dependent on its adjacent layers.&lt;/li&gt;
&lt;li&gt;The OSI stack has 7 such layers and TCP/IP stack has 4.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The OSI Model
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Stands for Open System Interconnection Model and was created by ISO (International Standards Organization) in the 1970's as a way to organize the efforts around the creation of new networking protocols, and to provide a common perspective for the existing network protocols at the time.&lt;/li&gt;
&lt;li&gt;The OSI model has 7 layers, the bottom 4 layers are referred to as "media" layers and are used for performing tasks like data transport, addressing and data delivery. The top 3 layers are referred to as "Host" layers that use the media layers to enable communication between applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Breakdown of each layer:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Application Layer (Layer-7)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Responsible for Human-Computer interaction.&lt;/li&gt;
&lt;li&gt;Handles services and programs that use the network to transmit and receive data, such as web browsers and email clients.&lt;/li&gt;
&lt;li&gt;Includes protocols like HTTP, FTP, SMTP, and DNS.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Presentation layer (Layer-6)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Responsible for formatting and presentation of data. &lt;/li&gt;
&lt;li&gt;This layer handles things like compression/decompression, encryption/decryption, and encoding/decoding. Basically, ensuring the data is in a usable format for the next layer (Layer 5 if sending data, Layer 7 if receiving it).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Session layer (Layer-5)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Responsible for Managing Communication between devices.&lt;/li&gt;
&lt;li&gt;This layer is responsible for setting up, maintaining, and tearing down sessions, in addition to performing functions like authentication and authorization. This ensures connections between clients are opened for as long as needed to transfer data, then torn down as soon as the transfer is complete.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Transport Layer (Layer-4)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Responsible for Transporting data between hosts.&lt;/li&gt;
&lt;li&gt;This is the layer that handles ports, like HTTP at port 80, HTTPS at port 443. Being responsible for data delivery, this layer also handles breaking large data transfers into pieces for delivery, and then reconstituting them at the other end.&lt;/li&gt;
&lt;li&gt;There are two main protocols that are used at this layer: TCP and UDP.

&lt;ol&gt;
&lt;li&gt;TCP (Transmission Control Protocol):&lt;/li&gt;
&lt;li&gt;Reliable, ensures data arrives correctly&lt;/li&gt;
&lt;li&gt;Checks for errors and lost packets&lt;/li&gt;
&lt;li&gt;Slower due to these checks&lt;/li&gt;
&lt;li&gt;UDP (User Datagram Protocol):&lt;/li&gt;
&lt;li&gt;Faster but less reliable&lt;/li&gt;
&lt;li&gt;Doesn't check for errors or lost packets&lt;/li&gt;
&lt;li&gt;Better for streaming media, gaming&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Network Layer (Layer-3)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This layer handles packet forwarding and routing between different networks, i.e., routing!&lt;/li&gt;
&lt;li&gt;Provides logical addressing (e.g., IP addresses).&lt;/li&gt;
&lt;li&gt;Manages traffic control and packet sequencing.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Data Link Layer (Layer-2)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Responsible for providing node-to-node data transfer.&lt;/li&gt;
&lt;li&gt;Detects and possibly corrects errors from the Physical layer.&lt;/li&gt;
&lt;li&gt;Defines how data is formatted for transmission.&lt;/li&gt;
&lt;li&gt;Includes MAC (Media Access Control) addressing.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Physical Layer (Layer-1)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Responsible for Transmitting data over a physical medium, such as a cable or over-the-air.&lt;/li&gt;
&lt;li&gt;Defines hardware specifications (cables, switches, network interface cards).&lt;/li&gt;
&lt;li&gt;Handles the transmission and reception of raw bit streams.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ol&gt;

&lt;h2&gt;
  
  
  The TCP/IP Model
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The TCP/IP model combines OSI layers 1 &amp;amp; 2 (Physical, Data Link) into a single layer 1 (Network Access).&lt;/li&gt;
&lt;li&gt;Similarly, layers 5, 6, 7 (Application, Presentation, Session) are combined into a single layer 4 (Application).&lt;/li&gt;
&lt;li&gt;It also renames the network layer (layer 3) to Internet.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Layer 1 - Network Access:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Combines OSI layers 1 &amp;amp; 2 (Physical and Data Link)&lt;/li&gt;
&lt;li&gt;Handles the physical transmission of data and hardware-level protocols&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Layer 2 - Internet:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Renamed from the OSI Network layer (layer 3)&lt;/li&gt;
&lt;li&gt;Deals with logical addressing and routing&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Layer 3 - Transport:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Equivalent to OSI layer 4 (Transport)&lt;/li&gt;
&lt;li&gt;Manages end-to-end communication and data flow&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Layer 4 - Application:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Combines OSI layers 5, 6, &amp;amp; 7 (Session, Presentation, and Application)&lt;/li&gt;
&lt;li&gt;Handles high-level protocols and user interfaces&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Notes:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The TCP/IP model is more compact than the OSI model.&lt;/li&gt;
&lt;li&gt;It merges multiple OSI layers into single layers in some cases.&lt;/li&gt;
&lt;li&gt;The "Internet" layer in TCP/IP is essentially a renamed "Network" layer from OSI.&lt;/li&gt;
&lt;li&gt;This model is more closely aligned with how networks actually operate in practice.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>osimodel</category>
      <category>networking</category>
      <category>cybersecurity</category>
      <category>tcpipmodel</category>
    </item>
    <item>
      <title>Linux Basics 📂 | Essential Commands Every Beginner Should Know 📝</title>
      <dc:creator>Dipsan Kadariya</dc:creator>
      <pubDate>Thu, 29 Aug 2024 10:08:19 +0000</pubDate>
      <link>https://dev.to/dipsankadariya/essential-linux-commands-for-beginners-5akl</link>
      <guid>https://dev.to/dipsankadariya/essential-linux-commands-for-beginners-5akl</guid>
      <description>&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Sudo su&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frt2dhevep4mnnsras88u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frt2dhevep4mnnsras88u.png" alt="Terminal showing sudo su command" width="400" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;"sudo" stands for "superuser do". It allows a permitted user to execute a command as the superuser or another user.&lt;br&gt;
"su" stands for "switch user".&lt;br&gt;
The hyphen (-) at the end is a shorthand for "-l" or "--login", which provides a full login shell.&lt;br&gt;
(This is just for knowing, not necessary used for now)...just knowing is good.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;pwd (Print Working Directory)&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyajorz1mmts289ppojra.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyajorz1mmts289ppojra.png" alt="Terminal showing pwd command and output" width="400" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The pwd command shows your current location in the file system.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;ls (List Directory Contents)&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy24pto9fv5mrr0dv66qz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy24pto9fv5mrr0dv66qz.png" alt="Terminal showing ls command and output" width="400" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The ls command lists files and directories in your current location.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;ls -la (Detailed List View)&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1fxhumoe2yd2r7ca01be.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1fxhumoe2yd2r7ca01be.png" alt="Terminal showing ls -la command and detailed output" width="400" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Adding the &lt;code&gt;-la&lt;/code&gt; options to &lt;code&gt;ls&lt;/code&gt; provides a detailed, long-format list that includes hidden files, hidden files have "." in front of them.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;cd (Change Directory)&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flqxjcfrpxyxmtuc0ms5f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flqxjcfrpxyxmtuc0ms5f.png" alt="Terminal showing cd command changing to Desktop directory" width="400" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Initially we were in /home/kali, when we write cd Desktop, path changes to /home/kali/Desktop.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;cd .. (Reverse Directory)&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnsbtc3c6ecc1bhmf2a2i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnsbtc3c6ecc1bhmf2a2i.png" alt="Terminal showing cd .. command moving back to parent directory" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This command helps to go back to the previous directory.&lt;/li&gt;
&lt;li&gt;Let's say you are in Desktop directory but you want to go back to kali directory&lt;/li&gt;
&lt;li&gt;You can do it by typing:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  cd ..
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Mkdir (Make a new Subdirectory)&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faymlrg9wpcwx7bh6nsor.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faymlrg9wpcwx7bh6nsor.png" alt="Terminal showing mkdir command creating a new directory" width="400" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is used to make a new folder. Let's make a new folder in the Desktop by first changing the directory to Desktop, and typing:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  mkdir filename
&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;  mkdir helloworld
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a folder named helloworld in the Desktop.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;touch&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frghoo1awwh13x7at0kdu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frghoo1awwh13x7at0kdu.png" alt="Terminal showing touch command creating a new file" width="400" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The primary purpose of the &lt;code&gt;touch&lt;/code&gt; command is to update the access and/or modification date of a file or directory. However, it can also be used to create a file if it doesn't exist. &lt;/li&gt;
&lt;li&gt;Let's create a file named &lt;code&gt;file.txt&lt;/code&gt; in the &lt;code&gt;helloworld&lt;/code&gt; folder. The first step would be changing the directory to the &lt;code&gt;helloworld&lt;/code&gt; folder if not done, then typing:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  touch file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;cp (copy)&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3xzecvvyie0zntrm7xse.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3xzecvvyie0zntrm7xse.png" alt="Terminal showing cp command copying a file" width="400" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let's say we want to copy the file.txt to a new folder named "newfolder", we can do it by first creating a newfolder in the desktop, now the desktop will have two folders, one being the helloworld folder which contains the file.txt and a new empty folder named "newfolder"&lt;/li&gt;
&lt;li&gt;To copy the file.txt what we can do is, type:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  cp ~/Desktop/helloworld/file.txt ~/Desktop/newfolder/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Basically what we are doing is, taking the path of the file.txt i.e. ~/Desktop/helloworld/file.txt (which is inside helloworld folder in desktop) and copying it to where we want to copy it, i.e. ~/Desktop/newfolder/ (inside newfolder).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;mv (move)&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv9pu1e3fehddnujhi1rv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv9pu1e3fehddnujhi1rv.png" alt="Terminal showing mv command moving a file" width="400" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's say we want to move the file.txt from "helloworld" folder to "newfolder", so that helloworld folder has nothing inside, and only the newfolder will have file.txt inside it.&lt;br&gt;
We can do it by typing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mv ~/Desktop/helloworld/file.txt ~/Desktop/newfolder/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here too, basically what we are doing is, taking the path of the file.txt i.e. ~/Desktop/helloworld/file.txt (which is inside helloworld folder in desktop) and moving it to where we want to move it, i.e. ~/Desktop/newfolder/ (inside newfolder).&lt;/p&gt;

</description>
      <category>linux</category>
      <category>linuxcommands</category>
      <category>networking</category>
      <category>filenavigationcommands</category>
    </item>
  </channel>
</rss>
