<?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: Kailas Warade</title>
    <description>The latest articles on DEV Community by Kailas Warade (@kailas_warade_d2a15d1ef8a).</description>
    <link>https://dev.to/kailas_warade_d2a15d1ef8a</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4126500%2F91be8ee8-0234-427e-a917-f6338418cd5d.png</url>
      <title>DEV Community: Kailas Warade</title>
      <link>https://dev.to/kailas_warade_d2a15d1ef8a</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kailas_warade_d2a15d1ef8a"/>
    <language>en</language>
    <item>
      <title>5 Common SQL Mistakes: WHERE, ORDER BY, AND/OR, and Top 3 Queries</title>
      <dc:creator>Kailas Warade</dc:creator>
      <pubDate>Thu, 29 Oct 2026 03:31:06 +0000</pubDate>
      <link>https://dev.to/kailas_warade_d2a15d1ef8a/5-common-sql-mistakes-where-order-by-andor-and-top-3-queries-3k9c</link>
      <guid>https://dev.to/kailas_warade_d2a15d1ef8a/5-common-sql-mistakes-where-order-by-andor-and-top-3-queries-3k9c</guid>
      <description>&lt;p&gt;A SQL query can execute without errors and still produce an unexpected result.&lt;/p&gt;

&lt;p&gt;It might return the wrong employees, sort salaries incorrectly, or select the wrong three records.&lt;/p&gt;

&lt;p&gt;The issue often lies in how you use "WHERE", "ORDER BY", logical operators, and row-limiting clauses.&lt;/p&gt;

&lt;p&gt;Let's explore five practical SQL examples using a simple employee table.&lt;/p&gt;

&lt;p&gt;Sample Data&lt;/p&gt;

&lt;p&gt;Assume we have the following "employees" table:&lt;/p&gt;

&lt;p&gt;ID| Name| Dept| Salary&lt;br&gt;
101| Amit| IT| 60000&lt;br&gt;
102| Priya| HR| 45000&lt;br&gt;
103| Rahul| IT| 75000&lt;br&gt;
104| Neha| Fin| 55000&lt;br&gt;
105| Sneha| IT| 60000&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Filter Rows Using WHERE&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Question: Find employees earning more than ₹50,000.&lt;/p&gt;

&lt;p&gt;SELECT emp_id, name, salary&lt;br&gt;
FROM employees&lt;br&gt;
WHERE salary &amp;gt; 50000;&lt;/p&gt;

&lt;p&gt;This query returns Amit, Rahul, Neha, and Sneha.&lt;/p&gt;

&lt;p&gt;Common mistake: Using "&amp;gt;=" instead of "&amp;gt;" changes the result when an employee earns exactly ₹50,000.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"&amp;gt;" means greater than.&lt;/li&gt;
&lt;li&gt;"&amp;gt;=" means greater than or equal to.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Always choose the comparison operator that matches the business requirement.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sort Salaries Correctly&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Question: Display employees from the highest salary to the lowest.&lt;/p&gt;

&lt;p&gt;SELECT name, salary&lt;br&gt;
FROM employees&lt;br&gt;
ORDER BY salary DESC;&lt;/p&gt;

&lt;p&gt;Remember:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"DESC" sorts from highest to lowest.&lt;/li&gt;
&lt;li&gt;"ASC" sorts from lowest to highest.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Interview tip: Without "ORDER BY", SQL does not guarantee the order of returned rows.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Combine Filtering and Sorting&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Question: Find IT employees earning more than ₹50,000 and display the highest salary first.&lt;/p&gt;

&lt;p&gt;SELECT name, salary&lt;br&gt;
FROM employees&lt;br&gt;
WHERE dept = 'IT'&lt;br&gt;
  AND salary &amp;gt; 50000&lt;br&gt;
ORDER BY salary DESC;&lt;/p&gt;

&lt;p&gt;The query first identifies employees who satisfy both conditions and then sorts the qualifying rows by salary.&lt;/p&gt;

&lt;p&gt;Expected result:&lt;/p&gt;

&lt;p&gt;Name| Salary&lt;br&gt;
Rahul| 75000&lt;br&gt;
Amit| 60000&lt;br&gt;
Sneha| 60000&lt;/p&gt;

&lt;p&gt;Notice that Amit and Sneha have the same salary. Their relative order is not guaranteed because the query does not specify a secondary sort key.&lt;/p&gt;

&lt;p&gt;This pattern is useful in employee reports, sales analysis, and dashboards.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Avoid AND/OR Logic Errors&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Question: Find employees who work in IT or earn more than ₹60,000, provided their salary is at least ₹50,000.&lt;/p&gt;

&lt;p&gt;SELECT name, dept, salary&lt;br&gt;
FROM employees&lt;br&gt;
WHERE (dept = 'IT' OR salary &amp;gt; 60000)&lt;br&gt;
  AND salary &amp;gt;= 50000;&lt;/p&gt;

&lt;p&gt;The parentheses make the intended logic explicit.&lt;/p&gt;

&lt;p&gt;In SQL, "AND" has higher precedence than "OR". Without parentheses, a condition combining both operators can return unintended results.&lt;/p&gt;

&lt;p&gt;Interview tip: When a requirement contains both "AND" and "OR", group the conditions carefully before writing the query.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Find the Top 3 Highest-Paid Employees&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Question: Return the three highest-paid employees.&lt;/p&gt;

&lt;p&gt;SELECT emp_id, name, salary&lt;br&gt;
FROM employees&lt;br&gt;
ORDER BY salary DESC, emp_id ASC&lt;br&gt;
LIMIT 3;&lt;/p&gt;

&lt;p&gt;The query sorts by salary in descending order and uses "emp_id" as a secondary sort key.&lt;/p&gt;

&lt;p&gt;Because Amit and Sneha both earn ₹60,000, the secondary sort makes their relative order predictable.&lt;/p&gt;

&lt;p&gt;Important: "LIMIT" works in MySQL and PostgreSQL. Other database systems may use different row-limiting syntax.&lt;/p&gt;

&lt;p&gt;Also, "LIMIT 3" returns at most three rows. If you need to include everyone tied at the third-highest salary, consider using a ranking function such as "RANK()".&lt;/p&gt;

&lt;p&gt;One Small Change Can Affect Your Report&lt;/p&gt;

&lt;p&gt;Compare these conditions:&lt;/p&gt;

&lt;p&gt;WHERE salary &amp;gt; 50000&lt;/p&gt;

&lt;p&gt;WHERE salary &amp;gt;= 50000&lt;/p&gt;

&lt;p&gt;The difference is just one character, but the second condition also includes employees earning exactly ₹50,000.&lt;/p&gt;

&lt;p&gt;In real reporting, small differences like this can affect totals, eligibility checks, and business decisions.&lt;/p&gt;

&lt;p&gt;Continue Learning SQL&lt;/p&gt;

&lt;p&gt;Want to practise more questions about filtering, sorting, and SQL interview preparation?&lt;/p&gt;

