<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Janaa Visvesvaran on Medium]]></title>
        <description><![CDATA[Stories by Janaa Visvesvaran on Medium]]></description>
        <link>https://medium.com/@JanaaVisvesvaran?source=rss-4111e0787db1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DrqjYl3BegreO_AbRQuvIQ.jpeg</url>
            <title>Stories by Janaa Visvesvaran on Medium</title>
            <link>https://medium.com/@JanaaVisvesvaran?source=rss-4111e0787db1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 07:05:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@JanaaVisvesvaran/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Functions and Modules: Building Blocks of Reusable Code]]></title>
            <link>https://medium.com/@JanaaVisvesvaran/functions-and-modules-building-blocks-of-reusable-code-e88fcd7c91ca?source=rss-4111e0787db1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e88fcd7c91ca</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[modules]]></category>
            <category><![CDATA[function]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Janaa Visvesvaran]]></dc:creator>
            <pubDate>Wed, 19 Feb 2025 05:01:43 GMT</pubDate>
            <atom:updated>2025-02-19T05:01:43.418Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article elaborates about the code reusability and organization through two fundamental concepts: <strong>functions</strong> and <strong>modules</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H_drdhP6i270DPc8pNK_jQ.jpeg" /><figcaption>Python Functions and Modules</figcaption></figure><h3>Introduction to Python Functions and Modules</h3><p>Python is very versatile language widely acclaimed for its readability and ease of use. Among the core features that contribute to its flexibility are <strong>functions </strong>and <strong>modules</strong>, which are fundamental to building organized, efficient, and reusable code. Functions allow you to encapsulate reusable pieces of code, while modules enable you to organize and reuse code across different programs. In this article, we will explore the concepts of functions and modules in Python, their syntax, and best practices for using them effectively</p><h3>Functions in Python</h3><p>A function in Python is a <strong>block of</strong> organized, reusable <strong>code </strong>that performs a specific task. Functions help break down complex problems into smaller, manageable chunks, making your code easier to read, understand, and debug. They can take <strong>arguments </strong>as <em>input</em>, <em>process </em>them, and <em>return </em>a value as <strong>output</strong>. Functions promote code reusability and make programs easier to understand. A Python Functionn returns <strong>None</strong> by <em>Default</em>.</p><blockquote>Understanding scoping rules is vital when working with functions; variables declared within a function are local to that function. Scoping plays a viral role while working with different blocks of code</blockquote><h4>Why use functions?</h4><ul><li><strong>Reusability:</strong> Write a piece of code once and use it multiple times throughout your program, avoiding repetition</li><li><strong>Modularity:</strong> Divide your code into logical units, improving organization and making it easier to maintain</li><li><strong>Abstraction:</strong> Hide complex implementation details and expose a simple interface, simplifying the use of the code</li><li><strong>Readability:</strong> Make your code more readable by giving meaningful names to blocks of code</li></ul><h4>Defining a Function</h4><p>In Python, you can define a function using the def keyword, followed by the function name and a pair of parentheses (). The code block within the function is indented.</p><p>Syntax</p><pre>def function_name():<br>    # Function&#39;s logic is placed here<br>    pass</pre><p>Example</p><pre>def greet():<br>    print(&quot;Hello, welcome to Python programming!&quot;)</pre><h4>Functions with Parameters and Return Values</h4><p>Functions can accept input values called <em>arguments</em>. The function receives these arguments as <em>parameters.</em> It is provided inside the paranthesis</p><p>Example</p><pre>def add_numbers(a, b):<br>    return a + b</pre><p>Here def represents function definition, add_numbers is the function’s name. Here <em>a</em> and <em>b</em> are the <strong>parameters</strong>.</p><p>Functions can return values using the return . The return statement exits the function and returns the specified value to the caller. This allows you to use the result of a function in other parts of your program</p><p>Example</p><pre>def add_numbers(a, b):<br>    return a + b<br><br># Calling the function<br>result = add_numbers(5, 10)<br>print(result)</pre><p>Output would be <strong>15</strong></p><h4>Default Arguments</h4><p>Python allows you to specify default values for function parameters. If an argument is not provided when the function is called, the default value is used</p><p>Example</p><pre>def greet(name=&quot;Guest&quot;):<br>    print(f&quot;Welcome, {name}!&quot;)<br><br>greet()         # Output: Welcome, Guest!<br>greet(&quot;Python Lover&quot;)  # Output: Welcome, Python Lover!</pre><p>In this example, if no argument is passed to greet, it defaults to &quot;Guest&quot;.</p><h4>Types of Functions</h4><p>Python has three types of functions:</p><ol><li><strong>Built-in Functions</strong> — Functions that are pre-defined in Python, such as print(), len(), sum(), and range()</li><li><strong>User-Defined Function </strong>— Functions created by the user to perform specific tasks</li><li><strong>Lambda Functions</strong> (Anonymous Functions) — Small, single-expression functions defined using the lambda keyword. Example: square = lambda x: x ** 2</li><li><strong>Recursive Functions </strong>— Functions that call themselves to solve a problem by breaking it into smaller subproblems</li><li><strong>Nested Functions</strong> — Functions defined inside another function. They are used to encapsulate logic that is only relevant within the outer function</li></ol><p>Example:</p><pre># Built-in Functions<br>print(len(&quot;Hello&quot;))  # Output: 5<br><br># User Defined Functions<br>def greet(name):<br>    return f&quot;Hello, {name}!&quot;<br><br>print(greet(&quot;Guest&quot;)) # Output: Hello, Guest<br><br>#  Lambda Functions <br>square = lambda x: x ** 2<br>print(square(5))  # Output: 25<br><br># Recursive Functions<br>def factorial(n):<br>    if n == 1:<br>        return 1<br>    else:<br>        return n * factorial(n - 1)<br><br>print(factorial(5))  # Output: 120<br><br># Nested Functions<br>def outer_function():<br>    def inner_function():<br>        return &quot;Hello from inside!&quot;<br>    return inner_function()<br><br>print(outer_function())  # Output: Hello from inside!</pre><h4>Docstrings</h4><p>The string enclosed in triple quotes (&quot;&quot;&quot;Docstring&quot;&quot;&quot;) within a function is called a docstring. It&#39;s used to document the function&#39;s purpose, arguments, and return values. Good docstrings are essential for readable and maintainable code</p><p>Example</p><pre>def add(x, y):  # x and y are parameters<br>  &quot;&quot;&quot;This function adds two numbers and returns the sum&quot;&quot;&quot;<br>  return x + y<br><br>result = add(5, 3)  # 5 and 3 are arguments<br>print(result)       # Output: 8</pre><h4>Variable-Length Arguments</h4><p>Sometimes, you may want to define a function that can accept a variable number of arguments. Python provides two ways to do this: *args for non-keyword arguments and **kwargs for keyword arguments</p><p>Example</p><pre>def print_args(*args):<br>    for arg in args:<br>        print(arg)<br><br>print_args(1, 2, 3)  # Output: 1 2 3<br><br>def print_kwargs(**kwargs):<br>    for key, value in kwargs.items():<br>        print(f&quot;{key}: {value}&quot;)<br><br>print_kwargs(name=&quot;Guest&quot;, age=30)  # Output: name: Guest age: 30</pre><h3>Modules in Python</h3><h4>What is a Module?</h4><p>A module in Python is a file containing Python code, such as functions, classes, and variables. Modules allow you to organize your code into separate files, making it easier to manage and reuse. Python comes with a large standard library of modules, and you can also create your own custom modules</p><h4>Types of Modules</h4><ol><li><strong>Built-in Modules</strong> — Pre-installed Python modules like math, random, datetime, etc.</li><li><strong>User-Defined Modules</strong> — Custom modules created by programmers to organize code</li><li><strong>Third-Party Modules</strong> — External modules installed using pip, such as numpy, pandas, and requests</li></ol><h4>Importing Modules</h4><p>To use a module in your program, you need to import it using the import statement</p><p>Example</p><pre>import math<br><br>result = math.sqrt(16)<br>print(result)  # Output: 4.0</pre><p>In the example provided above, the math module is imported, and the sqrt function from the math module is used to calculate the square root of 16</p><h4>Importing Specific Functions</h4><p>You can also import specific functions or variables from a module using the from ... import statement</p><p>Example</p><pre>from math import sqrt<br><br>result = sqrt(16)<br>print(result)  # Output: 4.0</pre><h4>Creating Your Own Modules !</h4><p>You can create your own modules by writing Python code in a .py file and then importing it into another script</p><p>For example, let’s create a module named mymodule.py:</p><pre># mymodule.py<br>def greet(name):<br>    print(f&quot;Hello, {name}!&quot;)<br><br>def add(a, b):<br>    return a + b</pre><p>Now, you can import and use this module in another script:</p><pre>import mymodule<br><br>mymodule.greet(&quot;Guest&quot;)  # Output: Hello, Guest!<br>result = mymodule.add(3, 5)<br>print(result)            # Output: 8</pre><blockquote>Make sure the files reside in same folder to import it directly and use</blockquote><h4>Using as to Rename a Module</h4><p>You can use an alias for a module to make it easier to use.</p><pre>import math as m<br><br>print(m.sqrt(36))  # Output: 6.0<br>print(m.pi)        # Output: 3.141592653589793</pre><h4>The __name__ Variable</h4><p>When you run a Python script, the __name__ variable is set to &quot;__main__&quot;. However, when a module is imported, __name__ is set to the module&#39;s name. This allows you to include code that should only run when the script is executed directly, not when it is imported as a module</p><p>Example</p><pre># mymodule.py<br>def greet(name):<br>    print(f&quot;Hello, {name}!&quot;)<br><br>if __name__ == &quot;__main__&quot;:<br>    greet(&quot;Guest&quot;)</pre><p>In this example, the greet function will only be called if mymodule.py is run directly, not when it is imported</p><h4>Installing Third-Party Modules</h4><p>In addition to the standard library, you can install third-party modules using the pip package manager. For example, to install the popular requests module, you can run:</p><pre>pip install requests</pre><h3>Best Practices for Functions and Modules</h3><ul><li><strong>Use descriptive names</strong>: Choose meaningful names for functions and modules that clearly indicate their purpose</li><li><strong>Keep functions small</strong>: Functions should be focused and perform a single, well-defined task. If a function becomes too large, consider breaking it down into smaller functions</li><li><strong>Document your code</strong>: Use docstrings to document functions and modules, explaining their purpose, arguments, and return values</li><li><strong>Organize Your Modules</strong>: Group related functions and classes into modules. This helps in organizing your code and makes it easier to find and reuse</li><li><strong>Avoid Global Variables:</strong> Minimize the use of global variables in your functions. Instead, pass data as arguments and return results. This makes your functions more predictable and easier to test</li><li><strong>Write Modular Code</strong>: Break down your code into small, reusable functions and modules. This makes your code easier to read, test, and maintain</li><li><strong>Test your code:</strong> Write unit tests to ensure that functions and modules work correctly</li><li><strong>Use Virtual Environments</strong>: When working on multiple projects, use virtual environments to manage dependencies. This prevents conflicts between different versions of modules</li></ul><h3>Conclusion</h3><p>Functions and modules are fundamental concepts in Python that enable you to write organized, reusable, and maintainable code. By breaking down your code into functions and organizing them into modules, you can create more efficient and scalable programs. Whether you’re working on a small script or a large application, mastering functions and modules will significantly enhance your Python programming skills</p><h3>Question</h3><p>Consider the following Python code:</p><pre># my_module.py<br>x = 10<br><br>def update_x():<br>    global x<br>    x += 5<br>    return x</pre><p>Now, suppose we import this module in another script and call the update_x() function:</p><pre>import my_module<br><br>print(my_module.x)        # Output 1<br>print(my_module.update_x())  # Output 2<br>print(my_module.x)        # Output 3</pre><p>What will be the output of Output 1, Output 2, and Output 3? Comment your answers</p><p>Give this blog a few claps 👏 to show your love! And hit that follow button 👉</p><p>Happy Learning! 😊</p><p>Feel free to <strong>connect </strong>with me 🙂: <a href="https://www.linkedin.com/in/janaa-v/"><strong>Linkedin</strong></a><strong> </strong>| <a href="https://medium.com/@JanaaVisvesvaran"><strong>Medium</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e88fcd7c91ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Loops: The Key to Efficient Coding]]></title>
            <link>https://medium.com/@JanaaVisvesvaran/python-loops-the-key-to-efficient-coding-5b1383d3bf17?source=rss-4111e0787db1------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b1383d3bf17</guid>
            <category><![CDATA[loop]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[iteration]]></category>
            <dc:creator><![CDATA[Janaa Visvesvaran]]></dc:creator>
            <pubDate>Wed, 01 Jan 2025 05:02:12 GMT</pubDate>
            <atom:updated>2025-01-01T05:02:12.993Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article helps you understand and enhance the complete understanding of Loops (Iterative Statements)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3eH--RipeY3v5HQOmMw-fQ.jpeg" /></figure><h3>Introduction</h3><p>Loops are a fundamental concept in programming, allowing developers to execute a block of code multiple times without the need for repetitive coding. In Python, loops are essential for automating <strong><em>repetitive tasks</em></strong>, managing collections of data, and controlling the flow of execution based on conditions. This article explores the different types of loops in Python, their syntax, practical applications, and control statements that enhance their functionality</p><h3>Types of Loops</h3><p>There are 2 types of Loops:</p><ol><li><strong>For</strong> Loop — Used for iterating over a sequence (like lists, strings, or ranges)</li><li><strong>While</strong> Loop — Repeats a block of code as long as a specified condition is true</li></ol><h3>FOR Loop</h3><p>The for loop is used to iterate over a sequence (such as lists, tuples, strings, or ranges). It allows you to execute a block of code for each item in the sequence until all items have been processed</p><h4>Syntax of FOR loop</h4><pre>for item in sequence:<br>    # Code block to be executed for each item</pre><h4>Example 1: Iterating Through a List</h4><p>In this example, a list is used to iterate values</p><pre>fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;]<br>for fruit in fruits:<br>    print(fruit)</pre><h4>Output 1</h4><pre>apple<br>banana<br>cherry</pre><h4>Example 2: Iterating Over a String</h4><p>In this example, a string is used to iterate values</p><pre>for letter in &quot;Python&quot;:<br>    print(letter)</pre><h4>Output 2</h4><pre>P<br>y<br>t<br>h<br>o<br>n</pre><h4>Example 3: Iterating through range()</h4><p>The <strong>range()</strong> function can also be used with for loops to iterate over a sequence of numbers. It generates a sequence starting from 0 up to (<em>but not including</em>) a specified number</p><pre>for i in range(5):<br>    print(f&quot;Count: {i}&quot;)</pre><h4>Output 3</h4><pre>Count: 0<br>Count: 1<br>Count: 2<br>Count: 3<br>Count: 4</pre><h4>Example 4: Iterating through enumerate()</h4><p>The enumerate() function keeps track of both the index and the element while iterating</p><pre>colors = [&quot;red&quot;, &quot;green&quot;, &quot;blue&quot;]<br>for index, color in enumerate(colors):<br>    print(f&quot;{index}: {color}&quot;)</pre><h4>Output 4</h4><pre>0: red<br>1: green<br>2: blue</pre><h3>WHILE Loop</h3><p>The while loop executes a block of code as long as a specified condition is true. This type of loop is useful when the number of iterations is not known beforehand and depends on dynamic conditions</p><h4>Syntax of WHILE loop</h4><pre>while condition:<br>    # Code block to be executed while condition is true</pre><h4>Example</h4><pre>countdown = 5<br>while countdown &gt; 0:<br>    print(f&quot;T-minus {countdown}&quot;)<br>    countdown -= 1</pre><h4>Output</h4><pre>T-minus 5<br>T-minus 4<br>T-minus 3<br>T-minus 2<br>T-minus 1</pre><h3>Loop Control Statements</h3><p>Control statements in Python enhance the functionality of loops by allowing developers to alter their behavior. Python provides special keywords to manage how loops execute:</p><ol><li><strong>break</strong>: Terminates the loop entirely</li><li><strong>continue</strong>: Skips the current iteration and moves to the next</li><li><strong>else</strong>: Executes only if the loop wasn’t terminated with a break</li><li><strong>pass : </strong>Acts as a placeholder within loops where no action is required</li></ol><h4>Break Statement</h4><p>The <strong>break </strong>statement terminates the loop prematurely when a specific condition is met</p><h4>Example: Using BREAK</h4><pre>numbers = [1, 2, 3, 4, 5, 6]<br>for number in numbers:<br>    if number == 4:<br>        print(&quot;Number 4 found, stopping loop.&quot;)<br>        break<br>    print(f&quot;Processing {number}&quot;)</pre><h4>Output</h4><pre>Processing 1<br>Processing 2<br>Processing 3<br>Number 4 found, stopping loop.</pre><h4>Example: Using CONTINUE</h4><p>The continue statement skips the current iteration and proceeds with the next iteration of the loop</p><pre>for num in range(10):<br>    if num % 2 == 0:<br>        continue  # Skip even numbers<br>    print(f&quot;Odd number: {num}&quot;)</pre><h4>Output</h4><pre>Odd number: 1<br>Odd number: 3<br>Odd number: 5<br>Odd number: 7<br>Odd number: 9</pre><h4>Example: Using ELSE with Loops</h4><p>The else statement executes only if the loop wasn’t terminated with a statement</p><pre>for n in range(1, 6):<br>    if n == 3:<br>        break<br>    print(n)<br>else:<br>    print(&quot;Loop completed successfully.&quot;)</pre><h4>Output</h4><pre>1<br>2</pre><h4>Example: Using PASS</h4><p>The pass statement acts as a placeholder within loops (or any code block) where no action is required. It allows you to write syntactically correct code without implementing any functionality at that point</p><pre>for i in range(3):<br>    pass  # Do nothing for now; placeholder for future code.</pre><h4>Output</h4><p>There are no operations being performed, so the output is not generated</p><h3>Nested Loops</h3><p>Nested loops occur when one loop (inner loop) is placed inside another loop (outer loop). The inner loop completes all its iterations for each iteration of the outer loop. They are useful for tasks like iterating over 2D structures (matrices), generating combinations, and solving grid-based problems, but deep nesting can impact performance. You can understand it better with an example</p><h4>Example</h4><pre>suits = [&quot;Hearts&quot;, &quot;Diamonds&quot;, &quot;Clubs&quot;, &quot;Spades&quot;]<br>ranks = [&quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;8&quot;, &quot;9&quot;, &quot;10&quot;, &quot;J&quot;, &quot;Q&quot;, &quot;K&quot;, &quot;A&quot;]<br><br>for suit in suits:<br>    for rank in ranks:<br>        print(f&quot;{rank} of {suit}&quot;)</pre><h4>Output</h4><pre>2 of Hearts<br>3 of Hearts  <br>4 of Hearts  <br>5 of Hearts  <br>6 of Hearts  <br>7 of Hearts  <br>8 of Hearts  <br>9 of Hearts  <br>10 of Hearts <br>J of Hearts  <br>Q of Hearts  <br>K of Hearts  <br>A of Hearts  <br>2 of Diamonds<br>3 of Diamonds<br>4 of Diamonds<br>5 of Diamonds<br>6 of Diamonds<br>7 of Diamonds<br>8 of Diamonds<br>9 of Diamonds<br>10 of Diamonds<br>J of Diamonds<br>Q of Diamonds<br>K of Diamonds<br>A of Diamonds<br>2 of Clubs<br>3 of Clubs<br>4 of Clubs<br>5 of Clubs<br>6 of Clubs<br>7 of Clubs<br>8 of Clubs<br>9 of Clubs<br>10 of Clubs<br>J of Clubs<br>Q of Clubs<br>K of Clubs<br>A of Clubs<br>2 of Spades<br>3 of Spades<br>4 of Spades<br>5 of Spades<br>6 of Spades<br>7 of Spades<br>8 of Spades<br>9 of Spades<br>10 of Spades<br>J of Spades<br>Q of Spades<br>K of Spades<br>A of Spades</pre><h3>Best Practices for Using Loops</h3><h4>Keep Loops Short and Simple</h4><p>A loop that spans too many lines or performs too many tasks can become confusing and error-prone. Simplicity and clarity make your loops easier to read, debug, and maintain</p><blockquote>Limit the number of tasks your loop performs. If a loop is doing too much, consider breaking it into smaller functions</blockquote><h4>Example of Bad Practice</h4><pre>for item in items:<br>    # Multiple tasks in one loop<br>    item.process()<br>    print(item)<br>    if item.value &gt; 10:<br>        process_item(item)<br>    log_to_file(item)</pre><h4>Example of Good Practice</h4><pre>for item in items:<br>    process_item(item)<br><br>def process_item(item):<br>    item.process()<br>    print(item)<br>    if item.value &gt; 10:<br>        update_item(item)<br>    log_to_file(item)</pre><h4>Optimize Loop Efficiency</h4><p>Loops can become bottlenecks in your code if they perform unnecessary computations. Optimizing them ensures your program runs faster and consumes fewer resources</p><blockquote>Avoid redundant calculations inside the loop. Precompute values outside the loop when possible. Use built-in Python functions and libraries like enumerate, zip, or itertools to optimize performance</blockquote><h4>Example of Bad Practice (Redundant Calculation)</h4><pre>for i in range(len(numbers)):<br>    result = process_data(numbers[i])<br>    print(f&quot;Processing index {i}, result: {result}&quot;)</pre><h4>Example of Good Practice (Precompute Length)</h4><pre>length = len(numbers)<br>for i in range(length):<br>    result = process_data(numbers[i])<br>    print(f&quot;Processing index {i}, result: {result}&quot;)</pre><h4>Leverage Python’s Built-In Functions</h4><p>Python’s built-in functions like sum(), max(), and filter() are optimized and often faster than writing custom loops. Using them also makes your code more concise and readable</p><h4>Instead of this:</h4><pre>total = 0<br>for num in numbers:<br>    total += num<br>print(total)</pre><p>Do this:</p><pre>print(sum(numbers))</pre><h4>Avoid Infinite Loops</h4><p>An infinite loop can freeze your program. Always ensure the loop’s condition eventually becomes false or that it has an explicit exit condition</p><h4>Example of Infinite Loop</h4><pre>while True:<br>    print(&quot;This loop will run forever!&quot;)</pre><h4>Example of Controlled Exit Loop</h4><pre>while True:<br>    user_input = input(&quot;Type &#39;exit&#39; to quit: &quot;)<br>    if user_input == &quot;exit&quot;:<br>        break</pre><h3>Summary</h3><p>Loops in Python are indispensable tools that make your code more efficient, readable, and powerful. With the knowledge of for, while, break, continue, and nested loops, you’re well on your way to mastering iteration in Python. As you work with loops, remember to write clean, efficient, and well-commented code to keep your projects maintainable</p><p>To test your understanding of Loops here is a Tricky Question</p><h4>Question</h4><p>What will the output of the below given code be, and why?</p><pre>numbers = [1, 2, 3, 4, 5]<br>for i in range(len(numbers)):<br>    if numbers[i] % 2 == 0:<br>        numbers.pop(i)<br>print(numbers)</pre><p>What do you think the output would be? Comment your answers</p><p>If you have found this article insightful and want more:</p><p>Give this blog a few claps 👏 to show your love! And hit that follow button 👉</p><p>Happy Learning! 😊</p><p>Feel free to <strong>connect </strong>with me 🙂: <a href="https://www.linkedin.com/in/janaa-v/"><strong>Linkedin</strong></a><strong> </strong>| <a href="https://medium.com/@JanaaVisvesvaran"><strong>Medium</strong></a></p><p>Checkout the other Articles written by Me</p><ol><li><a href="https://medium.com/@JanaaVisvesvaran/mastering-conditional-statements-in-python-fcb8772a9d7d"><em>Mastering Conditional Statements in Python</em></a></li><li><a href="https://medium.com/@JanaaVisvesvaran/unlock-the-power-of-variables-and-data-types-84f2ac284d98"><em>Unlock the Power of Variables and Data Types</em></a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b1383d3bf17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Conditional Statements in Python ]]></title>
            <link>https://medium.com/@JanaaVisvesvaran/mastering-conditional-statements-in-python-fcb8772a9d7d?source=rss-4111e0787db1------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcb8772a9d7d</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python-web-developer]]></category>
            <category><![CDATA[conditional-statements]]></category>
            <dc:creator><![CDATA[Janaa Visvesvaran]]></dc:creator>
            <pubDate>Wed, 13 Nov 2024 04:32:00 GMT</pubDate>
            <atom:updated>2024-11-13T04:32:00.388Z</atom:updated>
            <content:encoded><![CDATA[<h4>This Article enables you to Master Conditional Statements in Python</h4><p>This is my third article in the “<strong>Python — Mysteries Unwrapped!</strong>” series on the topic “<strong>Master Conditional Statements</strong>”</p><figure><img alt="Photo by Chris Ried on Unsplash" src="https://cdn-images-1.medium.com/max/720/1*DqKQtqSQVkQbmk6djF_xwg.jpeg" /></figure><p>In programming, <em>decision-making</em> is a fundamental skill, and in Python, that comes down to using conditional statements. These statements allow your code to “decide” which actions to take based on specific conditions — whether that’s checking the weather, verifying user permissions, or calculating discounts. So, let’s dive into Python’s conditional statements and see how they empower you to create dynamic and flexible code!</p><h4>1. Basics of “if” Statement</h4><p>The most fundamental conditional statement is the if statement. It checks whether a specific condition is True, and if so, it executes the code block within it</p><p><strong>Syntax:</strong></p><pre>if condition:<br>    # Write block of code that is to be executed if condition is True ✔️</pre><p><strong>Example:</strong></p><pre>age = 18<br>if age &gt;= 18:<br>    print(&quot;You are eligible to vote!&quot;)</pre><p>If this block of code is executed and as the condition is true, “You are eligible to vote!” is printed</p><h4>2. Adding Flexibility: if ….. else Statements</h4><p>We can include <em>else </em>statement with <em>if </em>statement to exeute a block of code if the specified condition is failed. The else statement provides an alternative action if the if condition is False</p><p><strong>Syntax:</strong></p><pre>if condition:<br>    # Code if condition is True ✔️<br>else:<br>    # Code if condition is False ❎</pre><p><strong>Example:</strong></p><pre>age = 16<br>if age &gt;= 18:<br>    print(&quot;You are eligible to vote!&quot;)<br>else:<br>    print(&quot;You are not eligible to vote :(&quot;)</pre><p>In this example, if age is less than 18, the else block runs and prints “You are not eligible to vote :(“</p><h4>3. Handling Multiple Conditions: if-elif-else Ladder</h4><p>When multiple conditions need to be evaluated, Python provides the elif (short for &quot;else if&quot;) statement. Once a condition is met, the corresponding code block runs, and the rest are skipped. The elif statement allows you to check multiple conditions sequentially</p><p><strong>Syntax:</strong></p><pre>if condition1:<br>    # Code to execute if condition1 is true<br>elif condition2:<br>    # Code to execute if condition1 is false and condition2 is true<br>else:<br>    # Code to execute if both conditions are false</pre><p><strong>Example:</strong></p><pre>score = 75<br>if score &gt;= 90:<br>    print(&quot;Grade: A&quot;)<br>elif score &gt;= 80:<br>    print(&quot;Grade: B&quot;)<br>elif score &gt;= 70:<br>    print(&quot;Grade: C&quot;)<br>else:<br>    print(&quot;Grade: F&quot;)</pre><p>So if this block of code is executed, Grade: C will be printed</p><h4>4. <strong>Nested Conditional Statements</strong></h4><p>You can place one conditional statement inside another, which is called nesting. Python also supports nested conditional statements, where an if statement can be placed inside another if statement. This structure helps in evaluating multiple layers of conditions</p><p><strong>Syntax:</strong></p><pre>if condition1:<br>    # Code to execute if condition1 is true<br>    if condition2:<br>        # Code to execute if both conditions are true<br>    else:<br>        # Code to execute if condition1 is true but condition2 is false<br>else:<br>    # Code to execute if condition1 is false</pre><p><strong>Example:</strong></p><pre>age = 20<br>has_id = True<br><br>if age &gt;= 18:<br>    if has_id:<br>        print(&quot;You are allowed entry.&quot;)<br>    else:<br>        print(&quot;ID is required.&quot;)<br>else:<br>    print(&quot;You are not old enough to enter.&quot;)</pre><p>Here, an additional condition (has_id) is checked only if the age condition is met, allowing for more specific responses</p><h4>Combining Conditions with &#39;and&#39; , &#39;or&#39; , &#39;not’</h4><p>Conditional statements can also utilize logical operators such as and, or, and not to combine multiple conditions. Python supports logical operators to combine multiple conditions within a single if statement</p><p><strong>Example with </strong><strong>and:</strong></p><pre>age = 21<br>has_membership = True<br><br>if age &gt;= 18 and has_membership:<br>    print(&quot;Welcome to the members-only club!&quot;)</pre><p>In this Example, both age should be above 18 and has_membership should be True</p><p><strong>Example with </strong><strong>or :</strong></p><pre>day = &quot;Saturday&quot;<br><br>if day == &quot;Saturday&quot; or day == &quot;Sunday&quot;:<br>    print(&quot;It&#39;s the weekend!&quot;)</pre><p>In this Example, if day is either Saturday or Sunday, “It’s the weekend!” is printed</p><p><strong>Example with </strong><strong>not :</strong></p><p>Using not Reverses the truth value of a condition</p><pre>a = 10<br>b = 20<br>if not a &gt; b:<br>    print(&quot;a is not greater than b&quot;)</pre><p>In this example, a &gt; b holds False. So if it was only if a &gt; b ,the condition would have failed. As not reverses the truth value False is made True . So here “a is not greater than b” is printed</p><h4>The &#39;pass’ Statement: Placeholder for Future Code</h4><p>Sometimes, we might want to write the structure of a condition but leave it unimplemented</p><p><strong>Example:</strong></p><pre>if condition:<br>    pass  # Implement later</pre><p>The pass statement does nothing but allows the code to run without errors, useful when outlining code</p><h4>Ternary (One-Line) ‘if’ Statements</h4><p>Python supports a concise, one-line version of if...else known as a ternary operator</p><p><strong>Syntax:</strong></p><pre>result = &quot;Yes&quot; if condition else &quot;No&quot;</pre><p><strong>Example:</strong></p><pre>age = 20<br>message = &quot;Eligible to vote&quot; if age &gt;= 18 else &quot;Not eligible to vote&quot;<br>print(message)</pre><p>In this Example, message holds the string <em>Eligible to vote</em>. So the same is printed</p><h4>Key Takeaway</h4><p>Conditional statements in Python are essential for controlling the flow of execution based on dynamic conditions. Understanding how to effectively use if, else, and elif, along with logical operators, allows developers to write more efficient and readable code. By effectively using <em>conditional statements</em>, you can create Python programs that can adapt to different situations and make intelligent decisions</p><h4>Bonus Part</h4><p>Check your understanding of Conditional Statements by predicting the output for it</p><pre>x = 10<br>y = 20<br>z = 10<br><br>if x &lt; y and y &lt; z or x == z:<br>    print(&quot;Condition 1 passed&quot;)<br>elif x == y or y &gt; z:<br>    print(&quot;Condition 2 passed&quot;)<br>else:<br>    print(&quot;All the Conditions failed :(&quot;)</pre><p>What do you think the output would be? Comment your answers</p><p>If you have found this article insightful and want more:</p><p>Give this blog a few claps 👏 to show your love! And hit that follow button 👉</p><p>Happy Learning! 😊</p><p>Feel free to <strong>connect </strong>with me 🙂: <a href="https://www.linkedin.com/in/janaa-v/"><strong>Linkedin</strong></a><strong> </strong>| <a href="https://medium.com/@JanaaVisvesvaran"><strong>Medium</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcb8772a9d7d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlock the Power of Variables and Data Types ]]></title>
            <link>https://medium.com/@JanaaVisvesvaran/unlock-the-power-of-variables-and-data-types-84f2ac284d98?source=rss-4111e0787db1------2</link>
            <guid isPermaLink="false">https://medium.com/p/84f2ac284d98</guid>
            <category><![CDATA[variables]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[datatypes-in-python]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python-web-developer]]></category>
            <dc:creator><![CDATA[Janaa Visvesvaran]]></dc:creator>
            <pubDate>Wed, 30 Oct 2024 04:32:07 GMT</pubDate>
            <atom:updated>2024-10-30T04:32:07.121Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article will introduce the fundamental concepts of variables and data types in programming which are essential for creating dynamic and efficient code</h4><h3><strong>Introduciton to Variables</strong></h3><blockquote>Python variables allow us to save data that may be accessed and modified throughout the code</blockquote><p>In Python, <strong>variables</strong> store values, that can later be referenced and manipulated. As Python is an interpreted language, The <strong>Value</strong> assigned to the variable is used to assign Datatype to the Variable. This allows for dynamic programming, where values can be changed and accessed easily</p><h3>Declaring Variables</h3><ul><li>Open Text Editor (like VS Code, Sublime, Vim etc,.)</li><li>Create a file with .py extension and type the following</li></ul><pre>x = 10       # x is now an integer variable<br>name = &quot;Python&quot;  # name is a string variable</pre><p>Here we have declared 2 variables, one of integer type and one of string type variable</p><h3>Types of Variables</h3><h4>Local Variables</h4><ul><li>Local variables are defined within a function or a block of code and can only be accessed within that specific scope</li><li>They exist only while the function is executing. Once the function exits, local variables are destroyed</li></ul><p>Example:</p><pre>def my_function():<br>    local_var = 10  # This is a local variable<br>    print(local_var)<br><br>my_function()  # Outputs: 10<br># print(local_var)</pre><p>This would raise error because local_var is not accessible outside the function or block of code</p><h4>Global Variables</h4><ul><li>Global variables are defined outside any function and can be accessed from any part of the program, including inside functions</li><li>They exist for the duration of the program</li></ul><p>Example:</p><pre>global_var = &quot;I am global&quot;<br><br>def my_function():<br>    print(global_var)<br><br>my_function()  # Outputs: I am global</pre><p>Here global_var is accessible throughout the code</p><h4>Enclosing Variables (Nonlocal Variables)</h4><ul><li>Enclosing variables are defined in the local scope of an enclosing function (i.e., a function within another function). They can be accessed by inner functions</li><li>They exist as long as the enclosing function is executing</li></ul><p>Example:</p><pre>def outer_function():<br>    enclosing_var = &quot;I am enclosing&quot;<br><br>    def inner_function():<br>        print(enclosing_var)  # Accessing enclosing variable<br><br>    inner_function()<br><br>outer_function()  # Outputs: I am enclosing</pre><p>Here scope of the variable can be determined with the declaration of the block of code. So it doesn’t raise or throw any Error</p><h4>Instance Variables</h4><ul><li>Variables defined within a class and accessed through instances of the class</li><li>It is specific to each instance of the class (object)</li></ul><p>Example:</p><pre>class MyClass:<br>    def __init__(self, value):<br>        self.value = value  # Instance variable</pre><p>It is specific to each instance, so values may differ for each instance (class object)</p><h4>Class Variables</h4><ul><li>Variables shared across all instances of a class</li><li>Defined within the class body but outside any instance method</li></ul><p>Example:</p><pre>class MyClass:<br>    shared_var = 42  # Class variable</pre><p>Here shared_var is the same value for all the created instances</p><h4>Built-in Variables</h4><ul><li>Built-in variables refer to names that are predefined in Python, such as print, len, list, etc. These are not user-defined but are part of the Python language itself</li><li>They exist as long as the Python interpreter is running</li></ul><p>Example:</p><pre>print(len(&quot;Hello&quot;))  # Outputs: 5</pre><h4>Variable Scope Summary</h4><p>Format: Scope of the Variable ( Variable Type ) — Scope — Lifetime</p><ol><li>Local — Inside a block of code or function — While the block of code or function is running</li><li>Global — Anywhere in the module — Throughout the execution</li><li>Enclosing — Inside nested functions — While the enclosing function comes to execution</li><li>Built-in — Throughout the interpreter — As long as the interpreter runs</li></ol><p>Variable Scope helps manage data visibility and memory usage, ensuring that code behaves as expected. By leveraging local, global, enclosing, and built-in variables appropriately, code can be written cleaner and more efficient</p><h3>Naming Convention</h3><p>Naming conventions are essential for writing clear, readable, and maintainable code. They help developers understand the purpose of variables and facilitate collaboration</p><h4>Rules</h4><ol><li><strong>Start with a Letter or Underscore</strong>: A variable name must begin with a letter (A-Z, a-z) or an underscore (_). It cannot start with a number or any special character</li><li><strong>Use Alphanumeric Characters and Underscores</strong>: After the first character, variable names can include letters, numbers, and underscores</li><li><strong>Case Sensitivity</strong>: Variable names are case-sensitive</li><li><strong>Avoid Reserved Keywords</strong>: You cannot use Python’s reserved keywords (like if, else, while, etc.) as variable names. These keywords have special meanings in this language</li></ol><p><strong>Best Practices</strong></p><ul><li><strong>Meaningful Names</strong>: Choose variable names that clearly describe their purpose or the data they hold. Avoid vague names like data or temp .(e.g., total_sum instead of ts)</li><li><strong>Snake Case</strong>: Use lowercase letters with underscores to separate words. This is the most common convention in Python. Example: user_name, total_price</li><li><strong>Camel Case</strong>: The first letter of each word is capitalized except for the first word. Example: userName, totalPrice</li><li><strong>Pascal Case</strong>: Similar to Camel Case, but the first letter of every word is capitalized. This is often used for class names. Example: UserName, TotalPrice</li><li>Avoid using Python keywords (e.g., class, def, if) as variable names, as they are reserved</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OOwK-NP2d0VZICz6ddJVeQ.jpeg" /></figure><h3>Data Types in Python</h3><blockquote>Python is a dynamically typed language, which means that variables can hold values of different types without requiring explicit declaration</blockquote><p>Python has several <strong>built-in data types</strong> that are fundamental to programming with the language. These are typically divided into <strong>8</strong> (Eight) categories</p><h3><strong>Numeric Type</strong></h3><h4>Integers ( int )</h4><p>Whole numbers, both positive and negative, without any decimal point. It represents Integers</p><p>Example: 5, -10, 1000</p><h4>Floating-point numbers ( float )</h4><p>Numbers that contain a decimal point. It represents floating-point numbers</p><p>Example: 65.5, 100.0</p><h4>Complex numbers ( complex )</h4><p>Numbers that have a real and an imaginary part, represented as a + bj, where a is the real part and b is the imaginary part. Represents complex numbers, used in advanced mathematics</p><p>Example: 3 + 5j, 2 + 3j</p><h3>Text Type</h3><h4>String ( str )</h4><p>A sequence of Unicode characters enclosed in single, double, or triple quotes. Strings are immutable</p><p>Example: “Python Programming!”, “Hello World”</p><h3>Sequence Type</h3><h4>Lists ( list )</h4><p><strong>Mutable sequences </strong>that can hold items of different data types. In Simpler terms, <strong><em>Ordered</em></strong><em>, mutable collections that allow duplicates</em></p><p>Example: [1, 2, “python”], [‘apple’, ‘banana’, ‘cherry’]</p><h4>Tuples ( tuple )</h4><p><strong>Immutable </strong>sequences that can also hold items of different data types</p><p>Example: (10.0, 20.0), (“hello”, 1, “world”)</p><h4>Ranges ( range )</h4><p>Represents an immutable <strong>sequence of numbers</strong>, typically used for looping a specific number of times</p><p>Example: range(1, 10)</p><p>Output: Generates numbers from 1 to 9</p><h3>Mapping Type</h3><h4>Dictionaries (dict)</h4><p>Unordered collections of key-value pairs, where each key must be unique. Dictionaries are mutable</p><p>Example: {“name”: “Python”, “type”: “interpreted”}</p><h3>Set Type</h3><h4>Sets ( set )</h4><p><strong>Mutable</strong> collections that do not allow duplicate elements</p><p>Example: {1, 2, 3, “Python”}</p><h4>Frozen Sets ( frozenset )</h4><p><strong>Immutable</strong> versions of sets</p><p>Example: frozenset([1, 2, 3])</p><h3>Boolean Type</h3><h4>Boolean ( bool )</h4><p>Represents Boolean values, either True or False. It is often the result of comparison or logical operations</p><h3>Binary Type</h3><h4>Bytes ( bytes )</h4><p>Represents immutable binary data, used in binary file handling</p><p>Example: b”Python”</p><h4>Byte arrays ( bytearray )</h4><p>Mutable sequences of bytes</p><p>Example: bytearray(5) # Creates a bytearray of size 5</p><h4>Memory views ( memoryview )</h4><p>Provides a memory-efficient way to manipulate binary data without copying it</p><p>Example: memoryview(byte_array)</p><h3>Special Type</h3><p>Represents the absence of a value, e.g., None. Used as a placeholder for optional or missing data</p><blockquote><strong>Note</strong>: Python’s built-in type() and isinstance() functions allow for dynamic type checking at runtime</blockquote><h3>Conversions Between Data Types</h3><p>Sometimes, you may need to convert between types for compatibility or logical reasons. Python offers several built-in functions for type casting</p><h4>Implicit Conversion</h4><p>Implicit conversion, also known as automatic type conversion, occurs when Python automatically converts one data type to another without user intervention. This typically happens when performing operations between different types that can be safely converted without losing information</p><p>Example of Implicit Conversion:</p><pre>integer_number = 123<br>float_number = 1.23<br>new_number = integer_number + float_number<br><br>print(&quot;Value:&quot;, new_number)  # Outputs: Value: 124.23<br>print(&quot;Data Type:&quot;, type(new_number))  # Outputs: &lt;class &#39;float&#39;&gt;</pre><h4>Explicit Conversion</h4><p>Explicit conversion, or type casting, is when the Developer manually converts one data type into another using built-in functions. This is necessary when you want to ensure that a variable is of a specific type or when you are combining types that cannot be implicitly converted</p><h4>Common Functions for Explicit Conversion</h4><ol><li>int() — Converts a value into Integer</li><li>float() — Converts a value into Float</li><li>str() — Converts a value into String</li><li>list() — Converts an iterable (like a string or tuple) into a list</li><li>tuple() — Converts an iterable into a tuple</li><li>set() — Converts an iterable into a set</li></ol><h3>Best Practices for Type Conversion</h3><ol><li>Always use explicit type conversion functions (like int(), float(), str(), bool()) instead of relying on implicit conversions</li><li>Wrap type conversions in try-except blocks to handle ValueError or TypeError exceptions if the input may not be in the expected format</li><li>Use isinstance() to confirm a variable’s type before converting to avoid unnecessary conversions or error</li><li>When converting dictionary values, use .get() to handle cases where the key might not exist, which helps avoid KeyError</li><li>When concatenating a non-string with a string, explicitly convert it to a string to avoid TypeError</li><li>If you need to convert a whole list or other iterable, consider using map() for efficiency</li><li>Avoid chaining multiple type conversions, as it can make code harder to read and introduce errors. Example: str(int(float(“123.45”)))</li></ol><h3>Key Takeaways</h3><p>Becoming proficient in the use of Variables and Data types is paramount for writing Python programs easily and efficiently. With these basics, you can manipulate different kinds of data, make your code organized, and carry out complicated computations with ease. These building blocks will continue to serve as you dive deeper into Python, whether working with simple scripts or building large-scale applications</p><p>By truly understanding variables and data types, you unlock the potential to write cleaner, more efficient, and more flexible code. Embrace these tools, and Python programming will become a far more intuitive and enjoyable experience</p><h3>Bonus</h3><h4>Problem</h4><p>What will be the Output for the given code?</p><pre>value = &quot;hello&quot;<br>output = list(value)<br>print(output)</pre><h4>Output</h4><p>[‘H’, ‘e’, ‘l’, ‘l’, ‘o’]</p><p>If you have found this article insightful and want more:</p><p>Give this blog a few claps 👏 to show your love! And hit that follow button 👉</p><p>Happy Learning! 😊</p><p>Feel free to <strong>connect </strong>with me 🙂: <a href="https://www.linkedin.com/in/janaa-v/"><strong>Linkedin</strong></a><strong> </strong>| <a href="https://medium.com/@JanaaVisvesvaran"><strong>Medium</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84f2ac284d98" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Python !!]]></title>
            <link>https://medium.com/@JanaaVisvesvaran/introduction-to-python-dacdb54420d7?source=rss-4111e0787db1------2</link>
            <guid isPermaLink="false">https://medium.com/p/dacdb54420d7</guid>
            <category><![CDATA[installation]]></category>
            <category><![CDATA[python-setup]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Janaa Visvesvaran]]></dc:creator>
            <pubDate>Wed, 23 Oct 2024 03:02:05 GMT</pubDate>
            <atom:updated>2024-10-23T16:18:19.496Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction to Python !!</strong></h3><h4>This Article helps you to understand Basic Python Setup with installation</h4><figure><img alt="Python Logo" src="https://cdn-images-1.medium.com/max/640/1*sOnSzgcxLIzCHI4ML-1vFg.png" /></figure><p>This Article <strong><em>Introduction to Python !!</em></strong> is part of the <strong><em>Python — Mysteries Unwrapped</em></strong> Series. In this article, you can find answers to the Questions — What is Python?, Why choose Python?, How to set up Python?, How to Run your first Python script? and many more. See if you understand Python well by answering the Question at the End. Let’s Get into the Topic</p><h3><strong>What is Python?</strong></h3><p><a href="https://www.python.org/">Python</a> is a high-level, interpreted, object-oriented, versatile programming language used for various purposes. Python was created by Guido van Rossum and first released in 1991. It was designed with simplicity and readability in mind, making it easier for both beginners and experts to write clear, logical code. Python’s syntax emphasizes readability, reducing the cost of program maintenance and making it accessible to new developers. Python has gained popularity because of its</p><ol><li><strong>Readability </strong>— Python is high-level, So reading and writing makes it very easy. Python code is often described as <strong>pseudocode-like</strong>.</li><li><strong>Large Community — </strong>Python has a thriving community of developers who contribute to its growth and provide support through forums, tutorials, and libraries.</li><li><strong>Extensive libraries </strong>— Python offers a rich ecosystem of libraries and frameworks for specific tasks, making it easier to develop applications efficiently</li><li><strong>High-level </strong>— Python abstracts away much of the complexity of the computer’s underlying hardware. We don’t have to worry about memory management, pointers, or other low-level details — Python handles that for us</li><li><strong>Interpreted</strong> — Python code is executed line by line by the Python interpreter. This makes the development process quicker and easier</li><li><strong>Cross-platform compatibility </strong>— Python code can run on various operating systems, including Windows, macOS, and Linux</li></ol><blockquote>I don’t think Python is a toy language, although it has that reputation because it’s easy to learn. It’s the fastest-growing language at Google</blockquote><blockquote>from <a href="https://en.wikipedia.org/wiki/Peter_Norvig"><strong>Peter Norvig</strong></a> (Director of Research at Google)</blockquote><h3><strong>Why choose Python?</strong></h3><ul><li><strong>Ease of Learning and Use </strong>— Python’s simple syntax and clear structure make it a great language for beginners. Python emphasizes readability, reducing the time needed to learn programming concepts and write efficient code</li><li><strong>Versatility </strong>— Python is highly versatile, allowing developers to build a wide range of applications like Web development, Data science and analysis, Machine learning, Automation, Scientific computing</li><li><strong>Community support </strong>— Python has a vast and active community of developers who contribute to improving the language and offer support for beginners and advanced users alike</li><li><strong>Cross-platform:</strong> Python is platform-independent, meaning you can run Python programs on Windows, macOS, Linux, and other systems without needing to modify your code</li><li><strong>Great for Prototyping and Rapid Development</strong> — Python’s simplicity and rich libraries make it a great choice for quickly prototyping ideas. You can develop applications faster compared to more complex languages like C++ or Java, allowing developers to focus on core functionalities rather than syntax complexities</li></ul><blockquote>Python’s simplicity lets you focus on getting your job done, not on fighting with the language</blockquote><blockquote>from <strong>Alex Martelli</strong> (Python Advocate and Author)</blockquote><h3><strong>How to set up Python?</strong></h3><p><strong>Download Python </strong>— Visit the official Python website (<a href="https://www.python.org/downloads/">https://www.python.org/downloads/</a>) and download the latest stable release unless you have specific requirements or compatibility concerns</p><ol><li>Python Installation (<strong>Windows</strong>):</li></ol><ul><li>Double-click the downloaded .exe file</li><li>Select the “Add Python to PATH” option during installation</li><li>Click “Install Now” and follow the prompts</li></ul><p>2. Python Installation (<strong>MacOS</strong>):</p><ul><li>Open the downloaded .pkg file</li><li>Follow the on-screen instructions</li><li>Ensure the “Add Python to PATH” option is selected</li></ul><p>3. Python Installation (<strong>Linux</strong>):</p><ul><li><strong>Ubuntu</strong>/Debian: sudo apt install python3</li><li><strong>Fedora</strong>: sudo dnf install python3</li><li><strong>CentOS</strong>: sudo yum install python3</li></ul><p><strong>Verify Installation</strong> — Open the command line or terminal and Type <strong>python</strong> and Enter</p><p>Optional — Setup different virtual environments for different projects</p><h3><strong>How to Run your first Python script?</strong></h3><p>Let’s start with a classic — the “Hello, World!” program</p><ul><li><strong>Open a Text Editor:</strong> Use any text editor (such as Notepad, VS Code, Sublime Text, or even Python’s own IDLE)</li><li>Write the Code:</li></ul><pre># hello.py<br>print(&quot;Hello, World!&quot;)</pre><ul><li>Save the file as hello.py (Extension .py is necessary)</li><li>Open the terminal or command prompt, navigate to the folder where the file is saved, and type:</li></ul><pre>python hello.py</pre><h3>Key Takeaway:</h3><p>In summary, Python’s versatility, simplicity, and strong community make it a developer’s go-to choice. Whether you’re a beginner or an expert, the language provides endless opportunities for growth and development. It’s versatile, beginner-friendly, and powerful enough for everything from web development to data analysis. Explore the vast Python ecosystem and discover the endless possibilities</p><h3>Bonus Part</h3><p><strong>Problem:</strong></p><p>What will be the Output for the given code?</p><pre>value = &quot;Hello World!&quot;<br>print(value)</pre><p>If you have found this article insightful and want more:</p><p>Give this blog a few claps 👏 to show your love! And hit that follow button 👉</p><p>Happy Learning! 😊</p><p>Feel free to <strong>connect </strong>with me 🙂: <a href="https://www.linkedin.com/in/janaa-v/"><strong>Linkedin</strong></a><strong> </strong>| <a href="https://medium.com/@JanaaVisvesvaran"><strong>Medium</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dacdb54420d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>