&lt;p&gt;Explore the "SQL FAQ tutorial on restricting and sorting data" (&lt;a href="https://www.sankalandtech.com/Tutorials/sql-plsql-faq-interview/restricting-sorting-data-sql-faq.html" rel="noopener noreferrer"&gt;https://www.sankalandtech.com/Tutorials/sql-plsql-faq-interview/restricting-sorting-data-sql-faq.html&lt;/a&gt;) from Sankalan Data Tech for more topic-focused examples.&lt;/p&gt;

&lt;p&gt;Final SQL Challenge&lt;/p&gt;

&lt;p&gt;Suppose the "employees" table contains thousands of records.&lt;/p&gt;

&lt;p&gt;How would you find the second-highest distinct salary without using "LIMIT" or "TOP"?&lt;/p&gt;

&lt;p&gt;Try solving it with a subquery before looking up the answer. This is a useful exercise for SQL interviews.&lt;/p&gt;

&lt;p&gt;Share your approach in the comments!&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>tutorial</category>
      <category>sqlserver</category>
    </item>
    <item>
      <title>SQL SELECT Statement: Practical Examples for Interview Preparation</title>
      <dc:creator>Kailas Warade</dc:creator>
      <pubDate>Wed, 28 Oct 2026 03:19:20 +0000</pubDate>
      <link>https://dev.to/kailas_warade_d2a15d1ef8a/sql-select-statement-practical-examples-for-interview-preparation-547f</link>
      <guid>https://dev.to/kailas_warade_d2a15d1ef8a/sql-select-statement-practical-examples-for-interview-preparation-547f</guid>
      <description>&lt;p&gt;The "SELECT" statement is one of the first things you learn when working with SQL. But knowing the syntax is only the beginning. In real projects, you need to retrieve the right columns, filter records, remove duplicates, sort results, and calculate useful information from tables.&lt;/p&gt;

&lt;p&gt;Let's understand how the SQL "SELECT" statement works through practical examples using an employee table.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Understanding the SELECT Statement&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Suppose you have an "employees" table containing employee details.&lt;/p&gt;

&lt;p&gt;Table: employees&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;id&lt;/th&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;dept&lt;/th&gt;
&lt;th&gt;salary&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;101&lt;/td&gt;
&lt;td&gt;Amit&lt;/td&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;td&gt;60000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;102&lt;/td&gt;
&lt;td&gt;Priya&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;td&gt;45000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;103&lt;/td&gt;
&lt;td&gt;Rahul&lt;/td&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;td&gt;75000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;104&lt;/td&gt;
&lt;td&gt;Neha&lt;/td&gt;
&lt;td&gt;Finance&lt;/td&gt;
&lt;td&gt;55000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;105&lt;/td&gt;
&lt;td&gt;Sneha&lt;/td&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;td&gt;65000&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Imagine your manager asks you to prepare a list of employees working in the IT department, including their names and salaries.&lt;/p&gt;

&lt;p&gt;You don't need every column in the table. You only need the information requested.&lt;/p&gt;

&lt;p&gt;SQL Solution&lt;/p&gt;

&lt;p&gt;SELECT name, salary&lt;br&gt;
FROM employees&lt;br&gt;
WHERE dept = 'IT';&lt;/p&gt;

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

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;salary&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Amit&lt;/td&gt;
&lt;td&gt;60000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rahul&lt;/td&gt;
&lt;td&gt;75000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sneha&lt;/td&gt;
&lt;td&gt;65000&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The query retrieves only the required columns and returns employees whose department is IT.&lt;/p&gt;

&lt;p&gt;Let's look at a few more situations you may encounter while working with SQL.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Retrieve All Columns from a Table&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Sometimes you need to see all available columns.&lt;/p&gt;

&lt;p&gt;SELECT *&lt;br&gt;
FROM employees;&lt;/p&gt;

&lt;p&gt;The asterisk ("*") retrieves all columns from the table.&lt;/p&gt;

&lt;p&gt;It is useful when exploring a dataset, but in production queries, explicitly listing the required columns often makes the code easier to maintain and avoids retrieving unnecessary data.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Filter Records Using WHERE&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Suppose you want to find employees earning more than ₹60,000.&lt;/p&gt;

&lt;p&gt;SELECT name, salary&lt;br&gt;
FROM employees&lt;br&gt;
WHERE salary &amp;gt; 60000;&lt;/p&gt;

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

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;salary&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Rahul&lt;/td&gt;
&lt;td&gt;75000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sneha&lt;/td&gt;
&lt;td&gt;65000&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The "WHERE" clause filters rows based on a condition. You can also combine conditions using "AND" and "OR".&lt;/p&gt;

&lt;p&gt;For example, to find IT employees earning more than ₹60,000:&lt;/p&gt;

&lt;p&gt;SELECT name, salary&lt;br&gt;
FROM employees&lt;br&gt;
WHERE dept = 'IT'&lt;br&gt;
  AND salary &amp;gt; 60000;&lt;/p&gt;

&lt;p&gt;This returns Rahul and Sneha.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Find Unique Values Using DISTINCT&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Suppose you want to identify all departments represented in the employee table.&lt;/p&gt;

&lt;p&gt;SELECT DISTINCT dept&lt;br&gt;
FROM employees;&lt;/p&gt;

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

&lt;h2&gt;
  
  
  dept
&lt;/h2&gt;

&lt;p&gt;IT&lt;br&gt;
HR&lt;br&gt;
Finance&lt;/p&gt;

&lt;p&gt;Without "DISTINCT", the IT department would appear multiple times because several employees belong to it.&lt;/p&gt;

&lt;p&gt;Remember that "DISTINCT" applies to the combination of all selected columns, not just the first column.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sort Records Using ORDER BY&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A salary report is often easier to understand when employees are listed from highest to lowest salary.&lt;/p&gt;

&lt;p&gt;SELECT name, salary&lt;br&gt;
FROM employees&lt;br&gt;
ORDER BY salary DESC;&lt;/p&gt;

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

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;salary&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Rahul&lt;/td&gt;
&lt;td&gt;75000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sneha&lt;/td&gt;
&lt;td&gt;65000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Amit&lt;/td&gt;
&lt;td&gt;60000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Neha&lt;/td&gt;
&lt;td&gt;55000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Priya&lt;/td&gt;
&lt;td&gt;45000&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Use "DESC" for descending order and "ASC" for ascending order.&lt;/p&gt;

&lt;p&gt;If two employees have the same salary, you can add another sorting column to make the result order more predictable.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Calculate Department-Wise Employee Counts&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The "SELECT" statement also works with aggregate functions.&lt;/p&gt;

&lt;p&gt;Suppose the HR team wants to know how many employees work in each department.&lt;/p&gt;

&lt;p&gt;SELECT dept, COUNT(*) AS employee_count&lt;br&gt;
FROM employees&lt;br&gt;
GROUP BY dept;&lt;/p&gt;

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

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;dept&lt;/th&gt;
&lt;th&gt;employee_count&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Finance&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Here, "COUNT(*)" counts rows in each group, while "GROUP BY" groups employees by department.&lt;/p&gt;

&lt;p&gt;This type of query is useful for reports, dashboards, and workforce analysis.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Filter Groups Using HAVING&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now suppose you only want departments with more than one employee.&lt;/p&gt;

&lt;p&gt;SELECT dept, COUNT(&lt;em&gt;) AS employee_count&lt;br&gt;
FROM employees&lt;br&gt;
GROUP BY dept&lt;br&gt;
HAVING COUNT(&lt;/em&gt;) &amp;gt; 1;&lt;/p&gt;

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

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;dept&lt;/th&gt;
&lt;th&gt;employee_count&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The difference between "WHERE" and "HAVING" is important:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"WHERE" filters individual rows before grouping.&lt;/li&gt;
&lt;li&gt;"HAVING" filters groups after aggregation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a common topic in SQL interviews.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Common SQL SELECT Interview Questions&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here are a few questions worth practising:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is the difference between "SELECT *" and selecting specific columns?&lt;/li&gt;
&lt;li&gt;How does "DISTINCT" work?&lt;/li&gt;
&lt;li&gt;What is the difference between "WHERE" and "HAVING"?&lt;/li&gt;
&lt;li&gt;How do you sort query results in descending order?&lt;/li&gt;
&lt;li&gt;Can you use aggregate functions with "GROUP BY"?&lt;/li&gt;
&lt;li&gt;How would you find the second-highest salary?&lt;/li&gt;
&lt;li&gt;What is the difference between "COUNT(*)" and "COUNT(column_name)"?&lt;/li&gt;
&lt;li&gt;How do you handle NULL values in SQL?&lt;/li&gt;
&lt;li&gt;What is the logical order of SQL query processing?&lt;/li&gt;
&lt;li&gt;How would you retrieve employees whose salaries are above the company average?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Try writing the queries yourself before looking up the answers. Understanding why a query works is more valuable than memorising its syntax.&lt;/p&gt;

&lt;p&gt;For more questions, detailed explanations, and additional examples, you can refer to this "SQL SELECT Statement Interview Questions and Answers guide" (&lt;a href="https://www.sankalandtech.com/Tutorials/sql-plsql-faq-interview/retrieving-data-sql-select-statement-interview-questions-faq.html" rel="noopener noreferrer"&gt;https://www.sankalandtech.com/Tutorials/sql-plsql-faq-interview/retrieving-data-sql-select-statement-interview-questions-faq.html&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Final Thoughts&lt;/p&gt;

&lt;p&gt;The "SELECT" statement is much more than a way to display table data. Combined with filtering, sorting, grouping, and aggregate functions, it becomes a practical tool for solving everyday database problems.&lt;/p&gt;

&lt;p&gt;If you're preparing for SQL interviews or working towards a data analytics or data engineering role, practise these queries on your own tables. Start with simple questions and gradually move to joins, subqueries, CTEs, and window functions.&lt;/p&gt;

&lt;p&gt;Your turn: Which SQL concept do you find most challenging: joins, subqueries, "GROUP BY", or window functions?&lt;/p&gt;

&lt;p&gt;Share your experience in the comments. I'd be interested to hear what you're practising.&lt;/p&gt;

&lt;h1&gt;
  
  
  SQL #SQLTutorial #SQLInterviewQuestions #Database #DataAnalytics
&lt;/h1&gt;

</description>
      <category>sql</category>
      <category>tutorial</category>
      <category>database</category>
      <category>learning</category>
    </item>
    <item>
      <title>Why Your SQL Query Returns the Wrong Rows (And How WHERE and ORDER BY Fix It)</title>
      <dc:creator>Kailas Warade</dc:creator>
      <pubDate>Sun, 25 Oct 2026 08:28:57 +0000</pubDate>
      <link>https://dev.to/kailas_warade_d2a15d1ef8a/why-your-sql-query-returns-the-wrong-rows-and-how-where-and-order-by-fix-it-5b1f</link>
      <guid>https://dev.to/kailas_warade_d2a15d1ef8a/why-your-sql-query-returns-the-wrong-rows-and-how-where-and-order-by-fix-it-5b1f</guid>
      <description>&lt;p&gt;A colleague spent twenty minutes on a query once. It was returning the top ten orders correctly. Then she added a WHERE clause and the wrong orders started coming back.&lt;/p&gt;

&lt;p&gt;She assumed the WHERE was broken. It wasn't. She thought LIMIT 10 ran first, and the sort happened on those ten rows. The database doesn't work that way. It sorts everything, then trims. She drew it on a whiteboard and never made the same mistake again.&lt;/p&gt;

&lt;p&gt;I've taught WHERE and ORDER BY many times. Every group has someone who gets stuck on the same three things: NULL sorting, aggregate in WHERE, missing parentheses. They're not hard ideas. They're just the three places where people's gut feeling is wrong.&lt;/p&gt;

&lt;p&gt;Here's where the gut feeling is wrong.&lt;/p&gt;

&lt;p&gt;The database runs your query in a different order than you wrote it&lt;br&gt;
You write top to bottom. The database runs it in a completely different order.&lt;/p&gt;

&lt;p&gt;FROM, then WHERE, then GROUP BY, then HAVING, then SELECT, then ORDER BY, then LIMIT.&lt;/p&gt;

&lt;p&gt;That's the whole pipeline. Once you can picture it, half of SQL stops being confusing.&lt;/p&gt;

&lt;p&gt;WHERE runs second. It sees one row at a time, before anything has been grouped. So when you try to write WHERE COUNT(*) &amp;gt; 5, the database has no idea what you mean. The count doesn't exist yet. That error message you get? It's not the database being difficult. It's saying "you asked for this too early."&lt;/p&gt;

&lt;p&gt;ORDER BY runs sixth. By that point the database has the full result in front of it, aliases and all. So ORDER BY line_total works even when line_total is only defined in the SELECT list. It can see it. WHERE can't.&lt;/p&gt;

&lt;p&gt;I used to memorise this order for exams and forget it a week later. What made it stick was debugging. Once you've stared at a slow query and traced it through the pipeline a few times, it stops being something you memorise and starts being something you can see.&lt;/p&gt;

&lt;p&gt;WHERE, and the one mistake everyone makes&lt;br&gt;
WHERE keeps the rows you asked for and throws away the rest.&lt;/p&gt;

&lt;p&gt;It's also the biggest speed win you have. &lt;br&gt;
If WHERE cuts the rows by 20x, everything after it has 20x less work. &lt;br&gt;
If a report is slow, WHERE is the first place to look.&lt;br&gt;
Not the last.&lt;/p&gt;

&lt;p&gt;Some patterns you'll use all the time:&lt;/p&gt;

&lt;p&gt;WHERE credit_limit &amp;gt; 50000&lt;br&gt;
 for a straight comparison.&lt;/p&gt;

&lt;p&gt;WHERE region = 'North' AND credit_limit &amp;gt; 60000 when you need two conditions to be true at once.&lt;/p&gt;

&lt;p&gt;WHERE customer_name LIKE 'A%' for pattern matching. &lt;/p&gt;

&lt;p&gt;The % is any sequence of characters, _ is exactly one.&lt;/p&gt;

&lt;p&gt;WHERE region IN ('North', 'South') when you have a short list and don't want to chain ORs.&lt;br&gt;
 And WHERE order_amount BETWEEN 5000 AND 20000 when both ends should be included.&lt;/p&gt;

&lt;p&gt;Then there's the one that gets everyone: WHERE credit_limit IS NULL.&lt;/p&gt;

&lt;p&gt;If you write WHERE credit_limit = NULL, you get zero rows. No error.&lt;/p&gt;

&lt;p&gt;No warning. Just an empty result that looks like a bug.&lt;/p&gt;

&lt;p&gt;NULL isn't equal to anything. Not even another NULL. So the comparison fails without telling you.&lt;/p&gt;

&lt;p&gt;Always use IS NULL or IS NOT NULL.&lt;/p&gt;

&lt;p&gt;I've made this mistake more times than I'd like to admit. I've also watched people with fifteen years of experience make it. There's no shame in it. There's just a fix.&lt;/p&gt;

&lt;p&gt;One more thing on WHERE.&lt;br&gt;
 SQL checks AND before OR. So A OR B AND C is read as A OR (B AND C). Not (A OR B) AND C.&lt;/p&gt;

&lt;p&gt;When your intent is mixed, add parentheses. I've watched this one break more production reports than any other single mistake in SQL.&lt;/p&gt;

&lt;p&gt;ORDER BY — putting the result in the order you want&lt;br&gt;
ORDER BY sorts the final result. It runs after SELECT, so it can see everything SELECT can see.&lt;/p&gt;

&lt;p&gt;Default is ascending. ORDER BY credit_limit puts the smallest first. DESC reverses it.&lt;/p&gt;

&lt;p&gt;Multiple sort keys work left to right. ORDER BY region ASC, credit_limit DESC sorts by region first, then by credit limit inside each region. That's the pattern behind almost every report. One column to organise by, one to rank within.&lt;/p&gt;

&lt;p&gt;You can sort by a column you didn't select. The output can be narrower than the sort. That works because ORDER BY runs after SELECT, which still has the original columns. Clean report, correct order, no compromise.&lt;/p&gt;

&lt;p&gt;You can sort by an alias too. ORDER BY adjusted_limit DESC works when adjusted_limit is defined in the SELECT list. You can't do the same in WHERE, because the alias doesn't exist yet. That's how you know WHERE runs before ORDER BY. Comes up in interviews a lot.&lt;/p&gt;

&lt;p&gt;If the column you're sorting by has an index, the database reads in that order and skips the sort. On a small table you won't notice. On a table with tens of millions of rows, it's the difference between a second and a minute. When a report gets slow, ORDER BY is the first thing I check.&lt;/p&gt;

&lt;p&gt;The NULL sorting problem&lt;br&gt;
NULL isn't zero. It isn't an empty string. It's the absence of a value, so it can't be compared like a number or a word.&lt;/p&gt;

&lt;p&gt;Which means different databases sort it differently.&lt;/p&gt;

&lt;p&gt;Oracle and PostgreSQL put NULLs last in ascending order, first in descending.&lt;/p&gt;

&lt;p&gt;MySQL and SQL Server do the opposite. NULLs come first in ascending, last in descending.&lt;/p&gt;

&lt;p&gt;This is exactly the kind of bug that works on your machine and breaks on the server. It's a portability problem, not a logic problem, and it only shows up when you move code from development to production.&lt;/p&gt;

&lt;p&gt;Oracle and PostgreSQL let you be explicit. ORDER BY credit_limit ASC NULLS LAST puts the customer with no credit limit at the bottom.&lt;/p&gt;

&lt;p&gt;MySQL and SQL Server don't support NULLS FIRST or NULLS LAST. You sort a computed column instead, like ORDER BY ISNULL(credit_limit, 999999) or ORDER BY credit_limit IS NULL, credit_limit. Different mechanics, same result.&lt;/p&gt;

&lt;p&gt;If a report depends on where NULLs appear, be explicit. The default is never safe across databases.&lt;/p&gt;

&lt;p&gt;WHERE vs HAVING, and why this is the question that catches people&lt;br&gt;
Both clauses filter. They're completely different in what they do.&lt;/p&gt;

&lt;p&gt;WHERE filters rows before any grouping. One row at a time. Aggregates don't exist yet.&lt;/p&gt;

&lt;p&gt;HAVING filters groups after GROUP BY has produced them. It sees the grouped result. So it can hold SUM, AVG, COUNT.&lt;/p&gt;

&lt;p&gt;Try to swap them and the database stops you with an error about aggregate functions in WHERE. That error isn't the database being difficult. It's saying "you asked for this too early." Same error message as before. Same reason.&lt;/p&gt;

&lt;p&gt;You'll often want both. Filter to delivered orders only with WHERE. Group by customer. Keep only the customers whose delivered average is above 5,000 with HAVING.&lt;/p&gt;

&lt;p&gt;The reason to do the WHERE first is not just correctness. It's speed. Filter early means fewer rows to group. On a large table that small win adds up.&lt;/p&gt;

&lt;p&gt;Six mistakes I keep seeing&lt;br&gt;
Two of these come up in every training session I run. The other four are the ones I used to make myself.&lt;/p&gt;

&lt;p&gt;Putting an aggregate in WHERE. WHERE COUNT(*) &amp;gt; 5 throws an error because the count doesn't exist when WHERE runs. Move it to HAVING.&lt;/p&gt;

&lt;p&gt;Assuming NULL sorts the same way everywhere. It doesn't. Oracle and PostgreSQL put NULLs last in ascending. MySQL and SQL Server put them first. If the query might run on more than one database, be explicit about NULL placement.&lt;/p&gt;

&lt;p&gt;The other four, quickly.&lt;/p&gt;

&lt;p&gt;BETWEEN on a timestamp column doesn't cover the whole end date.&lt;br&gt;
 It stops at midnight. Use &amp;gt;= '2024-01-01' AND &amp;lt; '2024-02-01', &lt;/p&gt;

&lt;p&gt;or cast the timestamp to a date first.&lt;/p&gt;

&lt;p&gt;WHERE credit_limit = NULL returns zero rows silently. No error. Use IS NULL.&lt;/p&gt;

&lt;p&gt;AND before OR. SQL checks AND first, so add parentheses when the intent is mixed.&lt;/p&gt;

&lt;p&gt;ORDER BY runs before LIMIT. Not after. The pipeline sorts first, then trims.&lt;/p&gt;

&lt;p&gt;What this article doesn't cover&lt;br&gt;
Those six are the ones that break production. They aren't the full picture.&lt;/p&gt;

&lt;p&gt;The guide on my site covers twenty-four interview questions on these two clauses. How NULL sorts in every major database. How to sort by a column you didn't select. How to make ORDER BY faster on a huge table.&lt;/p&gt;

&lt;p&gt;How WHERE and HAVING work together when you need both. The follow-up questions interviewers actually ask after the first answer.&lt;/p&gt;

&lt;p&gt;There are sample tables you can run against, worked examples for every clause, and a quiz at the bottom.&lt;/p&gt;

&lt;p&gt;That full walkthrough is here:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Restricting and Sorting Data   in SQL: WHERE and ORDER BY Explained&lt;/strong&gt;(&lt;a href="https://www.sankalandtech.com/Tutorials/sql-plsql-faq-interview/restricting-sorting-data-sql-faq.html" rel="noopener noreferrer"&gt;https://www.sankalandtech.com/Tutorials/sql-plsql-faq-interview/restricting-sorting-data-sql-faq.html&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Six here, twenty-four there. That's what the page has that I can't fit into a Dev.to post.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>sqlserver</category>
      <category>interview</category>
    </item>
    <item>
      <title>A Single SQL Constraint Can Save Your Database From Bad Data — Do You Know Which One?</title>
      <dc:creator>Kailas Warade</dc:creator>
      <pubDate>Thu, 22 Oct 2026 03:41:46 +0000</pubDate>
      <link>https://dev.to/kailas_warade_d2a15d1ef8a/a-single-sql-constraint-can-save-your-database-from-bad-data-do-you-know-which-one-4cbc</link>
      <guid>https://dev.to/kailas_warade_d2a15d1ef8a/a-single-sql-constraint-can-save-your-database-from-bad-data-do-you-know-which-one-4cbc</guid>
      <description>&lt;p&gt;Imagine you are building an order management system.&lt;/p&gt;

&lt;p&gt;Your "customers" table contains 10,000 customers. Your "orders" table contains 500,000 orders.&lt;/p&gt;

&lt;p&gt;Everything works perfectly.&lt;/p&gt;

&lt;p&gt;Then one day, an application inserts an order for "customer_id = 99999".&lt;/p&gt;

&lt;p&gt;The problem? Customer 99999 does not exist.&lt;/p&gt;

&lt;p&gt;Your database now contains an order that cannot be linked to a valid customer.&lt;/p&gt;

&lt;p&gt;Your reports may become unreliable. Your joins may not return the expected information. Your team may spend hours investigating a data-quality problem that could have been prevented.&lt;/p&gt;

&lt;p&gt;The solution is not another SQL query. It is a database constraint.&lt;/p&gt;

&lt;p&gt;Let's explore how SQL developers prevent these problems and learn some common SQL interview traps along the way.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;CREATE TABLE: Start With the Right Structure&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;First, create a customer table.&lt;/p&gt;

&lt;p&gt;CREATE TABLE customers (&lt;br&gt;
    customer_id   NUMBER PRIMARY KEY,&lt;br&gt;
    customer_name VARCHAR2(100) NOT NULL&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;Notice two important constraints:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"PRIMARY KEY" ensures that every customer has a unique, non-NULL identifier.&lt;/li&gt;
&lt;li&gt;"NOT NULL" prevents a customer record from being inserted without a name.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now create an orders table.&lt;/p&gt;

&lt;p&gt;CREATE TABLE orders (&lt;br&gt;
    order_id     NUMBER PRIMARY KEY,&lt;br&gt;
    customer_id  NUMBER,&lt;br&gt;
    order_amount NUMBER(10,2)&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;At first glance, everything looks fine.&lt;/p&gt;

&lt;p&gt;But there is a hidden problem.&lt;/p&gt;

&lt;p&gt;Nothing in this table definition prevents an order from referencing a customer who does not exist.&lt;/p&gt;

&lt;p&gt;How do we fix it?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;FOREIGN KEY: Protect Table Relationships&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Add a foreign key.&lt;/p&gt;

&lt;p&gt;ALTER TABLE orders&lt;br&gt;
ADD CONSTRAINT fk_orders_customer&lt;br&gt;
FOREIGN KEY (customer_id)&lt;br&gt;
REFERENCES customers(customer_id);&lt;/p&gt;

&lt;p&gt;Now the database enforces the relationship.&lt;/p&gt;

&lt;p&gt;If someone tries to insert an order with a non-NULL customer ID that does not exist in "customers", the database rejects the operation.&lt;/p&gt;

&lt;p&gt;Why is this important?&lt;/p&gt;

&lt;p&gt;Because your database should not depend entirely on every application developer remembering to validate every relationship correctly.&lt;/p&gt;

&lt;p&gt;Interview takeaway: A foreign key enforces referential integrity at the database level.&lt;/p&gt;

&lt;p&gt;One important detail: a nullable foreign key can contain "NULL" unless the column is also defined as "NOT NULL".&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;ALTER TABLE: Change Structure Without Recreating the Table&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Business requirements rarely remain the same forever.&lt;/p&gt;

&lt;p&gt;Suppose you now need to store customer email addresses.&lt;/p&gt;

&lt;p&gt;Do you need to drop the table and create it again?&lt;/p&gt;

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

&lt;p&gt;ALTER TABLE customers&lt;br&gt;
ADD email VARCHAR2(150);&lt;/p&gt;

&lt;p&gt;The new column is added to the existing table, and existing rows are retained.&lt;/p&gt;

&lt;p&gt;You can also use "ALTER TABLE" to add or remove constraints and modify columns, subject to database-specific rules and existing data.&lt;/p&gt;

&lt;p&gt;In production, always review dependencies before changing a schema. A column modification or removal can affect reports, stored procedures, applications, and downstream data pipelines.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;DROP vs TRUNCATE vs DELETE: The SQL Interview Trap&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;An interviewer asks:&lt;/p&gt;

&lt;p&gt;"You have a table containing 10 lakh records. You want to remove all records but retain the table structure. Which command would you use?"&lt;/p&gt;

&lt;p&gt;Many candidates immediately answer "DELETE".&lt;/p&gt;

&lt;p&gt;But let's understand the differences.&lt;/p&gt;

&lt;p&gt;DROP — Remove the Table&lt;/p&gt;

&lt;p&gt;DROP TABLE orders;&lt;/p&gt;

&lt;p&gt;This removes the table itself, including its data and associated table objects such as indexes and constraints.&lt;/p&gt;

&lt;p&gt;Use it only when the table is no longer needed.&lt;/p&gt;

&lt;p&gt;TRUNCATE — Remove All Rows&lt;/p&gt;

&lt;p&gt;TRUNCATE TABLE orders;&lt;/p&gt;

&lt;p&gt;This removes all rows while retaining the table structure.&lt;/p&gt;

&lt;p&gt;There is no "WHERE" clause, so you cannot use it to remove only selected records.&lt;/p&gt;

&lt;p&gt;DELETE — Remove Selected Rows&lt;/p&gt;

&lt;p&gt;DELETE FROM orders&lt;br&gt;
WHERE order_amount &amp;lt; 1000;&lt;/p&gt;

&lt;p&gt;This removes only rows matching the specified condition.&lt;/p&gt;

&lt;p&gt;You can also delete all rows by omitting the "WHERE" clause.&lt;/p&gt;

&lt;p&gt;Important Oracle interview tip: DDL statements such as "DROP" and "TRUNCATE" have implicit-commit implications. Do not assume you can roll them back like an ordinary uncommitted "DELETE".&lt;/p&gt;

&lt;p&gt;Always verify the target table and understand the transaction behavior before running destructive commands.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;COMPOSITE PRIMARY KEY: When One Column Is Not Enough&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Consider an order-items table.&lt;/p&gt;

&lt;p&gt;A single order can contain several products, and the same product can appear in different orders.&lt;/p&gt;

&lt;p&gt;CREATE TABLE order_items (&lt;br&gt;
    order_id   NUMBER,&lt;br&gt;
    product_id NUMBER,&lt;br&gt;
    quantity   NUMBER,&lt;br&gt;
    unit_price NUMBER(10,2),&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PRIMARY KEY (order_id, product_id)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;);&lt;/p&gt;

&lt;p&gt;Why use two columns in the primary key?&lt;/p&gt;

&lt;p&gt;Because the combination of "order_id" and "product_id" identifies each row.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;"(101, 10)" identifies product 10 in order 101.&lt;/li&gt;
&lt;li&gt;"(101, 20)" identifies product 20 in order 101.&lt;/li&gt;
&lt;li&gt;"(102, 10)" identifies product 10 in order 102.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These combinations are different.&lt;/p&gt;

&lt;p&gt;But inserting "(101, 10)" a second time would violate the composite primary key.&lt;/p&gt;

&lt;p&gt;This concept is useful when designing junction tables, order details, and many-to-many relationships.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;CHECK CONSTRAINT: Prevent Invalid Values&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Suppose an order amount must never be negative.&lt;/p&gt;

&lt;p&gt;You can enforce that rule at the database level.&lt;/p&gt;

&lt;p&gt;ALTER TABLE orders&lt;br&gt;
ADD CONSTRAINT chk_order_amount&lt;br&gt;
CHECK (order_amount &amp;gt;= 0);&lt;/p&gt;

&lt;p&gt;Now an insert or update that violates the constraint is rejected.&lt;/p&gt;

&lt;p&gt;One subtle detail: a "CHECK" constraint alone does not reject "NULL" values. If the amount must also be present, define the column as "NOT NULL" or add an appropriate constraint.&lt;/p&gt;

&lt;p&gt;This is the kind of detail that separates memorizing SQL syntax from understanding how database rules actually work.&lt;/p&gt;




&lt;p&gt;Your SQL Interview Challenge&lt;/p&gt;

&lt;p&gt;Before you leave, try this question without looking up the answer.&lt;/p&gt;

&lt;p&gt;You have two tables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"customers", containing customer information.&lt;/li&gt;
&lt;li&gt;"orders", containing customer orders.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You must prevent an order from referencing a customer who does not exist.&lt;/p&gt;

&lt;p&gt;Which solution is best?&lt;/p&gt;

&lt;p&gt;A. Create an index on "orders.customer_id".&lt;/p&gt;

&lt;p&gt;B. Add a foreign key referencing "customers.customer_id".&lt;/p&gt;

&lt;p&gt;C. Use "ORDER BY customer_id".&lt;/p&gt;

&lt;p&gt;D. Add a "CHECK" constraint requiring "customer_id &amp;gt; 0".&lt;/p&gt;

&lt;p&gt;Pause and decide before reading further.&lt;/p&gt;

&lt;p&gt;Correct answer: B — Add a foreign key.&lt;/p&gt;

&lt;p&gt;An index can improve access performance, but it does not enforce the relationship. Sorting rows does not enforce data integrity, and checking that an ID is positive does not establish that the customer exists.&lt;/p&gt;

&lt;p&gt;A foreign key directly enforces the required relationship.&lt;/p&gt;

&lt;p&gt;The key principle is simple:&lt;/p&gt;

&lt;p&gt;Good database design makes invalid data harder to create.&lt;/p&gt;

&lt;p&gt;Want to Master SQL DDL for Interviews?&lt;/p&gt;

&lt;p&gt;We've covered the fundamentals, but there is much more to learn.&lt;/p&gt;

&lt;p&gt;What happens when you need a many-to-many relationship? When should you use "ON DELETE CASCADE"? How do you modify existing constraints safely? What mistakes do interviewers expect SQL developers to avoid?&lt;/p&gt;

&lt;p&gt;I've brought these topics together in a detailed guide on Sankalan Data Tech.&lt;/p&gt;

&lt;p&gt;The complete tutorial covers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"CREATE", "ALTER", "DROP", and "TRUNCATE" with practical examples&lt;/li&gt;
&lt;li&gt;Primary keys, foreign keys, unique constraints, and check constraints&lt;/li&gt;
&lt;li&gt;One-to-many and many-to-many relationships&lt;/li&gt;
&lt;li&gt;Composite primary keys and junction tables&lt;/li&gt;
&lt;li&gt;Constraints versus triggers&lt;/li&gt;
&lt;li&gt;Common interview mistakes and follow-up questions&lt;/li&gt;
&lt;li&gt;21 SQL interview questions with answers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Continue learning with the complete SQL DDL guide:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.sankalandtech.com/Tutorials/sql-plsql-faq-interview/ddl-manage-tables-relationships-sql-faq.html" rel="noopener noreferrer"&gt;https://www.sankalandtech.com/Tutorials/sql-plsql-faq-interview/ddl-manage-tables-relationships-sql-faq.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are preparing for a SQL developer, Oracle PL/SQL, or data engineering interview, work through the examples and understand the reasoning behind each constraint instead of simply memorizing syntax.&lt;/p&gt;

&lt;p&gt;Save this post for revision, and test yourself on the interview questions in the full guide.&lt;/p&gt;

&lt;h1&gt;
  
  
  sql #database #tutorial #beginners
&lt;/h1&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Find Departments with an Average Salary Above the Company Average</title>
      <dc:creator>Kailas Warade</dc:creator>
      <pubDate>Mon, 19 Oct 2026 03:47:25 +0000</pubDate>
      <link>https://dev.to/kailas_warade_d2a15d1ef8a/find-departments-with-an-average-salary-above-the-company-average-198c</link>
      <guid>https://dev.to/kailas_warade_d2a15d1ef8a/find-departments-with-an-average-salary-above-the-company-average-198c</guid>
      <description>&lt;p&gt;SQL Challenge.&lt;br&gt;
Find Departments with an Average Salary Above the Company Average&lt;/p&gt;

&lt;p&gt;Here’s a practical SQL interview question. Can you find which departments have an average salary higher than the company-wide average?&lt;/p&gt;

&lt;p&gt;Table 1: employees&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;emp_id&lt;/th&gt;
&lt;th&gt;dept_id&lt;/th&gt;
&lt;th&gt;salary&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;101&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;80000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;102&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;100000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;103&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;90000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;104&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;50000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;105&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;60000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;106&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;70000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;107&lt;/td&gt;
&lt;td&gt;30&lt;/td&gt;
&lt;td&gt;40000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;108&lt;/td&gt;
&lt;td&gt;30&lt;/td&gt;
&lt;td&gt;50000&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Table 2: departments&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;id&lt;/th&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;30&lt;/td&gt;
&lt;td&gt;Sales&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Your task: Write an SQL query to find departments whose average salary is higher than the overall company average.&lt;/p&gt;

&lt;p&gt;Solution&lt;/p&gt;

&lt;p&gt;WITH department_averages AS (&lt;br&gt;
    SELECT&lt;br&gt;
        e.dept_id,&lt;br&gt;
        d.name AS dept,&lt;br&gt;
        AVG(e.salary) AS average_salary&lt;br&gt;
    FROM employees e&lt;br&gt;
    JOIN departments d&lt;br&gt;
        ON e.dept_id = d.id&lt;br&gt;
    GROUP BY e.dept_id, d.name&lt;br&gt;
)&lt;br&gt;
SELECT&lt;br&gt;
    dept_id,&lt;br&gt;
    dept,&lt;br&gt;
    average_salary&lt;br&gt;
FROM department_averages&lt;br&gt;
WHERE average_salary &amp;gt; (&lt;br&gt;
    SELECT AVG(salary)&lt;br&gt;
    FROM employees&lt;br&gt;
)&lt;br&gt;
ORDER BY average_salary DESC;&lt;/p&gt;

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

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;dept_id&lt;/th&gt;
&lt;th&gt;dept&lt;/th&gt;
&lt;th&gt;average_salary&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;td&gt;90000&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The company-wide average salary is ₹67,500. IT has an average salary of ₹90,000, while HR and Sales have lower averages.&lt;/p&gt;

&lt;p&gt;The CTE calculates the average salary for each department, and the subquery calculates the overall company average. The final query returns only departments whose average is higher than that benchmark.&lt;/p&gt;

&lt;p&gt;Interview Challenge&lt;/p&gt;

&lt;p&gt;What happens if a new employee earning ₹120,000 joins HR?&lt;/p&gt;

&lt;p&gt;Will HR also appear in the result, or will IT remain the only department?&lt;/p&gt;

&lt;p&gt;Share your answer in the comments.&lt;/p&gt;

&lt;p&gt;For more SQL practice involving joins and multiple tables, visit this guide:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.sankalandtech.com/Tutorials/sql-plsql-faq-interview/displaying-data-multiple-tables-sql-faq.html" rel="noopener noreferrer"&gt;https://www.sankalandtech.com/Tutorials/sql-plsql-faq-interview/displaying-data-multiple-tables-sql-faq.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow Sankalan Data Tech for more practical SQL examples and interview questions.&lt;/p&gt;

&lt;h1&gt;
  
  
  SQL #sqlinterview #LearnSQL #DataEngineering
&lt;/h1&gt;

</description>
      <category>sql</category>
      <category>dataengineering</category>
      <category>learnsql</category>
      <category>sqlinterview</category>
    </item>
    <item>
      <title>SQL: Find the Top 2 Orders for Every Customer Using Window Functions</title>
      <dc:creator>Kailas Warade</dc:creator>
      <pubDate>Thu, 08 Oct 2026 03:26:32 +0000</pubDate>
      <link>https://dev.to/kailas_warade_d2a15d1ef8a/sql-find-the-top-2-orders-for-every-customer-using-window-functions-1dnp</link>
      <guid>https://dev.to/kailas_warade_d2a15d1ef8a/sql-find-the-top-2-orders-for-every-customer-using-window-functions-1dnp</guid>
      <description>&lt;p&gt;SQL: Find the Top 2 Orders for Every Customer Using Window Functions&lt;/p&gt;

&lt;p&gt;One SQL problem I often see people get wrong is:&lt;/p&gt;

&lt;p&gt;How do you find the top 2 orders for every customer?&lt;/p&gt;

&lt;p&gt;Finding the top 2 orders overall is easy.&lt;/p&gt;

&lt;p&gt;The interesting part is “for every customer.”&lt;/p&gt;

&lt;p&gt;Let’s take a simple example.&lt;/p&gt;

&lt;p&gt;Sample Data&lt;/p&gt;

&lt;p&gt;CID| OID| AMT&lt;br&gt;
C001| 1001| 12000&lt;br&gt;
C001| 1002| 7500&lt;br&gt;
C001| 1003| 9000&lt;br&gt;
C002| 1004| 15000&lt;br&gt;
C002| 1005| 6000&lt;br&gt;
C002| 1006| 11000&lt;br&gt;
C003| 1007| 5000&lt;br&gt;
C003| 1008| 18000&lt;br&gt;
C003| 1009| 12000&lt;/p&gt;

&lt;p&gt;We want the top 2 orders for each customer based on order amount.&lt;/p&gt;

&lt;p&gt;The expected result is:&lt;/p&gt;

&lt;p&gt;CID| OID| AMT&lt;br&gt;
C001| 1001| 12000&lt;br&gt;
C001| 1003| 9000&lt;br&gt;
C002| 1004| 15000&lt;br&gt;
C002| 1006| 11000&lt;br&gt;
C003| 1008| 18000&lt;br&gt;
C003| 1009| 12000&lt;/p&gt;

&lt;p&gt;Why a Simple ORDER BY Is Not Enough&lt;/p&gt;

&lt;p&gt;A common first attempt might be:&lt;/p&gt;

&lt;p&gt;SELECT *&lt;br&gt;
FROM orders&lt;br&gt;
ORDER BY amt DESC&lt;br&gt;
FETCH FIRST 2 ROWS ONLY;&lt;/p&gt;

&lt;p&gt;This returns the top 2 orders from the entire table.&lt;/p&gt;

&lt;p&gt;But that is not what we need.&lt;/p&gt;

&lt;p&gt;We need the ranking to start again for each customer.&lt;/p&gt;

&lt;p&gt;That is where SQL window functions become useful.&lt;/p&gt;

&lt;p&gt;If you want to learn more about window functions and analytic functions, I’ve also covered the topic in more detail here:&lt;/p&gt;

&lt;p&gt;SQL Window Functions / Analytic Functions&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.sankalandtech.com/Tutorials/sql-plsql-faq-interview/window-functions-analytic-functions-sql-faq.html" rel="noopener noreferrer"&gt;https://www.sankalandtech.com/Tutorials/sql-plsql-faq-interview/window-functions-analytic-functions-sql-faq.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using ROW_NUMBER()&lt;/p&gt;

&lt;p&gt;Here is the solution:&lt;/p&gt;

&lt;p&gt;SELECT cid,&lt;br&gt;
       oid,&lt;br&gt;
       amt&lt;br&gt;
FROM (&lt;br&gt;
    SELECT cid,&lt;br&gt;
           oid,&lt;br&gt;
           amt,&lt;br&gt;
           ROW_NUMBER() OVER (&lt;br&gt;
               PARTITION BY cid&lt;br&gt;
               ORDER BY amt DESC&lt;br&gt;
           ) AS rn&lt;br&gt;
    FROM orders&lt;br&gt;
)&lt;br&gt;
WHERE rn &amp;lt;= 2;&lt;/p&gt;

&lt;p&gt;The key part is:&lt;/p&gt;

&lt;p&gt;ROW_NUMBER() OVER (&lt;br&gt;
    PARTITION BY cid&lt;br&gt;
    ORDER BY amt DESC&lt;br&gt;
)&lt;/p&gt;

&lt;p&gt;What does it do?&lt;/p&gt;

&lt;p&gt;PARTITION BY cid&lt;/p&gt;

&lt;p&gt;Divides the data customer-wise.&lt;/p&gt;

&lt;p&gt;ORDER BY amt DESC&lt;/p&gt;

&lt;p&gt;Sorts each customer’s orders from highest amount to lowest.&lt;/p&gt;

&lt;p&gt;ROW_NUMBER()&lt;/p&gt;

&lt;p&gt;Assigns a sequence number to the orders within each customer.&lt;/p&gt;

&lt;p&gt;The result before applying "WHERE rn &amp;lt;= 2" looks like this:&lt;/p&gt;

&lt;p&gt;CID| OID| AMT| RN&lt;br&gt;
C001| 1001| 12000| 1&lt;br&gt;
C001| 1003| 9000| 2&lt;br&gt;
C001| 1002| 7500| 3&lt;br&gt;
C002| 1004| 15000| 1&lt;br&gt;
C002| 1006| 11000| 2&lt;br&gt;
C002| 1005| 6000| 3&lt;br&gt;
C003| 1008| 18000| 1&lt;br&gt;
C003| 1009| 12000| 2&lt;br&gt;
C003| 1007| 5000| 3&lt;/p&gt;

&lt;p&gt;Then:&lt;/p&gt;

&lt;p&gt;WHERE rn &amp;lt;= 2&lt;/p&gt;

&lt;p&gt;keeps only the first two rows for each customer.&lt;/p&gt;

&lt;p&gt;What If Two Orders Have the Same Amount?&lt;/p&gt;

&lt;p&gt;This is where "ROW_NUMBER()", "RANK()", and "DENSE_RANK()" behave differently.&lt;/p&gt;

&lt;p&gt;ROW_NUMBER()&lt;/p&gt;

&lt;p&gt;Every row gets a unique number.&lt;/p&gt;

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

&lt;p&gt;OID| AMT| RN&lt;br&gt;
1001| 12000| 1&lt;br&gt;
1002| 12000| 2&lt;/p&gt;

&lt;p&gt;If you need exactly 2 rows per customer, "ROW_NUMBER()" is usually the right choice.&lt;/p&gt;

&lt;p&gt;RANK()&lt;/p&gt;

&lt;p&gt;Rows with the same amount receive the same rank.&lt;/p&gt;

&lt;p&gt;OID| AMT| RANK&lt;br&gt;
1001| 12000| 1&lt;br&gt;
1002| 12000| 1&lt;br&gt;
1003| 9000| 3&lt;/p&gt;

&lt;p&gt;Notice that rank 2 is skipped.&lt;/p&gt;

&lt;p&gt;DENSE_RANK()&lt;/p&gt;

&lt;p&gt;Rows with the same amount receive the same rank, but there are no gaps.&lt;/p&gt;

&lt;p&gt;OID| AMT| RANK&lt;br&gt;
1001| 12000| 1&lt;br&gt;
1002| 12000| 1&lt;br&gt;
1003| 9000| 2&lt;/p&gt;

&lt;p&gt;So the function you choose depends on the requirement.&lt;/p&gt;

&lt;p&gt;If you need:&lt;/p&gt;

&lt;p&gt;«Exactly 2 orders for every customer»&lt;/p&gt;

&lt;p&gt;use "ROW_NUMBER()".&lt;/p&gt;

&lt;p&gt;If you need:&lt;/p&gt;

&lt;p&gt;«All orders belonging to the top 2 amount levels»&lt;/p&gt;

&lt;p&gt;"DENSE_RANK()" may be a better choice.&lt;/p&gt;

&lt;p&gt;A Pattern Worth Remembering&lt;/p&gt;

&lt;p&gt;Whenever you see a requirement like:&lt;/p&gt;

&lt;p&gt;«Top N records for each customer, department, product, category, or region»&lt;/p&gt;

&lt;p&gt;think about this pattern:&lt;/p&gt;

&lt;p&gt;PARTITION BY&lt;br&gt;
+&lt;br&gt;
ORDER BY&lt;br&gt;
+&lt;br&gt;
ROW_NUMBER / RANK / DENSE_RANK&lt;/p&gt;

&lt;p&gt;The same approach can be used for many practical SQL problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Top 3 products for each category&lt;/li&gt;
&lt;li&gt;Highest-paid employees in each department&lt;/li&gt;
&lt;li&gt;Latest 2 transactions for each customer&lt;/li&gt;
&lt;li&gt;Top 5 sales for each region&lt;/li&gt;
&lt;li&gt;Most recent record for each employee&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The table and business requirement may change, but the underlying SQL pattern is often the same.&lt;/p&gt;

&lt;p&gt;Try This Yourself&lt;/p&gt;

&lt;p&gt;Now change the requirement:&lt;/p&gt;

&lt;p&gt;Find the latest 2 orders for every customer.&lt;/p&gt;

&lt;p&gt;What would you change in the query?&lt;/p&gt;

&lt;p&gt;The answer is in the "ORDER BY" inside the window function.&lt;/p&gt;

&lt;p&gt;That small change is worth understanding because learning the pattern is much more useful than simply memorizing one SQL query.&lt;/p&gt;




&lt;p&gt;Sankalan Data Tech&lt;br&gt;
Practical SQL, Python and Data Engineering learning.&lt;/p&gt;

</description>
      <category>dataengineering</category>
      <category>database</category>
      <category>sql</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Python Functions Explained: 10 Concepts Every Python Developer Should Know</title>
      <dc:creator>Kailas Warade</dc:creator>
      <pubDate>Wed, 07 Oct 2026 12:36:54 +0000</pubDate>
      <link>https://dev.to/kailas_warade_d2a15d1ef8a/python-functions-explained-10-concepts-every-python-developer-should-know-239d</link>
      <guid>https://dev.to/kailas_warade_d2a15d1ef8a/python-functions-explained-10-concepts-every-python-developer-should-know-239d</guid>
      <description>&lt;p&gt;If you are learning Python for Data Analytics, Data Engineering, automation, or backend development, functions are one of the first topics you need to get comfortable with.&lt;/p&gt;

&lt;p&gt;But in interviews, knowing only this is not enough:&lt;/p&gt;

&lt;p&gt;def add(a, b):&lt;br&gt;
    return a + b&lt;/p&gt;

&lt;p&gt;You may be asked what happens when you change the arguments, use "*args", pass keyword arguments, use default values, return multiple values, or access variables outside the function.&lt;/p&gt;

&lt;p&gt;Here are 10 Python function concepts worth understanding properly.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Function Definition vs Function Call&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A function definition tells Python what the function should do.&lt;/p&gt;

&lt;p&gt;def calculate_total(price, quantity):&lt;br&gt;
    return price * quantity&lt;/p&gt;

&lt;p&gt;Nothing happens when Python reads the definition.&lt;/p&gt;

&lt;p&gt;The function runs when you call it:&lt;/p&gt;

&lt;p&gt;total = calculate_total(500, 3)&lt;/p&gt;

&lt;p&gt;print(total)&lt;/p&gt;

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

&lt;p&gt;1500&lt;/p&gt;

&lt;p&gt;This distinction sounds basic, but it is a common interview question.&lt;/p&gt;




&lt;ol&gt;
&lt;li&gt;Parameters and Arguments Are Not the Same Thing&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;def calculate_total(price, quantity):&lt;br&gt;
    return price * quantity&lt;/p&gt;

&lt;p&gt;Here, "price" and "quantity" are parameters.&lt;/p&gt;

&lt;p&gt;When we call:&lt;/p&gt;

&lt;p&gt;calculate_total(500, 3)&lt;/p&gt;

&lt;p&gt;"500" and "3" are arguments.&lt;/p&gt;

&lt;p&gt;A simple way to remember it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Parameter → variable written in the function definition&lt;/li&gt;
&lt;li&gt;Argument → actual value passed during the function call&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This becomes more important when you start working with different types of arguments.&lt;/p&gt;




&lt;ol&gt;
&lt;li&gt;Positional and Keyword Arguments&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With positional arguments, Python matches values based on their position.&lt;/p&gt;

&lt;p&gt;def create_user(name, age):&lt;br&gt;
    print(name, age)&lt;/p&gt;

&lt;p&gt;create_user("Rahul", 28)&lt;/p&gt;

&lt;p&gt;Here:&lt;/p&gt;

&lt;p&gt;name = Rahul&lt;br&gt;
age  = 28&lt;/p&gt;

&lt;p&gt;With keyword arguments, you explicitly mention the parameter name:&lt;/p&gt;

&lt;p&gt;create_user(age=28, name="Rahul")&lt;/p&gt;

&lt;p&gt;This can make function calls easier to read, especially when a function has several parameters.&lt;/p&gt;

&lt;p&gt;You can also mix them:&lt;/p&gt;

&lt;p&gt;create_user("Rahul", age=28)&lt;/p&gt;

&lt;p&gt;This is valid because the positional argument comes before the keyword argument.&lt;/p&gt;




&lt;ol&gt;
&lt;li&gt;Default Arguments Make Functions More Flexible&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Suppose most users are from India:&lt;/p&gt;

&lt;p&gt;def create_user(name, country="India"):&lt;br&gt;
    print(name, country)&lt;/p&gt;

&lt;p&gt;Now you can call:&lt;/p&gt;

&lt;p&gt;create_user("Rahul")&lt;/p&gt;

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

&lt;p&gt;Rahul India&lt;/p&gt;

&lt;p&gt;Or override the default:&lt;/p&gt;

&lt;p&gt;create_user("John", "USA")&lt;/p&gt;

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

&lt;p&gt;John USA&lt;/p&gt;

&lt;p&gt;Default arguments are useful when a parameter has a sensible value that will be used most of the time.&lt;/p&gt;




&lt;ol&gt;
&lt;li&gt;What Exactly Does "*args" Do?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Sometimes you don't know how many positional values will be passed.&lt;/p&gt;

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

&lt;p&gt;def calculate_sum(*args):&lt;br&gt;
    return sum(args)&lt;/p&gt;

&lt;p&gt;print(calculate_sum(10, 20))&lt;br&gt;
print(calculate_sum(10, 20, 30, 40))&lt;/p&gt;

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

&lt;p&gt;30&lt;br&gt;
100&lt;/p&gt;

&lt;p&gt;Inside the function, "args" is a tuple.&lt;/p&gt;

&lt;p&gt;def show_values(*args):&lt;br&gt;
    print(args)&lt;/p&gt;

&lt;p&gt;show_values(10, 20, 30)&lt;/p&gt;

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

&lt;p&gt;(10, 20, 30)&lt;/p&gt;

&lt;p&gt;The important point is that "*" tells Python to collect additional positional arguments.&lt;/p&gt;




&lt;ol&gt;
&lt;li&gt;What About "**kwargs"?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;"**kwargs" is used when you want to accept multiple keyword arguments.&lt;/p&gt;

&lt;p&gt;def show_user(**kwargs):&lt;br&gt;
    print(kwargs)&lt;/p&gt;

&lt;p&gt;show_user(&lt;br&gt;
    name="Rahul",&lt;br&gt;
    age=28,&lt;br&gt;
    city="Pune"&lt;br&gt;
)&lt;/p&gt;

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

&lt;p&gt;{'name': 'Rahul', 'age': 28, 'city': 'Pune'}&lt;/p&gt;

&lt;p&gt;Inside the function, "kwargs" is a dictionary.&lt;/p&gt;

&lt;p&gt;This can be useful when the function needs to accept flexible named inputs.&lt;/p&gt;

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

&lt;p&gt;def create_report(**filters):&lt;br&gt;
    for key, value in filters.items():&lt;br&gt;
        print(key, value)&lt;/p&gt;

&lt;p&gt;create_report(&lt;br&gt;
    city="Pune",&lt;br&gt;
    department="Sales",&lt;br&gt;
    year=2026&lt;br&gt;
)&lt;/p&gt;

&lt;p&gt;The names "args" and "kwargs" are conventional. Python does not require those exact names.&lt;/p&gt;

&lt;p&gt;For example, this also works:&lt;/p&gt;

&lt;p&gt;def show_values(*values):&lt;br&gt;
    print(values)&lt;/p&gt;

&lt;p&gt;And:&lt;/p&gt;

&lt;p&gt;def show_details(**details):&lt;br&gt;
    print(details)&lt;/p&gt;

&lt;p&gt;The "&lt;em&gt;" and "&lt;/em&gt;*" are what matter.&lt;/p&gt;




&lt;ol&gt;
&lt;li&gt;"return" Is Different From "print()"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is an important concept for beginners.&lt;/p&gt;

&lt;p&gt;Consider:&lt;/p&gt;

&lt;p&gt;def add(a, b):&lt;br&gt;
    print(a + b)&lt;/p&gt;

&lt;p&gt;The function displays the result, but it does not return the result.&lt;/p&gt;

&lt;p&gt;Now compare it with:&lt;/p&gt;

&lt;p&gt;def add(a, b):&lt;br&gt;
    return a + b&lt;/p&gt;

&lt;p&gt;You can store the returned value:&lt;/p&gt;

&lt;p&gt;result = add(10, 20)&lt;/p&gt;

&lt;p&gt;print(result)&lt;/p&gt;

&lt;p&gt;This matters when functions are combined.&lt;/p&gt;

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

&lt;p&gt;def calculate_discount(price, discount):&lt;br&gt;
    return price - (price * discount / 100)&lt;/p&gt;

&lt;p&gt;final_price = calculate_discount(1000, 10)&lt;/p&gt;

&lt;p&gt;print(final_price)&lt;/p&gt;

&lt;p&gt;The returned value can be stored, passed to another function, or used in a larger calculation.&lt;/p&gt;




&lt;ol&gt;
&lt;li&gt;Can a Python Function Return Multiple Values?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Yes.&lt;/p&gt;

&lt;p&gt;def get_employee():&lt;br&gt;
    return "Rahul", "Data Engineer", 85000&lt;/p&gt;

&lt;p&gt;You can receive the result like this:&lt;/p&gt;

&lt;p&gt;name, role, salary = get_employee()&lt;/p&gt;

&lt;p&gt;print(name)&lt;br&gt;
print(role)&lt;br&gt;
print(salary)&lt;/p&gt;

&lt;p&gt;Python actually returns these values as a tuple.&lt;/p&gt;

&lt;p&gt;You can see this directly:&lt;/p&gt;

&lt;p&gt;result = get_employee()&lt;/p&gt;

&lt;p&gt;print(result)&lt;/p&gt;

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

&lt;p&gt;('Rahul', 'Data Engineer', 85000)&lt;/p&gt;

&lt;p&gt;This is useful when a function needs to return a small group of related values.&lt;/p&gt;




&lt;ol&gt;
&lt;li&gt;Understand Local and Global Variables&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Consider:&lt;/p&gt;

&lt;p&gt;name = "Rahul"&lt;/p&gt;

&lt;p&gt;def show_name():&lt;br&gt;
    print(name)&lt;/p&gt;

&lt;p&gt;show_name()&lt;/p&gt;

&lt;p&gt;The function can read the global variable.&lt;/p&gt;

&lt;p&gt;But a variable created inside a function normally belongs to that function:&lt;/p&gt;

&lt;p&gt;def show_name():&lt;br&gt;
    name = "Rahul"&lt;br&gt;
    print(name)&lt;/p&gt;

&lt;p&gt;show_name()&lt;/p&gt;

&lt;h1&gt;
  
  
  print(name)  # NameError
&lt;/h1&gt;

&lt;p&gt;The variable "name" created inside the function is local to that function.&lt;/p&gt;

&lt;p&gt;You may also see the "global" keyword:&lt;/p&gt;

&lt;p&gt;count = 0&lt;/p&gt;

&lt;p&gt;def increase():&lt;br&gt;
    global count&lt;br&gt;
    count += 1&lt;/p&gt;

&lt;p&gt;increase()&lt;/p&gt;

&lt;p&gt;print(count)&lt;/p&gt;

&lt;p&gt;Although "global" is valid, changing global state inside functions should generally be done carefully because it can make code harder to understand and test.&lt;/p&gt;




&lt;ol&gt;
&lt;li&gt;One Interview Question That Tests Your Understanding&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What will this code print?&lt;/p&gt;

&lt;p&gt;def calculate(a, b=10):&lt;br&gt;
    return a + b&lt;/p&gt;

&lt;p&gt;print(calculate(5))&lt;br&gt;
print(calculate(5, 20))&lt;/p&gt;

&lt;p&gt;The answer is:&lt;/p&gt;

&lt;p&gt;15&lt;br&gt;
25&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;In the first call:&lt;/p&gt;

&lt;p&gt;calculate(5)&lt;/p&gt;

&lt;p&gt;Python uses the default value:&lt;/p&gt;

&lt;p&gt;a = 5&lt;br&gt;
b = 10&lt;/p&gt;

&lt;p&gt;In the second call:&lt;/p&gt;

&lt;p&gt;calculate(5, 20)&lt;/p&gt;

&lt;p&gt;The supplied value "20" replaces the default.&lt;/p&gt;

&lt;p&gt;Questions like this are more useful than simply memorizing the definition of a function.&lt;/p&gt;




&lt;p&gt;What Should You Prepare for a Python Interview?&lt;/p&gt;

&lt;p&gt;For functions, don't stop at the basic syntax.&lt;/p&gt;

&lt;p&gt;Make sure you can explain and write examples for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Function definition and function call&lt;/li&gt;
&lt;li&gt;Parameters vs arguments&lt;/li&gt;
&lt;li&gt;Positional arguments&lt;/li&gt;
&lt;li&gt;Keyword arguments&lt;/li&gt;
&lt;li&gt;Default arguments&lt;/li&gt;
&lt;li&gt;"*args"&lt;/li&gt;
&lt;li&gt;"**kwargs"&lt;/li&gt;
&lt;li&gt;"return" vs "print"&lt;/li&gt;
&lt;li&gt;Returning multiple values&lt;/li&gt;
&lt;li&gt;Local and global scope&lt;/li&gt;
&lt;li&gt;"global" keyword&lt;/li&gt;
&lt;li&gt;Lambda functions&lt;/li&gt;
&lt;li&gt;Nested functions&lt;/li&gt;
&lt;li&gt;Recursion&lt;/li&gt;
&lt;li&gt;Decorators&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The important part is not just remembering the definition.&lt;/p&gt;

&lt;p&gt;Write the code, run it, change the input, and see what Python actually does.&lt;/p&gt;

&lt;p&gt;That is how these concepts become much easier to remember during an interview.&lt;/p&gt;

&lt;p&gt;More Python Function Interview Questions&lt;/p&gt;

&lt;p&gt;If you want a more detailed interview-focused reference, I have covered Python functions with examples and explanations here:&lt;/p&gt;

&lt;p&gt;👉 "Python Functions Interview Questions and Answers" (&lt;a href="https://www.sankalandtech.com/Tutorials/Python/interview-questions/python-functions-tutorial.html" rel="noopener noreferrer"&gt;https://www.sankalandtech.com/Tutorials/Python/interview-questions/python-functions-tutorial.html&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;The page goes deeper into Python function concepts and can be useful as a revision page before a Python interview.&lt;/p&gt;

&lt;p&gt;Final Thought&lt;/p&gt;

&lt;p&gt;Functions look simple when you first learn Python.&lt;/p&gt;

&lt;p&gt;But once you understand how arguments, return values, scope, "&lt;em&gt;args", "&lt;/em&gt;*kwargs", and nested functions work, you start writing much more reusable Python code.&lt;/p&gt;

&lt;p&gt;And that is the real purpose of learning functions — not just answering an interview question, but being able to break a real problem into smaller pieces of code that you can reuse and test.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>python</category>
      <category>interview</category>
      <category>coding</category>
    </item>
    <item>
      <title>Python Loops and Flow Control: A Practical Guide to Repetition and Program Execution</title>
      <dc:creator>Kailas Warade</dc:creator>
      <pubDate>Mon, 05 Oct 2026 01:36:55 +0000</pubDate>
      <link>https://dev.to/kailas_warade_d2a15d1ef8a/python-loops-and-flow-control-a-practical-guide-to-repetition-and-program-execution-110p</link>
      <guid>https://dev.to/kailas_warade_d2a15d1ef8a/python-loops-and-flow-control-a-practical-guide-to-repetition-and-program-execution-110p</guid>
      <description>&lt;p&gt;When writing Python programs, we often need to execute the same operation repeatedly.&lt;/p&gt;

&lt;p&gt;It could be processing records, checking values in a list, reading a file line by line, processing API responses, or performing repetitive data-processing tasks.&lt;/p&gt;

&lt;p&gt;Writing the same code again and again is not practical.&lt;/p&gt;

&lt;p&gt;This is where loops and flow control become important.&lt;/p&gt;

&lt;p&gt;Python provides simple ways to repeat operations, make decisions, skip specific iterations, stop execution when required, and control the normal flow of a program.&lt;/p&gt;

&lt;p&gt;In this post, we'll understand the important concepts behind Python loops and flow control with practical examples.&lt;/p&gt;




&lt;p&gt;*&lt;em&gt;What Is a Loop in Python?&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
A loop allows us to execute a block of code repeatedly.&lt;/p&gt;

&lt;p&gt;For example, if we want to print numbers from 1 to 5, we could write:&lt;/p&gt;

&lt;p&gt;print(1)&lt;br&gt;
print(2)&lt;br&gt;
print(3)&lt;br&gt;
print(4)&lt;br&gt;
print(5)&lt;/p&gt;

&lt;p&gt;But using a loop makes the code much simpler:&lt;/p&gt;

&lt;p&gt;for i in range(1, 6):&lt;br&gt;
    print(i)&lt;/p&gt;

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

&lt;p&gt;1&lt;br&gt;
2&lt;br&gt;
3&lt;br&gt;
4&lt;br&gt;
5&lt;/p&gt;

&lt;p&gt;The main advantage of loops is that they reduce repetitive code.&lt;/p&gt;

&lt;p&gt;Loops are commonly used for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Processing lists&lt;/li&gt;
&lt;li&gt;Processing strings&lt;/li&gt;
&lt;li&gt;Reading files&lt;/li&gt;
&lt;li&gt;Processing database records&lt;/li&gt;
&lt;li&gt;Handling API responses&lt;/li&gt;
&lt;li&gt;Data transformation&lt;/li&gt;
&lt;li&gt;Automation&lt;/li&gt;
&lt;li&gt;Data analysis&lt;/li&gt;
&lt;li&gt;ETL and data-processing tasks&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;The Two Main Types of Loops in Python&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Python mainly provides two types of loops:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"for" loop&lt;/li&gt;
&lt;li&gt;"while" loop&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They both repeat code, but they are generally used in different situations.&lt;/p&gt;




&lt;p&gt;for Loop&lt;/p&gt;

&lt;p&gt;A "for" loop is commonly used to iterate through an iterable.&lt;/p&gt;

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

&lt;p&gt;fruits = ["Apple", "Banana", "Mango"]&lt;/p&gt;

&lt;p&gt;for fruit in fruits:&lt;br&gt;
    print(fruit)&lt;/p&gt;

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

&lt;p&gt;Apple&lt;br&gt;
Banana&lt;br&gt;
Mango&lt;/p&gt;

&lt;p&gt;The loop takes one item at a time from the collection.&lt;/p&gt;

&lt;p&gt;A "for" loop can be used with lists, strings, tuples, ranges, and many other iterable objects.&lt;/p&gt;

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

&lt;p&gt;name = "Python"&lt;/p&gt;

&lt;p&gt;for character in name:&lt;br&gt;
    print(character)&lt;/p&gt;

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

&lt;p&gt;P&lt;br&gt;
y&lt;br&gt;
t&lt;br&gt;
h&lt;br&gt;
o&lt;br&gt;
n&lt;/p&gt;




&lt;p&gt;while Loop&lt;/p&gt;

&lt;p&gt;A "while" loop continues executing as long as its condition is true.&lt;/p&gt;

&lt;p&gt;count = 1&lt;/p&gt;

&lt;p&gt;while count &amp;lt;= 5:&lt;br&gt;
    print(count)&lt;br&gt;
    count += 1&lt;/p&gt;

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

&lt;p&gt;1&lt;br&gt;
2&lt;br&gt;
3&lt;br&gt;
4&lt;br&gt;
5&lt;/p&gt;

&lt;p&gt;The important part here is:&lt;/p&gt;

&lt;p&gt;count += 1&lt;/p&gt;

&lt;p&gt;The value changes during each iteration.&lt;/p&gt;

&lt;p&gt;Eventually, "count &amp;lt;= 5" becomes false and the loop stops.&lt;/p&gt;

&lt;p&gt;A "while" loop is useful when the number of iterations depends on a condition that can change during execution.&lt;/p&gt;




&lt;p&gt;for vs while&lt;/p&gt;

&lt;p&gt;A simple way to think about them is:&lt;/p&gt;

&lt;p&gt;for loop&lt;/p&gt;

&lt;p&gt;Use it when you are iterating through a sequence or iterable.&lt;/p&gt;

&lt;p&gt;for item in items:&lt;br&gt;
    print(item)&lt;/p&gt;

&lt;p&gt;while loop&lt;/p&gt;

&lt;p&gt;Use it when a condition controls whether the loop should continue.&lt;/p&gt;

&lt;p&gt;while condition:&lt;br&gt;
    # code&lt;/p&gt;

&lt;p&gt;The choice should depend on the problem rather than simply on whether the number of iterations is known.&lt;/p&gt;




&lt;p&gt;What Is an Iterable?&lt;/p&gt;

&lt;p&gt;An iterable is an object whose values can be accessed one at a time.&lt;/p&gt;

&lt;p&gt;Common examples include:&lt;/p&gt;

&lt;p&gt;list&lt;br&gt;
tuple&lt;br&gt;
string&lt;br&gt;
set&lt;br&gt;
dictionary&lt;br&gt;
range&lt;/p&gt;

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

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

&lt;p&gt;for number in numbers:&lt;br&gt;
    print(number)&lt;/p&gt;

&lt;p&gt;The "for" loop gets each value from the iterable.&lt;/p&gt;

&lt;p&gt;Understanding iterables is important because Python's "for" loop is built around iteration.&lt;/p&gt;




&lt;p&gt;Using range()&lt;/p&gt;

&lt;p&gt;The "range()" function is commonly used with "for" loops.&lt;/p&gt;

&lt;p&gt;There are three common forms:&lt;/p&gt;

&lt;p&gt;range(stop)&lt;/p&gt;

&lt;p&gt;range(start, stop)&lt;/p&gt;

&lt;p&gt;range(start, stop, step)&lt;/p&gt;

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

&lt;p&gt;for i in range(5):&lt;br&gt;
    print(i)&lt;/p&gt;

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

&lt;p&gt;0&lt;br&gt;
1&lt;br&gt;
2&lt;br&gt;
3&lt;br&gt;
4&lt;/p&gt;

&lt;p&gt;Notice that "5" is not included.&lt;/p&gt;

&lt;p&gt;We can specify a starting value:&lt;/p&gt;

&lt;p&gt;for i in range(1, 6):&lt;br&gt;
    print(i)&lt;/p&gt;

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

&lt;p&gt;1&lt;br&gt;
2&lt;br&gt;
3&lt;br&gt;
4&lt;br&gt;
5&lt;/p&gt;

&lt;p&gt;We can also specify a step:&lt;/p&gt;

&lt;p&gt;for i in range(0, 11, 2):&lt;br&gt;
    print(i)&lt;/p&gt;

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

&lt;p&gt;0&lt;br&gt;
2&lt;br&gt;
4&lt;br&gt;
6&lt;br&gt;
8&lt;br&gt;
10&lt;/p&gt;

&lt;p&gt;The "step" controls how much the value changes during each iteration.&lt;/p&gt;




&lt;p&gt;Loop Control Variables&lt;/p&gt;

&lt;p&gt;A loop control variable can be used to control how long a loop continues.&lt;/p&gt;

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

&lt;p&gt;count = 1&lt;/p&gt;

&lt;p&gt;while count &amp;lt;= 5:&lt;br&gt;
    print(count)&lt;br&gt;
    count += 1&lt;/p&gt;

&lt;p&gt;Here, "count" starts at "1" and increases after every iteration.&lt;/p&gt;

&lt;p&gt;When it reaches "6", the condition becomes false.&lt;/p&gt;

&lt;p&gt;This is especially important when working with "while" loops.&lt;/p&gt;




&lt;p&gt;Infinite Loops&lt;/p&gt;

&lt;p&gt;An infinite loop is a loop that never reaches a condition that stops it.&lt;/p&gt;

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

&lt;p&gt;while True:&lt;br&gt;
    print("Running...")&lt;/p&gt;

&lt;p&gt;Because the condition is always "True", the loop continues indefinitely.&lt;/p&gt;

&lt;p&gt;An infinite loop can also happen accidentally:&lt;/p&gt;

&lt;p&gt;count = 1&lt;/p&gt;

&lt;p&gt;while count &amp;lt;= 5:&lt;br&gt;
    print(count)&lt;/p&gt;

&lt;p&gt;The problem is that "count" never changes.&lt;/p&gt;

&lt;p&gt;A corrected version is:&lt;/p&gt;

&lt;p&gt;count = 1&lt;/p&gt;

&lt;p&gt;while count &amp;lt;= 5:&lt;br&gt;
    print(count)&lt;br&gt;
    count += 1&lt;/p&gt;

&lt;p&gt;Whenever you write a "while" loop, ask:&lt;/p&gt;

&lt;p&gt;What will eventually make this condition false?&lt;/p&gt;




&lt;p&gt;break, continue and pass&lt;/p&gt;

&lt;p&gt;Python provides three important statements for controlling loop execution:&lt;/p&gt;

&lt;p&gt;break&lt;br&gt;
continue&lt;br&gt;
pass&lt;/p&gt;

&lt;p&gt;They have completely different purposes.&lt;/p&gt;

&lt;p&gt;break&lt;/p&gt;

&lt;p&gt;"break" stops the entire loop.&lt;/p&gt;

&lt;p&gt;for i in range(1, 6):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if i == 3:
    break

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

&lt;/div&gt;

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

&lt;p&gt;1&lt;br&gt;
2&lt;/p&gt;

&lt;p&gt;When "i" becomes "3", the loop terminates.&lt;/p&gt;

&lt;p&gt;This is useful when the required result has already been found and there is no reason to continue.&lt;/p&gt;

&lt;p&gt;continue&lt;/p&gt;

&lt;p&gt;"continue" skips the current iteration.&lt;/p&gt;

&lt;p&gt;for i in range(1, 6):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if i == 3:
    continue

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

&lt;/div&gt;

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

&lt;p&gt;1&lt;br&gt;
2&lt;br&gt;
4&lt;br&gt;
5&lt;/p&gt;

&lt;p&gt;The loop continues after skipping "3".&lt;/p&gt;

&lt;p&gt;pass&lt;/p&gt;

&lt;p&gt;"pass" does nothing.&lt;/p&gt;

&lt;p&gt;for i in range(5):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if i == 2:
    pass

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

&lt;/div&gt;

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

&lt;p&gt;0&lt;br&gt;
1&lt;br&gt;
2&lt;br&gt;
3&lt;br&gt;
4&lt;/p&gt;

&lt;p&gt;So the easiest way to remember them is:&lt;/p&gt;

&lt;p&gt;break     → stop the loop&lt;br&gt;
continue  → skip the current iteration&lt;br&gt;
pass      → do nothing&lt;/p&gt;




&lt;p&gt;Nested Loops&lt;/p&gt;

&lt;p&gt;A loop inside another loop is called a nested loop.&lt;/p&gt;

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

&lt;p&gt;for i in range(1, 4):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for j in range(1, 4):
    print(i, j)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The inner loop executes completely for each iteration of the outer loop.&lt;/p&gt;

&lt;p&gt;Nested loops are useful for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tables&lt;/li&gt;
&lt;li&gt;Grids&lt;/li&gt;
&lt;li&gt;Matrices&lt;/li&gt;
&lt;li&gt;Multi-dimensional data&lt;/li&gt;
&lt;li&gt;Combinations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, they can become expensive when working with large datasets, so unnecessary nested loops should be avoided.&lt;/p&gt;




&lt;p&gt;enumerate()&lt;/p&gt;

&lt;p&gt;Sometimes we need both the position and the value while iterating.&lt;/p&gt;

&lt;p&gt;Python provides "enumerate()" for this purpose.&lt;/p&gt;

&lt;p&gt;fruits = ["Apple", "Banana", "Mango"]&lt;/p&gt;

&lt;p&gt;for index, fruit in enumerate(fruits):&lt;br&gt;
    print(index, fruit)&lt;/p&gt;

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

&lt;p&gt;0 Apple&lt;br&gt;
1 Banana&lt;br&gt;
2 Mango&lt;/p&gt;

&lt;p&gt;This is cleaner than maintaining a separate counter.&lt;/p&gt;




&lt;p&gt;Loop else&lt;/p&gt;

&lt;p&gt;Python has an interesting feature that allows an "else" block to be used with loops.&lt;/p&gt;

&lt;p&gt;The loop "else" executes when the loop finishes normally without "break".&lt;/p&gt;

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

&lt;p&gt;for i in range(5):&lt;br&gt;
    print(i)&lt;br&gt;
else:&lt;br&gt;
    print("Loop completed")&lt;/p&gt;

&lt;p&gt;The "else" block executes because the loop finishes normally.&lt;/p&gt;

&lt;p&gt;But if "break" terminates the loop:&lt;/p&gt;

&lt;p&gt;for i in range(5):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if i == 3:
    break

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

&lt;/div&gt;

&lt;p&gt;else:&lt;br&gt;
    print("Loop completed")&lt;/p&gt;

&lt;p&gt;The "else" block does not execute.&lt;/p&gt;

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

&lt;p&gt;Loop "else" runs when the loop completes without "break".&lt;/p&gt;




&lt;p&gt;Simulating a do-while Loop&lt;/p&gt;

&lt;p&gt;Python does not have a separate "do-while" statement.&lt;/p&gt;

&lt;p&gt;However, similar behavior can be created using "while True" and "break".&lt;/p&gt;

&lt;p&gt;while True:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;value = input("Enter a positive number: ")

if int(value) &amp;gt; 0:
    break
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The body executes first, and the loop can then be terminated when the required condition is satisfied.&lt;/p&gt;

&lt;p&gt;This is useful when an operation needs to execute at least once before checking whether the loop should continue.&lt;/p&gt;




&lt;p&gt;Iterating in Reverse&lt;/p&gt;

&lt;p&gt;The "range()" function can also be used to iterate backwards.&lt;/p&gt;

&lt;p&gt;for number in range(10, 0, -1):&lt;br&gt;
    print(number)&lt;/p&gt;

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

&lt;p&gt;10&lt;br&gt;
9&lt;br&gt;
8&lt;br&gt;
7&lt;br&gt;
6&lt;br&gt;
5&lt;br&gt;
4&lt;br&gt;
3&lt;br&gt;
2&lt;br&gt;
1&lt;/p&gt;

&lt;p&gt;The "-1" tells Python to decrease the value after every iteration.&lt;/p&gt;




&lt;p&gt;Printing Every Other Number&lt;/p&gt;

&lt;p&gt;The "step" argument of "range()" can be used to skip values.&lt;/p&gt;

&lt;p&gt;for number in range(0, 11, 2):&lt;br&gt;
    print(number)&lt;/p&gt;

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

&lt;p&gt;0&lt;br&gt;
2&lt;br&gt;
4&lt;br&gt;
6&lt;br&gt;
8&lt;br&gt;
10&lt;/p&gt;

&lt;p&gt;The value increases by "2" each time.&lt;/p&gt;




&lt;p&gt;Handling Exceptions Inside a Loop&lt;/p&gt;

&lt;p&gt;When processing many values, one invalid value should not always stop the complete operation.&lt;/p&gt;

&lt;p&gt;Python allows us to handle exceptions inside a loop.&lt;/p&gt;

&lt;p&gt;numbers = [10, 5, 0, 3]&lt;/p&gt;

&lt;p&gt;for number in numbers:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try:
    result = 100 / number
    print(result)

except ZeroDivisionError:
    print("Cannot divide by zero")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;When the value is "0", the exception is handled and the loop continues.&lt;/p&gt;

&lt;p&gt;This pattern is useful when processing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data records&lt;/li&gt;
&lt;li&gt;Files&lt;/li&gt;
&lt;li&gt;API responses&lt;/li&gt;
&lt;li&gt;User input&lt;/li&gt;
&lt;li&gt;Large datasets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It makes the program more robust because one problematic record does not necessarily stop the complete process.&lt;/p&gt;




&lt;p&gt;How to Write Better Python Loops&lt;/p&gt;

&lt;p&gt;Once the logic is correct, we can also think about readability and performance.&lt;/p&gt;

&lt;p&gt;Use built-in functions&lt;/p&gt;

&lt;p&gt;For some operations, Python's built-in functions can replace manual loops.&lt;/p&gt;

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

&lt;p&gt;total = sum(numbers)&lt;/p&gt;

&lt;p&gt;Other useful functions include:&lt;/p&gt;

&lt;p&gt;min(numbers)&lt;br&gt;
max(numbers)&lt;/p&gt;

&lt;p&gt;Avoid unnecessary calculations&lt;/p&gt;

&lt;p&gt;If a calculation does not change during the loop, perform it outside the loop when possible.&lt;/p&gt;

&lt;p&gt;Avoid unnecessary nested loops&lt;/p&gt;

&lt;p&gt;Nested loops can become expensive as the amount of data increases.&lt;/p&gt;

&lt;p&gt;Use appropriate data structures&lt;/p&gt;

&lt;p&gt;Sets and dictionaries can be useful for efficient lookup operations.&lt;/p&gt;

&lt;p&gt;Stop processing when the answer is known&lt;/p&gt;

&lt;p&gt;Use "break" when there is no reason to continue.&lt;/p&gt;

&lt;p&gt;Consider vectorized operations for data processing&lt;/p&gt;

&lt;p&gt;When working with libraries such as Pandas and NumPy, a Python loop is not always the best solution. Vectorized operations can often be more appropriate for large datasets.&lt;/p&gt;




&lt;p&gt;Why Loops Matter in Data Engineering and Data Analytics&lt;/p&gt;

&lt;p&gt;Loops are basic Python concepts, but they appear in many real-world tasks.&lt;/p&gt;

&lt;p&gt;For example, they can be used while:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Processing records&lt;/li&gt;
&lt;li&gt;Validating data&lt;/li&gt;
&lt;li&gt;Transforming values&lt;/li&gt;
&lt;li&gt;Reading files&lt;/li&gt;
&lt;li&gt;Calling APIs&lt;/li&gt;
&lt;li&gt;Handling errors&lt;/li&gt;
&lt;li&gt;Automating repetitive operations&lt;/li&gt;
&lt;li&gt;Building data-processing scripts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As your Python knowledge grows, you will also learn when not to use a loop.&lt;/p&gt;

&lt;p&gt;For example, Pandas and NumPy provide operations that can process collections of data more efficiently than manually iterating through every row in many situations.&lt;/p&gt;

&lt;p&gt;So the goal is not simply to learn loop syntax.&lt;/p&gt;

&lt;p&gt;The goal is to understand how and when to control program execution effectively.&lt;/p&gt;




&lt;p&gt;Going Deeper: Python Loops and Flow Control&lt;/p&gt;

&lt;p&gt;The examples above give you the foundation.&lt;/p&gt;

&lt;p&gt;But if you are preparing for technical interviews or want to understand the topic more deeply, there are many details worth exploring—such as iterable behavior, loop termination, "range()", "enumerate()", nested loops, loop "else", "break" and "continue", do-while behavior, optimization, and exception handling.&lt;/p&gt;

&lt;p&gt;I have put those deeper topics into a separate 25-question Python Loops and Flow Control technical Q&amp;amp;A resource, with detailed explanations and examples.&lt;/p&gt;

&lt;p&gt;👉 "Explore the detailed Python Loops and Flow Control questions and answers" (&lt;a href="https://www.sankalandtech.com/Tutorials/Python/interview-questions/python-control-structures-loops.html" rel="noopener noreferrer"&gt;https://www.sankalandtech.com/Tutorials/Python/interview-questions/python-control-structures-loops.html&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;You can use this post to understand the concepts first, and then use the detailed Q&amp;amp;A resource when you want to test your understanding or go deeper into the technical side of Python loops.&lt;/p&gt;




&lt;p&gt;Final Takeaway&lt;/p&gt;

&lt;p&gt;Python loops are more than just a way to repeat code.&lt;/p&gt;

&lt;p&gt;They are a fundamental part of controlling program execution.&lt;/p&gt;

&lt;p&gt;The important concepts to remember are:&lt;/p&gt;

&lt;p&gt;for        → iterate over an iterable&lt;br&gt;
while      → repeat while a condition is true&lt;br&gt;
range()    → generate a sequence of numbers&lt;br&gt;
enumerate  → get index and value&lt;br&gt;
break      → stop the loop&lt;br&gt;
continue   → skip the current iteration&lt;br&gt;
pass       → do nothing&lt;br&gt;
nested loop → loop inside another loop&lt;br&gt;
loop else  → execute when the loop completes normally&lt;/p&gt;

&lt;p&gt;Start with small examples.&lt;/p&gt;

&lt;p&gt;Run the code.&lt;/p&gt;

&lt;p&gt;Change the conditions.&lt;/p&gt;

&lt;p&gt;Predict the output.&lt;/p&gt;

&lt;p&gt;Then move to real-world data-processing problems.&lt;/p&gt;

&lt;p&gt;That is where Python loops and flow control become much more useful.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Python if-else: A Simple Guide with Examples</title>
      <dc:creator>Kailas Warade</dc:creator>
      <pubDate>Thu, 01 Oct 2026 03:19:23 +0000</pubDate>
      <link>https://dev.to/kailas_warade_d2a15d1ef8a/python-if-else-a-simple-guide-with-examples-6km</link>
      <guid>https://dev.to/kailas_warade_d2a15d1ef8a/python-if-else-a-simple-guide-with-examples-6km</guid>
      <description>&lt;p&gt;Python if-else: A Simple Guide with Examples&lt;/p&gt;

&lt;p&gt;Programs often need to make decisions.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;If the temperature is high, show a warning.&lt;/li&gt;
&lt;li&gt;If a file exists, read it.&lt;/li&gt;
&lt;li&gt;If marks are above 40, consider the student passed.&lt;/li&gt;
&lt;li&gt;If a value is missing, handle it differently.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Python uses "if", "elif", and "else" to handle this kind of logic.&lt;/p&gt;

&lt;p&gt;These are simple statements, but you will use them regularly when writing Python programs.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Python if statement&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's start with a simple example.&lt;/p&gt;

&lt;p&gt;age = 25&lt;/p&gt;

&lt;p&gt;if age &amp;gt;= 18:&lt;br&gt;
    print("Adult")&lt;/p&gt;

&lt;p&gt;The condition "age &amp;gt;= 18" is checked first.&lt;/p&gt;

&lt;p&gt;If it is "True", Python runs the indented code below it.&lt;/p&gt;

&lt;p&gt;If it is "False", Python skips that code.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Python if-else&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Sometimes we have two possible results.&lt;/p&gt;

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

&lt;p&gt;marks = 65&lt;/p&gt;

&lt;p&gt;if marks &amp;gt;= 40:&lt;br&gt;
    print("Pass")&lt;br&gt;
else:&lt;br&gt;
    print("Fail")&lt;/p&gt;

&lt;p&gt;Here, Python does one of two things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"marks &amp;gt;= 40" is true → "Pass"&lt;/li&gt;
&lt;li&gt;"marks &amp;gt;= 40" is false → "Fail"&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Python if-elif-else&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What if there are several possible results?&lt;/p&gt;

&lt;p&gt;We can use "elif".&lt;/p&gt;

&lt;p&gt;marks = 78&lt;/p&gt;

&lt;p&gt;if marks &amp;gt;= 75:&lt;br&gt;
    print("Distinction")&lt;br&gt;
elif marks &amp;gt;= 60:&lt;br&gt;
    print("First Class")&lt;br&gt;
elif marks &amp;gt;= 40:&lt;br&gt;
    print("Pass")&lt;br&gt;
else:&lt;br&gt;
    print("Fail")&lt;/p&gt;

&lt;p&gt;Python checks the conditions from top to bottom.&lt;/p&gt;

&lt;p&gt;For "marks = 78", the first condition is true, so Python prints:&lt;/p&gt;

&lt;p&gt;Distinction&lt;/p&gt;

&lt;p&gt;It does not continue checking the remaining "elif" conditions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Multiple if statements vs if-elif-else&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is an important difference.&lt;/p&gt;

&lt;p&gt;With separate "if" statements:&lt;/p&gt;

&lt;p&gt;num = 10&lt;/p&gt;

&lt;p&gt;if num &amp;gt; 0:&lt;br&gt;
    print("Positive")&lt;/p&gt;

&lt;p&gt;if num &amp;gt; 5:&lt;br&gt;
    print("Greater than 5")&lt;/p&gt;

&lt;p&gt;Both conditions are checked independently.&lt;/p&gt;

&lt;p&gt;With "if-elif":&lt;/p&gt;

&lt;p&gt;num = 10&lt;/p&gt;

&lt;p&gt;if num &amp;gt; 0:&lt;br&gt;
    print("Positive")&lt;br&gt;
elif num &amp;gt; 5:&lt;br&gt;
    print("Greater than 5")&lt;/p&gt;

&lt;p&gt;Once the first condition is true, Python skips the "elif".&lt;/p&gt;

&lt;p&gt;A simple way to remember this:&lt;/p&gt;

&lt;p&gt;Separate "if" statements are independent.&lt;/p&gt;

&lt;p&gt;"if-elif-else" is one chain of conditions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using "and"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We can combine conditions with logical operators.&lt;/p&gt;

&lt;p&gt;With "and", all conditions must be true.&lt;/p&gt;

&lt;p&gt;age = 25&lt;br&gt;
salary = 50000&lt;/p&gt;

&lt;p&gt;if age &amp;gt;= 18 and salary &amp;gt;= 30000:&lt;br&gt;
    print("Eligible")&lt;/p&gt;

&lt;p&gt;Both conditions need to be "True" for the message to be printed.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using "or"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With "or", at least one condition needs to be true.&lt;/p&gt;

&lt;p&gt;day = "Saturday"&lt;/p&gt;

&lt;p&gt;if day == "Saturday" or day == "Sunday":&lt;br&gt;
    print("Weekend")&lt;/p&gt;

&lt;p&gt;The condition is true because "day == "Saturday"" is true.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using "not"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;"not" reverses a Boolean condition.&lt;/p&gt;

&lt;p&gt;is_active = False&lt;/p&gt;

&lt;p&gt;if not is_active:&lt;br&gt;
    print("Account is inactive")&lt;/p&gt;

&lt;p&gt;Since "is_active" is "False", "not is_active" is "True".&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Nested if&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;An "if" statement can be placed inside another "if".&lt;/p&gt;

&lt;p&gt;age = 25&lt;br&gt;
has_id = True&lt;/p&gt;

&lt;p&gt;if age &amp;gt;= 18:&lt;br&gt;
    if has_id:&lt;br&gt;
        print("Access allowed")&lt;/p&gt;

&lt;p&gt;This is called a nested "if".&lt;/p&gt;

&lt;p&gt;Nested conditions are sometimes useful, but too many levels of nesting can make code difficult to read.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Python conditional expression&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For a simple two-way decision, Python provides a conditional expression.&lt;/p&gt;

&lt;p&gt;age = 20&lt;/p&gt;

&lt;p&gt;result = "Adult" if age &amp;gt;= 18 else "Minor"&lt;/p&gt;

&lt;p&gt;print(result)&lt;/p&gt;

&lt;p&gt;This is often called a ternary expression.&lt;/p&gt;

&lt;p&gt;It can make short conditions more compact.&lt;/p&gt;

&lt;p&gt;For complicated logic, however, a normal "if-else" statement is usually easier to understand.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Checking positive, negative, or zero&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is another simple example:&lt;/p&gt;

&lt;p&gt;num = -5&lt;/p&gt;

&lt;p&gt;if num &amp;gt; 0:&lt;br&gt;
    print("Positive")&lt;br&gt;
elif num &amp;lt; 0:&lt;br&gt;
    print("Negative")&lt;br&gt;
else:&lt;br&gt;
    print("Zero")&lt;/p&gt;

&lt;p&gt;Changing "num" to "10", "-10", or "0" will produce different results.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Checking a leap year&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A slightly more interesting example is checking whether a year is a leap year.&lt;/p&gt;

&lt;p&gt;year = 2024&lt;/p&gt;

&lt;p&gt;if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0):&lt;br&gt;
    print("Leap year")&lt;br&gt;
else:&lt;br&gt;
    print("Not a leap year")&lt;/p&gt;

&lt;p&gt;This example combines the modulo operator "%" with "and" and "or".&lt;/p&gt;

&lt;p&gt;Try these values:&lt;/p&gt;

&lt;p&gt;2024&lt;br&gt;
2023&lt;br&gt;
2000&lt;br&gt;
1900&lt;/p&gt;

&lt;p&gt;and see what happens.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Comparing two numbers&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We can also use conditions to compare values.&lt;/p&gt;

&lt;p&gt;a = 25&lt;br&gt;
b = 40&lt;/p&gt;

&lt;p&gt;if a &amp;gt; b:&lt;br&gt;
    print("a is larger")&lt;br&gt;
elif b &amp;gt; a:&lt;br&gt;
    print("b is larger")&lt;br&gt;
else:&lt;br&gt;
    print("Both are equal")&lt;/p&gt;

&lt;p&gt;The final "else" handles the case where both values are equal.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using if inside a function&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Conditional logic is also commonly used inside functions.&lt;/p&gt;

&lt;p&gt;def check_age(age):&lt;br&gt;
    if age &amp;lt; 18:&lt;br&gt;
        return "Minor"&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;print(check_age(25))&lt;/p&gt;

&lt;p&gt;Here, the function returns ""Minor"" when the age is below 18. Otherwise, it returns ""Adult"".&lt;/p&gt;

&lt;p&gt;Notice that we don't need an "else" after "return".&lt;/p&gt;

&lt;p&gt;Once "return" runs, the function ends.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Common Python if-else mistakes&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Using "=" instead of "=="&lt;/p&gt;

&lt;p&gt;Use "=" when assigning a value:&lt;/p&gt;

&lt;p&gt;age = 18&lt;/p&gt;

&lt;p&gt;Use "==" when comparing values:&lt;/p&gt;

&lt;p&gt;if age == 18:&lt;br&gt;
    print("Age is 18")&lt;/p&gt;

&lt;p&gt;Incorrect indentation&lt;/p&gt;

&lt;p&gt;Python uses indentation to define code blocks.&lt;/p&gt;

&lt;p&gt;This is incorrect:&lt;/p&gt;

&lt;p&gt;if age &amp;gt;= 18:&lt;br&gt;
print("Adult")&lt;/p&gt;

&lt;p&gt;The correct version is:&lt;/p&gt;

&lt;p&gt;if age &amp;gt;= 18:&lt;br&gt;
    print("Adult")&lt;/p&gt;

&lt;p&gt;Using "true" and "false"&lt;/p&gt;

&lt;p&gt;Python uses "True" and "False".&lt;/p&gt;

&lt;p&gt;is_active = True&lt;/p&gt;

&lt;p&gt;if is_active:&lt;br&gt;
    print("Active")&lt;/p&gt;

&lt;p&gt;"true" and "false" are not the Python Boolean values.&lt;/p&gt;

&lt;p&gt;A few things to practice&lt;/p&gt;

&lt;p&gt;After understanding the examples above, try writing these programs yourself:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Check whether a number is even or odd.&lt;/li&gt;
&lt;li&gt;Find the largest of three numbers.&lt;/li&gt;
&lt;li&gt;Check whether a person is eligible based on age.&lt;/li&gt;
&lt;li&gt;Convert marks into a grade.&lt;/li&gt;
&lt;li&gt;Check whether a number is positive, negative, or zero.&lt;/li&gt;
&lt;li&gt;Check whether a year is a leap year.&lt;/li&gt;
&lt;li&gt;Check whether a password meets a few basic conditions.&lt;/li&gt;
&lt;li&gt;Use "and", "or", and "not" in a small program.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Try solving them without looking at the examples first.&lt;/p&gt;

&lt;p&gt;More Python if-else examples&lt;/p&gt;

&lt;p&gt;If you want more practice, I have a separate collection of Python conditional-statement examples and questions covering "if", "elif", "else", nested conditions, logical operators, conditional expressions, and practical problems:&lt;/p&gt;

&lt;p&gt;Python If-Else Examples and Interview Questions:&lt;br&gt;
&lt;a href="https://www.sankalandtech.com/Tutorials/Python/interview-questions/python-control-structures-if-else.html" rel="noopener noreferrer"&gt;https://www.sankalandtech.com/Tutorials/Python/interview-questions/python-control-structures-if-else.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The examples can be useful whether you are learning Python for the first time, working with data, writing automation scripts, or preparing for a Python interview.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Python Operators Explained with Simple Examples</title>
      <dc:creator>Kailas Warade</dc:creator>
      <pubDate>Sun, 27 Sep 2026 18:53:19 +0000</pubDate>
      <link>https://dev.to/kailas_warade_d2a15d1ef8a/python-operators-explained-with-simple-examples-146n</link>
      <guid>https://dev.to/kailas_warade_d2a15d1ef8a/python-operators-explained-with-simple-examples-146n</guid>
      <description>&lt;p&gt;&lt;strong&gt;Python Operators Explained with Simple Examples&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Python operators are symbols or keywords used to perform operations on values and variables.&lt;/p&gt;

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

&lt;p&gt;a = 10&lt;br&gt;
b = 3&lt;/p&gt;

&lt;p&gt;print(a + b)&lt;br&gt;
print(a &amp;gt; b)&lt;/p&gt;

&lt;p&gt;Here, "+" adds two values and "&amp;gt;" compares them.&lt;/p&gt;

&lt;p&gt;If you are learning Python or preparing for a Python interview, understanding operators is important because you will use them in almost every Python program.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Main Types of Python Operators&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Operator Type| Common Operators| Used For&lt;br&gt;
Arithmetic| "+ - * / // % **"| Mathematical calculations&lt;br&gt;
Comparison| "== != &amp;gt; &amp;lt; &amp;gt;= &amp;lt;="| Comparing values&lt;br&gt;
Logical| "and or not"| Combining conditions&lt;br&gt;
Assignment| "= += -= *= /="| Assigning and updating values&lt;br&gt;
Membership| "in", "not in"| Checking whether a value exists&lt;br&gt;
Identity| "is", "is not"| Checking object identity&lt;/p&gt;

&lt;p&gt;Let's look at each type with simple examples.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Arithmetic Operators&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Arithmetic operators are used for calculations.&lt;/p&gt;

&lt;p&gt;a = 10&lt;br&gt;
b = 3&lt;/p&gt;

&lt;p&gt;print(a + b)   # 13&lt;br&gt;
print(a - b)   # 7&lt;br&gt;
print(a * b)   # 30&lt;br&gt;
print(a / b)   # 3.3333333333333335&lt;br&gt;
print(a // b)  # 3&lt;br&gt;
print(a % b)   # 1&lt;br&gt;
print(a ** b)  # 1000&lt;/p&gt;

&lt;p&gt;Some operators need special attention.&lt;/p&gt;

&lt;p&gt;"/" Division&lt;/p&gt;

&lt;p&gt;"/" returns the normal division result.&lt;/p&gt;

&lt;p&gt;print(10 / 3)&lt;/p&gt;

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

&lt;p&gt;3.3333333333333335&lt;/p&gt;

&lt;p&gt;"//" Floor Division&lt;/p&gt;

&lt;p&gt;"//" returns the floor value of the division.&lt;/p&gt;

&lt;p&gt;print(10 // 3)&lt;/p&gt;

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

&lt;p&gt;3&lt;/p&gt;

&lt;p&gt;"%" Modulus&lt;/p&gt;

&lt;p&gt;"%" returns the remainder.&lt;/p&gt;

&lt;p&gt;print(10 % 3)&lt;/p&gt;

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

&lt;p&gt;1&lt;/p&gt;

&lt;p&gt;It is often useful for checking whether a number is even or odd.&lt;/p&gt;

&lt;p&gt;number = 10&lt;/p&gt;

&lt;p&gt;if number % 2 == 0:&lt;br&gt;
    print("Even")&lt;/p&gt;

&lt;p&gt;"**" Exponentiation&lt;/p&gt;

&lt;p&gt;"**" is used to raise a number to a power.&lt;/p&gt;

&lt;p&gt;print(2 ** 3)&lt;/p&gt;

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

&lt;p&gt;8&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Comparison Operators&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Comparison operators compare two values.&lt;/p&gt;

&lt;p&gt;The result is always "True" or "False".&lt;/p&gt;

&lt;p&gt;a = 10&lt;br&gt;
b = 20&lt;/p&gt;

&lt;p&gt;print(a == b)  # False&lt;br&gt;
print(a != b)  # True&lt;br&gt;
print(a &amp;gt; b)   # False&lt;br&gt;
print(a &amp;lt; b)   # True&lt;br&gt;
print(a &amp;gt;= b)  # False&lt;br&gt;
print(a &amp;lt;= b)  # True&lt;/p&gt;

&lt;p&gt;One common mistake is confusing "=" and "==".&lt;/p&gt;

&lt;p&gt;"=" vs "=="&lt;/p&gt;

&lt;p&gt;"=" is used to assign a value.&lt;/p&gt;

&lt;p&gt;age = 25&lt;/p&gt;

&lt;p&gt;"==" is used to compare two values.&lt;/p&gt;

&lt;p&gt;age == 25&lt;/p&gt;

&lt;p&gt;This difference is very important in Python.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;3. Logical Operators&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Logical operators are mainly used when working with multiple conditions.&lt;/p&gt;

&lt;p&gt;Python has three logical operators:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"and"&lt;/li&gt;
&lt;li&gt;"or"&lt;/li&gt;
&lt;li&gt;"not"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;"and"&lt;/p&gt;

&lt;p&gt;Both conditions must be "True".&lt;/p&gt;

&lt;p&gt;age = 25&lt;br&gt;
salary = 50000&lt;/p&gt;

&lt;p&gt;if age &amp;gt;= 18 and salary &amp;gt;= 30000:&lt;br&gt;
    print("Eligible")&lt;/p&gt;

&lt;p&gt;"or"&lt;/p&gt;

&lt;p&gt;At least one condition must be "True".&lt;/p&gt;

&lt;p&gt;age = 25&lt;br&gt;
salary = 20000&lt;/p&gt;

&lt;p&gt;if age &amp;gt;= 18 or salary &amp;gt;= 30000:&lt;br&gt;
    print("Eligible")&lt;/p&gt;

&lt;p&gt;"not"&lt;/p&gt;

&lt;p&gt;"not" reverses the result.&lt;/p&gt;

&lt;p&gt;is_active = True&lt;/p&gt;

&lt;p&gt;print(not is_active)&lt;/p&gt;

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

&lt;p&gt;False&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;4. Assignment Operators&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Assignment operators are used to assign or update values.&lt;/p&gt;

&lt;p&gt;salary = 50000&lt;/p&gt;

&lt;p&gt;salary += 5000&lt;br&gt;
print(salary)&lt;/p&gt;

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

&lt;p&gt;55000&lt;/p&gt;

&lt;p&gt;Here are some common assignment operators:&lt;/p&gt;

&lt;p&gt;Operator| Example| Meaning&lt;br&gt;
"="| "x = 10"| Assign 10 to x&lt;br&gt;
"+="| "x += 5"| Add 5 to x&lt;br&gt;
"-="| "x -= 5"| Subtract 5 from x&lt;br&gt;
"*="| "x *= 5"| Multiply x by 5&lt;br&gt;
"/="| "x /= 5"| Divide x by 5&lt;/p&gt;

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

&lt;p&gt;x = 10&lt;/p&gt;

&lt;p&gt;x += 5&lt;br&gt;
print(x)  # 15&lt;/p&gt;

&lt;p&gt;x -= 3&lt;br&gt;
print(x)  # 12&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;5. Membership Operators&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Membership operators check whether a value exists inside a sequence such as a list or string.&lt;/p&gt;

&lt;p&gt;The two membership operators are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"in"&lt;/li&gt;
&lt;li&gt;"not in"&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;languages = ["Python", "Java", "SQL"]&lt;/p&gt;

&lt;p&gt;print("Python" in languages)&lt;br&gt;
print("C++" in languages)&lt;/p&gt;

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

&lt;p&gt;True&lt;br&gt;
False&lt;/p&gt;

&lt;p&gt;You can also use them with strings:&lt;/p&gt;

&lt;p&gt;name = "Python Programming"&lt;/p&gt;

&lt;p&gt;print("Python" in name)&lt;/p&gt;

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

&lt;p&gt;True&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;6. Identity Operators&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Python has two identity operators:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"is"&lt;/li&gt;
&lt;li&gt;"is not"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They check whether two variables refer to the same object.&lt;/p&gt;

&lt;p&gt;a = [1, 2, 3]&lt;br&gt;
b = a&lt;/p&gt;

&lt;p&gt;print(a is b)&lt;/p&gt;

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

&lt;p&gt;True&lt;/p&gt;

&lt;p&gt;Here, "b" refers to the same list object as "a".&lt;/p&gt;

&lt;p&gt;"==" vs "is"&lt;/p&gt;

&lt;p&gt;This is an important Python interview question.&lt;/p&gt;

&lt;p&gt;"==" checks whether two values are equal.&lt;/p&gt;

&lt;p&gt;"is" checks whether two variables refer to the same object.&lt;/p&gt;

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

&lt;p&gt;a = [1, 2, 3]&lt;br&gt;
b = [1, 2, 3]&lt;/p&gt;

&lt;p&gt;print(a == b)&lt;br&gt;
print(a is b)&lt;/p&gt;

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

&lt;p&gt;True&lt;br&gt;
False&lt;/p&gt;

&lt;p&gt;The values are equal, but they are different list objects.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;7. Operator Precedence&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
When an expression contains multiple operators, Python follows operator precedence to decide which operation happens first.&lt;/p&gt;

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

&lt;p&gt;result = 10 + 5 * 2&lt;/p&gt;

&lt;p&gt;print(result)&lt;/p&gt;

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

&lt;p&gt;20&lt;/p&gt;

&lt;p&gt;Multiplication happens before addition.&lt;/p&gt;

&lt;p&gt;You can use parentheses when you want to make the order clear:&lt;/p&gt;

&lt;p&gt;result = (10 + 5) * 2&lt;/p&gt;

&lt;p&gt;print(result)&lt;/p&gt;

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

&lt;p&gt;30&lt;/p&gt;

&lt;p&gt;Using parentheses also makes the code easier to read.&lt;/p&gt;

&lt;p&gt;A Small Practical Example&lt;/p&gt;

&lt;p&gt;Suppose we have an employee salary and want to calculate a bonus.&lt;/p&gt;

&lt;p&gt;salary = 50000&lt;br&gt;
bonus = 5000&lt;/p&gt;

&lt;p&gt;total_salary = salary + bonus&lt;/p&gt;

&lt;p&gt;if total_salary &amp;gt;= 55000:&lt;br&gt;
    print("Salary target reached")&lt;/p&gt;

&lt;p&gt;This small example uses different operators together:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"+" calculates the total salary.&lt;/li&gt;
&lt;li&gt;"&amp;gt;=" compares the salary.&lt;/li&gt;
&lt;li&gt;"=" assigns values.&lt;/li&gt;
&lt;li&gt;"if" uses the result of the comparison.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is how operators are normally used in real Python programs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quick Revision&lt;br&gt;
**&lt;br&gt;
Operator| Example| Purpose&lt;br&gt;
"+"| "a + b"| Addition&lt;br&gt;
"-"| "a - b"| Subtraction&lt;br&gt;
"*"| "a * b"| Multiplication&lt;br&gt;
"/"| "a / b"| Division&lt;br&gt;
"//"| "a // b"| Floor division&lt;br&gt;
"%"| "a % b"| Remainder&lt;br&gt;
"&lt;/strong&gt;"| "a ** b"| Power&lt;br&gt;
"=="| "a == b"| Equal comparison&lt;br&gt;
"!="| "a != b"| Not equal&lt;br&gt;
"&amp;gt;"| "a &amp;gt; b"| Greater than&lt;br&gt;
"&amp;lt;"| "a &amp;lt; b"| Less than&lt;br&gt;
"and"| "a and b"| Both conditions&lt;br&gt;
"or"| "a or b"| Either condition&lt;br&gt;
"not"| "not a"| Reverse condition&lt;br&gt;
"in"| "x in list"| Check membership&lt;br&gt;
"is"| "a is b"| Check object identity&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Frequently Asked Questions&lt;br&gt;
**&lt;br&gt;
**What is the difference between "/" and "//" in Python&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;"/" performs normal division and returns a division result.&lt;/p&gt;

&lt;p&gt;"//" performs floor division and returns the floor value.&lt;/p&gt;

&lt;p&gt;print(10 / 3)   # 3.3333333333333335&lt;br&gt;
print(10 // 3)  # 3&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the difference between "==" and "is" in Python?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;"==" checks whether two values are equal.&lt;/p&gt;

&lt;p&gt;"is" checks whether two variables refer to the same object.&lt;/p&gt;

&lt;p&gt;This is an important difference to understand when working with Python objects.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;More Python Operators Interview Questions&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
If you are preparing for a Python interview, you can find more operator-based interview questions and answers here:&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;"Python Operators Interview Questions and Answers" (&lt;a href="https://www.sankalandtech.com/Tutorials/Python/interview-questions/python-operators-overview.html" rel="noopener noreferrer"&gt;https://www.sankalandtech.com/Tutorials/Python/interview-questions/python-operators-overview.html&lt;/a&gt;)&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The examples cover the important Python operators and explain where they are used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Python operators are simple, but they are used everywhere in Python programming.&lt;/p&gt;

&lt;p&gt;The most important ones to understand first are arithmetic, comparison, logical, assignment, membership, and identity operators.&lt;/p&gt;

&lt;p&gt;Once these operators are clear, writing conditions and calculations in Python becomes much easier..&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Python Data Types Explained With Practical Examples</title>
      <dc:creator>Kailas Warade</dc:creator>
      <pubDate>Fri, 25 Sep 2026 04:00:40 +0000</pubDate>
      <link>https://dev.to/kailas_warade_d2a15d1ef8a/python-data-types-explained-with-practical-examples-51m4</link>
      <guid>https://dev.to/kailas_warade_d2a15d1ef8a/python-data-types-explained-with-practical-examples-51m4</guid>
      <description>&lt;p&gt;Python Data Types Explained With Practical Examples&lt;/p&gt;

&lt;p&gt;When you write a Python program, you work with different kinds of values every day.&lt;/p&gt;

&lt;p&gt;You might store a person's name, an age, a price, a list of products, or information returned by an API. Python needs to know what kind of value it is dealing with, and that's where data types come in.&lt;/p&gt;

&lt;p&gt;If you're learning Python, data types are one of those topics that look simple at first but become important when you start working with functions, APIs, databases, Pandas, or data analysis.&lt;/p&gt;

&lt;p&gt;Let's look at the most commonly used Python data types with simple examples.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Numbers: "int" and "float"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Python uses "int" for whole numbers and "float" for numbers with decimal values.&lt;/p&gt;

&lt;p&gt;age = 45&lt;br&gt;
price = 1250.50&lt;/p&gt;

&lt;p&gt;print(type(age))&lt;br&gt;
print(type(price))&lt;/p&gt;

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



&lt;p&gt;For example, an age would normally be an integer, while a product price might contain decimal values.&lt;/p&gt;

&lt;p&gt;One thing worth knowing about floats is that they don't always represent decimal numbers exactly.&lt;/p&gt;

&lt;p&gt;print(0.1 + 0.2)&lt;/p&gt;

&lt;p&gt;You may get:&lt;/p&gt;

&lt;p&gt;0.30000000000000004&lt;/p&gt;

&lt;p&gt;This isn't a Python bug. It comes from the way floating-point numbers are represented internally.&lt;/p&gt;

&lt;p&gt;It becomes especially important when you're working with calculations where precision matters.&lt;/p&gt;

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

&lt;p&gt;A string is a sequence of characters.&lt;/p&gt;

&lt;p&gt;name = "Kailas"&lt;/p&gt;

&lt;p&gt;print(name)&lt;br&gt;
print(type(name))&lt;/p&gt;

&lt;p&gt;Strings support indexing:&lt;/p&gt;

&lt;p&gt;language = "Python"&lt;/p&gt;

&lt;p&gt;print(language[0])&lt;/p&gt;

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

&lt;p&gt;P&lt;/p&gt;

&lt;p&gt;You can also take a part of a string using slicing:&lt;/p&gt;

&lt;p&gt;print(language[0:3])&lt;/p&gt;

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

&lt;p&gt;Pyt&lt;/p&gt;

&lt;p&gt;One important point is that strings are immutable.&lt;/p&gt;

&lt;p&gt;You can't change one character directly after the string has been created.&lt;/p&gt;

&lt;p&gt;name = "Python"&lt;/p&gt;
&lt;h1&gt;
  
  
  name[0] = "J"   # TypeError
&lt;/h1&gt;

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

&lt;p&gt;A list is useful when you need to keep multiple values together.&lt;/p&gt;

&lt;p&gt;languages = ["Python", "SQL", "Java"]&lt;/p&gt;

&lt;p&gt;print(languages)&lt;/p&gt;

&lt;p&gt;One of the biggest advantages of a list is that it can be changed.&lt;/p&gt;

&lt;p&gt;languages[1] = "C++"&lt;/p&gt;

&lt;p&gt;print(languages)&lt;/p&gt;

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

&lt;p&gt;['Python', 'C++', 'Java']&lt;/p&gt;

&lt;p&gt;You can also add new values:&lt;/p&gt;

&lt;p&gt;languages.append("Go")&lt;/p&gt;

&lt;p&gt;This is why lists are commonly used when the collection of values may change during program execution.&lt;/p&gt;

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

&lt;p&gt;Tuples also store multiple values, but they are immutable.&lt;/p&gt;

&lt;p&gt;coordinates = (18.52, 73.85)&lt;/p&gt;

&lt;p&gt;print(coordinates)&lt;/p&gt;

&lt;p&gt;Once a tuple is created, you can't change one of its elements.&lt;/p&gt;

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

&lt;p&gt;List   → mutable&lt;br&gt;
Tuple  → immutable&lt;/p&gt;

&lt;p&gt;Neither is automatically better. The right choice depends on what you need to do with the data.&lt;/p&gt;

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

&lt;p&gt;A dictionary stores information using key-value pairs.&lt;/p&gt;

&lt;p&gt;student = {&lt;br&gt;
    "name": "Rahul",&lt;br&gt;
    "age": 25,&lt;br&gt;
    "city": "Pune"&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;print(student["name"])&lt;/p&gt;

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

&lt;p&gt;Rahul&lt;/p&gt;

&lt;p&gt;This is useful when the meaning of each value matters.&lt;/p&gt;

&lt;p&gt;Compare:&lt;/p&gt;

&lt;p&gt;student = ["Rahul", 25, "Pune"]&lt;/p&gt;

&lt;p&gt;with:&lt;/p&gt;

&lt;p&gt;student = {&lt;br&gt;
    "name": "Rahul",&lt;br&gt;
    "age": 25,&lt;br&gt;
    "city": "Pune"&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;The second version makes the data much easier to understand.&lt;/p&gt;

&lt;p&gt;Dictionaries are widely used in Python applications, APIs, configuration files, and JSON data.&lt;/p&gt;

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

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

&lt;p&gt;numbers = {10, 20, 30, 10, 20}&lt;/p&gt;

&lt;p&gt;print(numbers)&lt;/p&gt;

&lt;p&gt;The duplicate values are removed.&lt;/p&gt;

&lt;p&gt;Sets are particularly useful when you need operations such as union, intersection, or difference.&lt;/p&gt;

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

&lt;p&gt;a = {1, 2, 3}&lt;br&gt;
b = {3, 4, 5}&lt;/p&gt;

&lt;p&gt;print(a.intersection(b))&lt;/p&gt;

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

&lt;p&gt;{3}&lt;/p&gt;

&lt;p&gt;If your main requirement is to work with unique values, a set can be very convenient.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Boolean Values&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Boolean values represent either "True" or "False".&lt;/p&gt;

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

&lt;p&gt;age = 25&lt;/p&gt;

&lt;p&gt;is_adult = age &amp;gt;= 18&lt;/p&gt;

&lt;p&gt;print(is_adult)&lt;/p&gt;

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

&lt;p&gt;True&lt;/p&gt;

&lt;p&gt;You'll see Boolean values everywhere in Python, especially in conditions, filtering, validation, and data processing.&lt;/p&gt;

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

&lt;p&gt;if is_adult:&lt;br&gt;
    print("Allowed")&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is "None" in Python?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;"None" is a special value that represents the absence of a value.&lt;/p&gt;

&lt;p&gt;result = None&lt;/p&gt;

&lt;p&gt;print(result)&lt;br&gt;
print(type(result))&lt;/p&gt;

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

&lt;p&gt;None&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;It's important not to confuse "None" with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"0"&lt;/li&gt;
&lt;li&gt;"False"&lt;/li&gt;
&lt;li&gt;""""&lt;/li&gt;
&lt;li&gt;an empty list&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They represent different things.&lt;/p&gt;

&lt;p&gt;You'll often encounter "None" when working with functions, databases, APIs, and optional values.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Type Conversion&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Sometimes the value you receive isn't in the type you need.&lt;/p&gt;

&lt;p&gt;A common example is user input.&lt;/p&gt;

&lt;p&gt;age = input("Enter your age: ")&lt;/p&gt;

&lt;p&gt;print(type(age))&lt;/p&gt;

&lt;p&gt;Even if the user enters:&lt;/p&gt;

&lt;p&gt;45&lt;/p&gt;

&lt;p&gt;the result from "input()" is a string.&lt;/p&gt;

&lt;p&gt;If you want to perform numerical calculations, you can convert it:&lt;/p&gt;

&lt;p&gt;age = int(age)&lt;/p&gt;

&lt;p&gt;print(age + 5)&lt;/p&gt;

&lt;p&gt;Python provides several common conversion functions:&lt;/p&gt;

&lt;p&gt;int()&lt;br&gt;
float()&lt;br&gt;
str()&lt;br&gt;
list()&lt;br&gt;
tuple()&lt;/p&gt;

&lt;p&gt;But conversion isn't always possible.&lt;/p&gt;

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

&lt;p&gt;int("Python")&lt;/p&gt;

&lt;p&gt;will raise a "ValueError" because ""Python"" cannot be converted into an integer.&lt;/p&gt;

&lt;p&gt;This is something you'll frequently deal with when processing files, APIs, databases, and user input.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Mutable vs Immutable Data Types&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is one of the Python concepts that is worth understanding properly.&lt;/p&gt;

&lt;p&gt;Some objects can be changed after they are created. Others cannot.&lt;/p&gt;

&lt;p&gt;Common mutable types include:&lt;/p&gt;

&lt;p&gt;list&lt;br&gt;
dict&lt;br&gt;
set&lt;/p&gt;

&lt;p&gt;Common immutable types include:&lt;/p&gt;

&lt;p&gt;int&lt;br&gt;
float&lt;br&gt;
str&lt;br&gt;
tuple&lt;br&gt;
bool&lt;/p&gt;

&lt;p&gt;For example, a list can be modified:&lt;/p&gt;

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

&lt;p&gt;numbers.append(40)&lt;/p&gt;

&lt;p&gt;print(numbers)&lt;/p&gt;

&lt;p&gt;The same list now contains the additional value.&lt;/p&gt;

&lt;p&gt;Strings behave differently:&lt;/p&gt;

&lt;p&gt;name = "Python"&lt;/p&gt;

&lt;h1&gt;
  
  
  name[0] = "J"
&lt;/h1&gt;

&lt;p&gt;The code above raises an error because strings are immutable.&lt;/p&gt;

&lt;p&gt;This distinction becomes particularly important when you start learning about object references, copying, functions, and shallow vs deep copy.&lt;/p&gt;

&lt;p&gt;A Practical Example&lt;/p&gt;

&lt;p&gt;Imagine you're working on a small employee application.&lt;/p&gt;

&lt;p&gt;You might have:&lt;/p&gt;

&lt;p&gt;employee_id = 101&lt;br&gt;
employee_name = "Amit"&lt;br&gt;
salary = 55000.50&lt;br&gt;
is_active = True&lt;/p&gt;

&lt;p&gt;skills = ["Python", "SQL", "Power BI"]&lt;/p&gt;

&lt;p&gt;employee = {&lt;br&gt;
    "id": employee_id,&lt;br&gt;
    "name": employee_name,&lt;br&gt;
    "salary": salary,&lt;br&gt;
    "active": is_active,&lt;br&gt;
    "skills": skills&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Here, several Python data types are working together:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"101" → "int"&lt;/li&gt;
&lt;li&gt;""Amit"" → "str"&lt;/li&gt;
&lt;li&gt;"55000.50" → "float"&lt;/li&gt;
&lt;li&gt;"True" → "bool"&lt;/li&gt;
&lt;li&gt;"skills" → "list"&lt;/li&gt;
&lt;li&gt;"employee" → "dict"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is much closer to how you'll actually encounter data types in a real Python application.&lt;/p&gt;

&lt;p&gt;Why Data Types Matter Beyond Python Basics&lt;/p&gt;

&lt;p&gt;Data types become even more important when you move into data analytics and data engineering.&lt;/p&gt;

&lt;p&gt;For example, an API might return:&lt;/p&gt;

&lt;p&gt;age = "45"&lt;/p&gt;

&lt;p&gt;while your calculation expects:&lt;/p&gt;

&lt;p&gt;age = 45&lt;/p&gt;

&lt;p&gt;Or a column in a dataset might contain a mixture of numbers and strings.&lt;/p&gt;

&lt;p&gt;Before performing calculations or transformations, you need to understand what you're actually working with.&lt;/p&gt;

&lt;p&gt;That's why Python data types are not just an interview topic. They are part of everyday Python programming.&lt;/p&gt;

&lt;p&gt;Final Thoughts&lt;/p&gt;

&lt;p&gt;The most important Python data types to understand first are:&lt;/p&gt;

&lt;p&gt;int&lt;br&gt;
float&lt;br&gt;
str&lt;br&gt;
bool&lt;br&gt;
list&lt;br&gt;
tuple&lt;br&gt;
set&lt;br&gt;
dict&lt;br&gt;
None&lt;/p&gt;

&lt;p&gt;Don't try to memorize them only for an interview.&lt;/p&gt;

&lt;p&gt;Try small examples and pay attention to what can be changed, how values are accessed, and what happens when you convert one type to another.&lt;/p&gt;

&lt;p&gt;Once these basics are clear, topics like functions, APIs, Pandas, data cleaning, and data analysis become much easier to understand.&lt;/p&gt;

&lt;p&gt;Preparing for a Python Interview?&lt;/p&gt;

&lt;p&gt;If you want to go beyond these basic examples, I've put together a detailed Python Data Types Interview Questions and Answers guide on SankalanTech.&lt;/p&gt;

&lt;p&gt;It covers questions around:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Built-in data types&lt;/li&gt;
&lt;li&gt;Lists vs tuples&lt;/li&gt;
&lt;li&gt;Dictionaries&lt;/li&gt;
&lt;li&gt;Sets&lt;/li&gt;
&lt;li&gt;"int" vs "float"&lt;/li&gt;
&lt;li&gt;Strings&lt;/li&gt;
&lt;li&gt;"None"&lt;/li&gt;
&lt;li&gt;Type conversion&lt;/li&gt;
&lt;li&gt;Shallow vs deep copy&lt;/li&gt;
&lt;li&gt;Dynamic typing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Read the complete Python Data Types interview guide on SankalanTech:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.sankalandtech.com/Tutorials/Python/interview-questions/python-data-types-guide.html" rel="noopener noreferrer"&gt;https://www.sankalandtech.com/Tutorials/Python/interview-questions/python-data-types-guide.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use this article to understand the concepts with examples, and the detailed guide for deeper interview preparation.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Python Variables: Why y = x Sometimes Changes Both Variables</title>
      <dc:creator>Kailas Warade</dc:creator>
      <pubDate>Fri, 18 Sep 2026 06:17:31 +0000</pubDate>
      <link>https://dev.to/kailas_warade_d2a15d1ef8a/python-variables-why-y-x-sometimes-changes-both-variables-58kk</link>
      <guid>https://dev.to/kailas_warade_d2a15d1ef8a/python-variables-why-y-x-sometimes-changes-both-variables-58kk</guid>
      <description>&lt;p&gt;Python: Why Changing "y" Can Sometimes Change "x" Too&lt;/p&gt;

&lt;p&gt;You write:&lt;/p&gt;

&lt;p&gt;x = 10&lt;br&gt;
y = x&lt;/p&gt;

&lt;p&gt;Then you change "y".&lt;/p&gt;

&lt;p&gt;Sometimes "x" stays the same.&lt;/p&gt;

&lt;p&gt;Sometimes "x" changes too.&lt;/p&gt;

&lt;p&gt;That sounds strange until you understand what "=" actually does in Python.&lt;/p&gt;

&lt;p&gt;First, look at this example&lt;/p&gt;

&lt;p&gt;x = 10&lt;br&gt;
y = x&lt;/p&gt;

&lt;p&gt;x = 20&lt;/p&gt;

&lt;p&gt;print(x)&lt;br&gt;
print(y)&lt;/p&gt;

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

&lt;p&gt;20&lt;br&gt;
10&lt;/p&gt;

&lt;p&gt;Changing "x" did not change "y".&lt;/p&gt;

&lt;p&gt;Now look at this:&lt;/p&gt;

&lt;p&gt;x = [10, 20, 30]&lt;br&gt;
y = x&lt;/p&gt;

&lt;p&gt;y.append(40)&lt;/p&gt;

&lt;p&gt;print(x)&lt;br&gt;
print(y)&lt;/p&gt;

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

&lt;p&gt;[10, 20, 30, 40]&lt;br&gt;
[10, 20, 30, 40]&lt;/p&gt;

&lt;p&gt;This time, changing "y" also changed what we see through "x".&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;The answer is mutation and reassignment.&lt;/p&gt;

&lt;p&gt;"y = x" does not create a copy&lt;/p&gt;

&lt;p&gt;When you write:&lt;/p&gt;

&lt;p&gt;x = [10, 20, 30]&lt;br&gt;
y = x&lt;/p&gt;

&lt;p&gt;Python does not create another list containing the same values.&lt;/p&gt;

&lt;p&gt;Both names refer to the same list object.&lt;/p&gt;

&lt;p&gt;So when you do:&lt;/p&gt;

&lt;p&gt;y.append(40)&lt;/p&gt;

&lt;p&gt;you are changing that list.&lt;/p&gt;

&lt;p&gt;Since "x" also refers to that same list, "x" now shows:&lt;/p&gt;

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

&lt;p&gt;A simple way to remember it:&lt;/p&gt;

&lt;p&gt;Reassignment → changes what a name refers to.&lt;/p&gt;

&lt;p&gt;Mutation → changes the object itself.&lt;/p&gt;

&lt;p&gt;Reassignment vs mutation&lt;/p&gt;

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

&lt;p&gt;x = 10&lt;br&gt;
y = x&lt;/p&gt;

&lt;p&gt;x = 20&lt;/p&gt;

&lt;p&gt;Here, "x" is reassigned.&lt;/p&gt;

&lt;p&gt;It now refers to "20".&lt;/p&gt;

&lt;p&gt;"y" still refers to "10".&lt;/p&gt;

&lt;p&gt;But with a list:&lt;/p&gt;

&lt;p&gt;x = [10, 20]&lt;br&gt;
y = x&lt;/p&gt;

&lt;p&gt;y.append(30)&lt;/p&gt;

&lt;p&gt;"y.append(30)" changes the existing list.&lt;/p&gt;

&lt;p&gt;So both "x" and "y" show:&lt;/p&gt;

&lt;p&gt;[10, 20, 30]&lt;/p&gt;

&lt;p&gt;This difference is one of those small Python concepts that becomes very important when working with real programs.&lt;/p&gt;

&lt;p&gt;Mutable and immutable objects&lt;/p&gt;

&lt;p&gt;This is where another Python concept becomes useful.&lt;/p&gt;

&lt;p&gt;Some objects can be changed after they are created.&lt;/p&gt;

&lt;p&gt;These are called mutable objects.&lt;/p&gt;

&lt;p&gt;Common examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"list"&lt;/li&gt;
&lt;li&gt;"dict"&lt;/li&gt;
&lt;li&gt;"set"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some objects cannot be changed in place.&lt;/p&gt;

&lt;p&gt;These are called immutable objects.&lt;/p&gt;

&lt;p&gt;Common examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"int"&lt;/li&gt;
&lt;li&gt;"float"&lt;/li&gt;
&lt;li&gt;"str"&lt;/li&gt;
&lt;li&gt;"tuple"&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;numbers = [10, 20, 30]&lt;br&gt;
numbers.append(40)&lt;/p&gt;

&lt;p&gt;The existing list is modified.&lt;/p&gt;

&lt;p&gt;But:&lt;/p&gt;

&lt;p&gt;x = 10&lt;br&gt;
x = 20&lt;/p&gt;

&lt;p&gt;does not modify the integer "10".&lt;/p&gt;

&lt;p&gt;The name "x" is simply reassigned.&lt;/p&gt;

&lt;p&gt;Here is another example that can confuse you&lt;/p&gt;

&lt;p&gt;Predict the output before running this:&lt;/p&gt;

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

&lt;p&gt;other_numbers = numbers&lt;/p&gt;

&lt;p&gt;numbers = [100, 200, 300]&lt;/p&gt;

&lt;p&gt;other_numbers.append(40)&lt;/p&gt;

&lt;p&gt;print(numbers)&lt;br&gt;
print(other_numbers)&lt;/p&gt;

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

&lt;p&gt;[100, 200, 300]&lt;br&gt;
[10, 20, 30, 40]&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Initially:&lt;/p&gt;

&lt;p&gt;numbers = [10, 20, 30]&lt;br&gt;
other_numbers = numbers&lt;/p&gt;

&lt;p&gt;Both names refer to the first list.&lt;/p&gt;

&lt;p&gt;Then:&lt;/p&gt;

&lt;p&gt;numbers = [100, 200, 300]&lt;/p&gt;

&lt;p&gt;This does not change the old list.&lt;/p&gt;

&lt;p&gt;It makes "numbers" refer to a new list.&lt;/p&gt;

&lt;p&gt;"other_numbers" is still referring to the original list.&lt;/p&gt;

&lt;p&gt;So:&lt;/p&gt;

&lt;p&gt;other_numbers.append(40)&lt;/p&gt;

&lt;p&gt;changes only the original list.&lt;/p&gt;

&lt;p&gt;One more Python variable trap: "input()"&lt;/p&gt;

&lt;p&gt;There is another small thing that often causes confusion.&lt;/p&gt;

&lt;p&gt;Look at this:&lt;/p&gt;

&lt;p&gt;age = input("Enter your age: ")&lt;/p&gt;

&lt;p&gt;print(type(age))&lt;/p&gt;

&lt;p&gt;If you enter:&lt;/p&gt;

&lt;p&gt;25&lt;/p&gt;

&lt;p&gt;the result is:&lt;/p&gt;



&lt;p&gt;Even though you entered a number.&lt;/p&gt;

&lt;p&gt;"input()" returns a string.&lt;/p&gt;

&lt;p&gt;If you actually need an integer:&lt;/p&gt;

&lt;p&gt;age = int(input("Enter your age: "))&lt;/p&gt;

&lt;p&gt;Now:&lt;/p&gt;

&lt;p&gt;print(type(age))&lt;/p&gt;

&lt;p&gt;gives:&lt;/p&gt;



&lt;p&gt;This matters when you start doing calculations.&lt;/p&gt;

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

&lt;p&gt;age = input("Enter your age: ")&lt;/p&gt;

&lt;p&gt;print(age + 5)&lt;/p&gt;

&lt;p&gt;This will not work as expected because "age" is a string.&lt;/p&gt;

&lt;p&gt;Instead:&lt;/p&gt;

&lt;p&gt;age = int(input("Enter your age: "))&lt;/p&gt;

&lt;p&gt;print(age + 5)&lt;/p&gt;

&lt;p&gt;Don't confuse "=" with "=="&lt;/p&gt;

&lt;p&gt;Another basic mistake is confusing these two operators.&lt;/p&gt;

&lt;p&gt;"=" means assignment:&lt;/p&gt;

&lt;p&gt;age = 25&lt;/p&gt;

&lt;p&gt;"==" means comparison:&lt;/p&gt;

&lt;p&gt;age == 25&lt;/p&gt;

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

&lt;p&gt;age = 25&lt;/p&gt;

&lt;p&gt;if age == 25:&lt;br&gt;
    print("Age is 25")&lt;/p&gt;

&lt;p&gt;A simple rule:&lt;/p&gt;

&lt;p&gt;"=" → assign&lt;/p&gt;

&lt;p&gt;"==" → compare&lt;/p&gt;

&lt;p&gt;Python is dynamically typed&lt;/p&gt;

&lt;p&gt;Python variables do not need a type declaration like some other programming languages.&lt;/p&gt;

&lt;p&gt;You can write:&lt;/p&gt;

&lt;p&gt;age = 25&lt;/p&gt;

&lt;p&gt;and later:&lt;/p&gt;

&lt;p&gt;age = "25"&lt;/p&gt;

&lt;p&gt;The same name can refer to objects of different types at different times.&lt;/p&gt;

&lt;p&gt;You can check the current type with:&lt;/p&gt;

&lt;p&gt;print(type(age))&lt;/p&gt;

&lt;p&gt;This is called dynamic typing.&lt;/p&gt;

&lt;p&gt;Choose variable names that explain the value&lt;/p&gt;

&lt;p&gt;Technically, this works:&lt;/p&gt;

&lt;p&gt;a = 45000&lt;br&gt;
b = 12&lt;br&gt;
c = a / b&lt;/p&gt;

&lt;p&gt;But this is easier to understand:&lt;/p&gt;

&lt;p&gt;annual_salary = 45000&lt;br&gt;
months = 12&lt;br&gt;
monthly_salary = annual_salary / months&lt;/p&gt;

&lt;p&gt;Good variable names make code easier to read, debug, and maintain.&lt;/p&gt;

&lt;p&gt;Especially when you come back to your code after a few weeks.&lt;/p&gt;

&lt;p&gt;Try these before you run them&lt;/p&gt;

&lt;p&gt;Don't run these immediately.&lt;/p&gt;

&lt;p&gt;Predict the output first.&lt;/p&gt;

&lt;p&gt;Question 1&lt;/p&gt;

&lt;p&gt;x = [1, 2, 3]&lt;br&gt;
y = x&lt;/p&gt;

&lt;p&gt;y.append(4)&lt;/p&gt;

&lt;p&gt;print(x)&lt;/p&gt;

&lt;p&gt;What will it print?&lt;/p&gt;

&lt;p&gt;Question 2&lt;/p&gt;

&lt;p&gt;x = 10&lt;br&gt;
y = x&lt;/p&gt;

&lt;p&gt;y = 20&lt;/p&gt;

&lt;p&gt;print(x)&lt;br&gt;
print(y)&lt;/p&gt;

&lt;p&gt;What will it print?&lt;/p&gt;

&lt;p&gt;Question 3&lt;/p&gt;

&lt;p&gt;x = [1, 2, 3]&lt;br&gt;
y = x&lt;/p&gt;

&lt;p&gt;x = [10, 20, 30]&lt;/p&gt;

&lt;p&gt;y.append(4)&lt;/p&gt;

&lt;p&gt;print(x)&lt;br&gt;
print(y)&lt;/p&gt;

&lt;p&gt;Can you predict both outputs?&lt;/p&gt;

&lt;p&gt;If you can explain why the answers are different, you understand the important part.&lt;/p&gt;

&lt;p&gt;Want the Python Variable Basics in One Place?&lt;/p&gt;

&lt;p&gt;If you're preparing for Python interviews or want a reference for Python syntax, variable naming rules, data types, dynamic typing, multiple assignment, scope, "input()", and related questions, I've collected those topics here:&lt;/p&gt;

&lt;p&gt;Python Syntax and Variables Interview Q&amp;amp;A&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.sankalandtech.com/Tutorials/Python/interview-questions/python-syntax-variables-tutorial.html" rel="noopener noreferrer"&gt;https://www.sankalandtech.com/Tutorials/Python/interview-questions/python-syntax-variables-tutorial.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use it as a reference when you want to revise the broader Python syntax and variable concepts.&lt;/p&gt;

&lt;p&gt;Final challenge&lt;/p&gt;

&lt;p&gt;What will this program print?&lt;/p&gt;

&lt;p&gt;items = ["SQL", "Python"]&lt;/p&gt;

&lt;p&gt;copy_of_items = items&lt;/p&gt;

&lt;p&gt;items = ["Python", "GCP"]&lt;/p&gt;

&lt;p&gt;copy_of_items.append("BigQuery")&lt;/p&gt;

&lt;p&gt;print(items)&lt;br&gt;
print(copy_of_items)&lt;/p&gt;

&lt;p&gt;Will ""BigQuery"" appear in both lists?&lt;/p&gt;

&lt;p&gt;Don't run it immediately.&lt;/p&gt;

&lt;p&gt;Think about these three things first:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What object does "items" refer to initially?&lt;/li&gt;
&lt;li&gt;What happens when "items" is reassigned?&lt;/li&gt;
&lt;li&gt;Which object does "copy_of_items" still refer to?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's the part of Python variables that is easy to miss when you're just learning the syntax.&lt;/p&gt;

</description>
      <category>pythonvariable</category>
      <category>python</category>
    </item>
  </channel>
</rss>
