diff --git a/for_loop_&_While_loop.ipynb b/for_loop_&_While_loop.ipynb new file mode 100644 index 0000000..ab17934 --- /dev/null +++ b/for_loop_&_While_loop.ipynb @@ -0,0 +1,2673 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "authorship_tag": "ABX9TyO9E08Z4uVX1R76aC9jpSgV", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "#Introduction to Loops" + ], + "metadata": { + "id": "3WqykKfqmvbi" + } + }, + { + "cell_type": "markdown", + "source": [ + "In our every day life we follow routines for many repetitive tasks.\n", + "\n", + "In the same way we also do a lots of repetitive tasks.In order to handel repetitive task programming languages use loops.\n", + "\n", + "Python programming language also provides two types of loop:\n", + "\n", + "1) While loop\n", + "\n", + "2) For loop\n", + "\n" + ], + "metadata": { + "id": "QEyfSQqPm69N" + } + }, + { + "cell_type": "markdown", + "source": [ + "# While Loop\n", + "\n", + "We use the word ***while*** to make a while loop.It is used to execute a block of statements repeatedly until a given condition is satisfied.\n", + "\n", + "\n", + "When the condition becomes false, the lines of code after the loop will be continued to be executed." + ], + "metadata": { + "id": "0OJ_RKaAoT-v" + } + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "D7LAZsP5ms-t" + }, + "outputs": [], + "source": [ + "# syntax\n", + "while condition:\n", + " code goes here" + ] + }, + { + "cell_type": "code", + "source": [ + "#Example:\n", + "\n", + "count = 0\n", + "while count < 5:\n", + " print(count)\n", + " count = count + 1" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "kTtbiou4mt05", + "outputId": "ed263f97-49ce-4447-cc5d-27316a6ebf27" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "0\n", + "1\n", + "2\n", + "3\n", + "4\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "In above while loop, the condition becomes false when count is 5.\n", + "\n", + "That is when the loop stops.If we are interested to run block of code once the condition is no longer true, we can use ***else***." + ], + "metadata": { + "id": "f-WkgfYMq2hL" + } + }, + { + "cell_type": "code", + "source": [ + "# syntax\n", + "while condition:\n", + " code goes here\n", + "else:\n", + " code goes here" + ], + "metadata": { + "id": "6WX2tt8ymt16" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#Example\n", + "\n", + "count = 0\n", + "while count <= 5:\n", + " print(count)\n", + " count += 1\n", + "\n", + "else:\n", + " print(count)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "USmwGQ9Zmt6M", + "outputId": "83c13788-ba0e-4da1-e51e-86b1ce6c8b64" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "0\n", + "1\n", + "2\n", + "3\n", + "4\n", + "5\n", + "6\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "The above loop condition will be false when count is 5 and the loop stops, and execution starts the else statement.\n", + "\n", + "As a result 5 will be printed." + ], + "metadata": { + "id": "RP6yoyzttWrk" + } + }, + { + "cell_type": "markdown", + "source": [ + "So after getting to know how while loop working , let's understand Basic Structure.\n", + "\n" + ], + "metadata": { + "id": "zgwOqSQgt5Kd" + } + }, + { + "cell_type": "markdown", + "source": [ + "#Basic Structure\n", + "\n", + "A while loop consists of three main components:\n", + "\n", + "### 1) Initialization:\n", + "Initialize a control variable or variable before entering the loop.This variable is used to control the loop's execution.\n", + "\n", + "### 2) Condition:\n", + "Define a condition that is evaluated before each iteration of the loop.If the condition is true , the loop body is executed ; otherwise , the loop terminates.\n", + "\n", + "### 3) Loop Body:\n", + "The code block that contains the the instructions to be executed as long as the condition is true.\n", + "\n", + "### pseudocode:" + ], + "metadata": { + "id": "iZ4e4oN6uSRi" + } + }, + { + "cell_type": "code", + "source": [ + "initialize control_variable\n", + "while condition:\n", + " # Loop body\n", + " # Code to be executed repeatedly\n", + " update control_variable\n" + ], + "metadata": { + "id": "ZBXXpTtLmt9Q" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Loop Execution\n", + "\n", + "The execution of while loop can be summarized as follows:\n", + "\n", + "1) The control variable is initialized.\n", + "\n", + "2) The condition is checked.If it's true , the body is executed; otherwise, the loop terminates.\n", + "\n", + "3) After the loop body is executed,the control variable is updated . This is a crucial step to ensure that the loop eventually terminates.If you forget to update the control variable, you may create an infinite loop.\n", + "\n", + "4) The condition is checked again. If it's still true, the loop body is executed again. This process continues untill the condition becomes false." + ], + "metadata": { + "id": "BJeS_poVwXgj" + } + }, + { + "cell_type": "markdown", + "source": [ + "# What is Infinite Loops\n", + "\n", + "Crae should be taken to avoid inifinite loops, where the conditon never become false.\n", + "\n", + "This can lead to program crashes or freezes." + ], + "metadata": { + "id": "f9FNWTlXygvK" + } + }, + { + "cell_type": "markdown", + "source": [ + "# What is Exit Condition ?\n", + "\n", + "Define a clear exit condition to ensure the loop terminates when it should." + ], + "metadata": { + "id": "dQhidzV4zChX" + } + }, + { + "cell_type": "markdown", + "source": [ + "#Use Cases\n", + "\n", + "While loops are suitable for scenarios where you don't the exact number of iterations beforehand want to repeat a task untill a specific condition is met.\n" + ], + "metadata": { + "id": "vnGQ7zhWzUTt" + } + }, + { + "cell_type": "markdown", + "source": [ + "# Precautions\n", + "\n", + "Be cautious with the control variable and condition to avoid logic errors and unexpected behavior." + ], + "metadata": { + "id": "l8U3bAOyz6YI" + } + }, + { + "cell_type": "markdown", + "source": [ + "#Conclusion\n", + "\n", + "While loops are essential programming constructs for automating repetitive tasks. By carefully designing the initialization, condition, and loop body, you can control the flow of your program and efficiently solve a wide range of problems. However, it's crucial to pay attention to detail to avoid common pitfalls, such as infinite loops, and ensure your code behaves as expected." + ], + "metadata": { + "id": "4VD-4C_J0PGI" + } + }, + { + "cell_type": "markdown", + "source": [ + "#what kind of coding proble we can solve using while loop?" + ], + "metadata": { + "id": "8srF0B4J5COt" + } + }, + { + "cell_type": "markdown", + "source": [ + "While loops are versatile control structures that can be used to solve a wide range of coding problems.\n", + "\n", + "Their ability to repeatedly execute a block of code as long as a certain condition is met makes them suitable for various tasks.\n", + "\n", + "Here are some common types of coding problems that can be solved using while loops:\n", + "\n", + "#1)Counting and Summation:\n", + "\n", + "a) Counting from a starting number to an ending number.\n", + "\n", + "b) Calculating the sum of numbers in a sequence.\n", + "\n", + "c) Counting occurrences of specific elements in a list.\n", + "\n", + "#2)User Input and Validation:\n", + "\n", + "a) Repeatedly prompting the user for input until valid input is provided.\n", + "\n", + "b) Creating interactive menu-driven programs.\n", + "\n", + "#3) Searching and Filtering:\n", + "\n", + "a)Searching for an element in an array or list.\n", + "\n", + "b)Filtering elements based on a certain condition.\n", + "\n", + "#4)Data Processing and Transformation:\n", + "\n", + "a)Parsing and processing data from a file line by line.\n", + "\n", + "b)Transforming data, such as converting units or formatting text.\n", + "\n", + "#5)Simulation and Modeling:\n", + "\n", + "a)Simulating real-world scenarios, like a game loop.\n", + "\n", + "b)Modeling physical processes with discrete time steps.\n", + "\n", + "#6)Handling Unknown Iterations:\n", + "\n", + "a)Performing a task until a specific condition is met (e.g., finding a target in a game).\n", + "\n", + "b)Repeating an action until a desired level of accuracy is achieved in numerical calculations.\n", + "\n", + "#7)Dynamic Problem Solving:\n", + "\n", + "a)Solving problems where the number of iterations is determined during runtime.\n", + "\n", + "b)Dynamic programming problems, such as calculating Fibonacci numbers or solving the knapsack problem.\n", + "\n", + "#8)Dequeuing and Processing Queues:\n", + "\n", + "a)Implementing algorithms that use a queue data structure.\n", + "\n", + "b)Processing items in a queue until it's empty.\n", + "\n", + "#9)Network and I/O Operations:\n", + "\n", + "a)Receiving and processing data from network sockets.\n", + "\n", + "b)Reading and writing data from/to files or streams.\n", + "\n", + "#10)Control Flow:\n", + "\n", + "a)Implementing custom control flow mechanisms, such as custom state machines.\n", + "\n", + "b)Creating loops that react to changing conditions or events.\n", + "\n", + "#11)Error Handling and Recovery:\n", + "\n", + "a)Handling errors and retries based on error conditions.\n", + "\n", + "b)Recovering from exceptional situations.\n", + "\n", + "#12)Recursive Algorithm Replacement:\n", + "\n", + "a)Some problems that can be solved using recursion can also be solved using iterative approaches with while loops.\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "It's important to note that while loops should be used when the number of iterations is not known in advance or when you want to repeat a task until a specific condition is met. Care should be taken to ensure that the loop eventually terminates to avoid infinite loops. Additionally, while loops can often be replaced with for loops in cases where you know the exact number of iterations in advance." + ], + "metadata": { + "id": "XkWkP6Qs5F8e" + } + }, + { + "cell_type": "code", + "source": [ + "#Q1) Write a program that uses a while loop to print numbers from 1 to 100\n", + "\n", + "num =1\n", + "while num <= 100:\n", + " print(num)\n", + " num += 1" + ], + "metadata": { + "id": "lkLMv3VvmuBO", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "f8507a9c-6bee-4e65-8c2f-b1508755540a" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "5\n", + "6\n", + "7\n", + "8\n", + "9\n", + "10\n", + "11\n", + "12\n", + "13\n", + "14\n", + "15\n", + "16\n", + "17\n", + "18\n", + "19\n", + "20\n", + "21\n", + "22\n", + "23\n", + "24\n", + "25\n", + "26\n", + "27\n", + "28\n", + "29\n", + "30\n", + "31\n", + "32\n", + "33\n", + "34\n", + "35\n", + "36\n", + "37\n", + "38\n", + "39\n", + "40\n", + "41\n", + "42\n", + "43\n", + "44\n", + "45\n", + "46\n", + "47\n", + "48\n", + "49\n", + "50\n", + "51\n", + "52\n", + "53\n", + "54\n", + "55\n", + "56\n", + "57\n", + "58\n", + "59\n", + "60\n", + "61\n", + "62\n", + "63\n", + "64\n", + "65\n", + "66\n", + "67\n", + "68\n", + "69\n", + "70\n", + "71\n", + "72\n", + "73\n", + "74\n", + "75\n", + "76\n", + "77\n", + "78\n", + "79\n", + "80\n", + "81\n", + "82\n", + "83\n", + "84\n", + "85\n", + "86\n", + "87\n", + "88\n", + "89\n", + "90\n", + "91\n", + "92\n", + "93\n", + "94\n", + "95\n", + "96\n", + "97\n", + "98\n", + "99\n", + "100\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Sum of Even Numbers:\n", + "#Calculate the sum of all even numbers from 1 to 20 using a while loop.\n", + "\n", + "num = 2\n", + "total = 0\n", + "while num <= 20:\n", + " total += num\n", + " num += 2\n", + "print(total)" + ], + "metadata": { + "id": "r9MJ13HD0j1y", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "68dfd4a9-050e-4792-fb8d-045af7af20d8" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "110\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#User Input Validation:\n", + "#Ask the user to enter a positive integer, and keep asking until they do.\n", + "\n", + "while True:\n", + " user_input = int(input(\"Enter a positive integer:\"))\n", + " if user_input > 0:\n", + " print(\"Task is completed\")\n", + " break" + ], + "metadata": { + "id": "c2tXn0JJ0kH0", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "daa49774-ce68-4f32-d93f-b7fc5dc60155" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Enter a positive integer:23\n", + "Task is completed\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Reverse a String:\n", + "#Take a string as input and print it in reverse using a while loop.\n", + "\n", + "text = input(\"Enter a string: \")\n", + "index = len(text) - 1\n", + "\n", + "while index >= 0:\n", + " print(text[index], end=\"\")\n", + " index -= 1" + ], + "metadata": { + "id": "OgEpLiHJ0kKz", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "0f2b1c60-8836-4807-c613-e8bcc6948d9e" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Enter a string: MY NAME IS SOUMYA\n", + "AYMUOS SI EMAN YM" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Factorial Calculation:\n", + "#Calculate the factorial of a number entered by the user using a while loop.\n", + "\n", + "num = int(input(\"Enter a number: \"))\n", + "factorial = 1\n", + "while num > 0:\n", + " factorial *= num\n", + " num -= 1\n", + "\n", + "print(\"Factorial:\", factorial)\n" + ], + "metadata": { + "id": "Imy2jSJ80kO2", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "d36f274f-64b1-4fea-f7c3-b58d31d414de" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Enter a number: 6\n", + "Factorial: 720\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "Here the code has a logic error. It will not calculate the correct factorial for the input number due to the order of operations inside the loop.\n", + "\n", + "# num = int(input(\"Enter a number:\"))\n", + "This line prompts the user to enter a number and stores it in the \"num\" variable as an integer.\n", + "\n", + "# factorial = 1\n", + "Here , you initialize the \"factorial\" variable to 1, which is correct for calculating the factorial.\n", + "\n", + "# while num > 0\n", + "This line starts a while loop that should countinue as long as 'num' is greater than 0 , just like in the previous example.\n", + "\n", + "# num -= 1\n", + "Inside the loop, you decrement 'num' by 1.This is correct:it's a step toward reaching the condition where 'num' becomes 0 and the loop terminates.\n", + "\n", + "#factorial *= num\n", + "The problem lies here. You are multiplying 'factorial' by 'num' inside the loop before decrementing 'num'.This means you are multiplying 'factorial' by the current value of 'num' before decreasing it.\n", + "\n", + "This leads to incorrect results because you should multiply by the original value of 'num' before decrementing it." + ], + "metadata": { + "id": "1xrlnzJLISKx" + } + }, + { + "cell_type": "code", + "source": [ + "num = int(input(\"Enter a number: \"))\n", + "factorial = 1\n", + "while num > 0:\n", + " num -= 1\n", + " factorial *= num\n", + "print(\"Factorial:\", factorial)" + ], + "metadata": { + "id": "mi1TWwrQ0kRZ", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "9f6a15ab-1982-4fd0-d239-3d56a35756e4" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Enter a number: 6\n", + "Factorial: 0\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Prime Number Checker:\n", + "#Ask the user to enter a number and determine whether it's prime or not using a while loop.\n", + "\n", + "num = int(input(\"Enter a number: \"))\n", + "is_prime = True\n", + "divisor = 2\n", + "while divisor < num :\n", + " if num % divisor == 0:\n", + " is_prime = False\n", + " break\n", + "\n", + " divisor += 1\n", + "\n", + "if is_prime:\n", + " print(num, \"is prime.\")\n", + "else:\n", + " print(num, \"is not prime.\")" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "wWKHWe3hMN2n", + "outputId": "7587c8a4-db71-4387-f831-5fb21f11d2cb" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Enter a number: 21\n", + "21 is not prime.\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Number Guessing Game:\n", + "#Create a number guessing game where the user has to guess a randomly generated number using a while loop.\n", + "\n", + "import random\n", + "\n", + "target = random.randint(1, 100)\n", + "attempts = 0\n", + "\n", + "while True:\n", + " guess = int(input(\"Guess the number (1-100):\"))\n", + " attempts += 1\n", + "\n", + " if guess == target:\n", + " print(\"Congratulations! You guessed it in\", attempts,\"attempts.\")\n", + " break\n", + " elif guess < target:\n", + " print(\"Try higher.\")\n", + " else:\n", + " print(\"Try lower.\")" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "uFGM0ZgGMN50", + "outputId": "49b3eb82-55e5-4ad1-f9ea-a6e783224c65" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Guess the number (1-100):34\n", + "Try higher.\n", + "Guess the number (1-100):45\n", + "Try higher.\n", + "Guess the number (1-100):46\n", + "Try higher.\n", + "Guess the number (1-100):76\n", + "Try lower.\n", + "Guess the number (1-100):56\n", + "Try higher.\n", + "Guess the number (1-100):66\n", + "Try higher.\n", + "Guess the number (1-100):68\n", + "Congratulations! You guessed it in 7 attempts.\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Power of a Number:\n", + "#Calculate the result of raising a base number to an exponent using a while loop.\n", + "\n", + "base = int(input(\"Enter the base: \"))\n", + "exponent = int(input(\"Enter the exponent: \"))\n", + "result = 1\n", + "\n", + "while exponent > 0:\n", + " result *= base\n", + " exponent -= 1\n", + "\n", + "print(\"Result:\", result)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "crT-ElkOMN9d", + "outputId": "7c67b1b7-88ca-459b-a1c2-5c4a8a6cafc9" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Enter the base: 3456\n", + "Enter the exponent: 43\n", + "Result: 144102180914865092036679373711749081923950047318462324467720521022303464592605145423453304022555895261782838683394451379740789708755825831710670261846016\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Fibonacci Sequence:\n", + "#Generate the first N Fibonacci numbers using a while loop.\n", + "\n", + "n = int(input(\"Enter the number of Fibonacci numbers to generate: \"))\n", + "a, b = 0, 1\n", + "count = 0\n", + "\n", + "while count < n:\n", + " print(a, end=\" \")\n", + " a, b = b, a + b\n", + " count += 1\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "q0Ocg2X1MOBX", + "outputId": "fe42bca6-33e1-47e7-ae30-237d62dca2dd" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Enter the number of Fibonacci numbers to generate: 34\n", + "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 " + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Table of a Number:\n", + "#Display the multiplication table of a number entered by the user using a while loop.\n", + "\n", + "num = int(input(\"Enter a number: \"))\n", + "multiplier = 1\n", + "\n", + "while multiplier <= 10:\n", + " product = num * multiplier\n", + " print(num, \"x\", multiplier, \"=\", product)\n", + " multiplier += 1\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "qjzLt-B0MOHf", + "outputId": "b7261634-36aa-408d-9f72-c83c2d471f54" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Enter a number: 23\n", + "23 x 1 = 23\n", + "23 x 2 = 46\n", + "23 x 3 = 69\n", + "23 x 4 = 92\n", + "23 x 5 = 115\n", + "23 x 6 = 138\n", + "23 x 7 = 161\n", + "23 x 8 = 184\n", + "23 x 9 = 207\n", + "23 x 10 = 230\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Password Verification:\n", + "#Implement a simple password verification system where the user enters a password until it matches a predefined password.\n", + "\n", + "correct_password = 'secret'\n", + "\n", + "while True:\n", + " user_password = input(\"Enter the password: \")\n", + " if user_password == correct_password:\n", + " print('Access granted!')\n", + " break\n", + "\n", + " else:\n", + " print(\"Incorrect password. Try again.\")" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "vOIpzOY1Qfmj", + "outputId": "9085bb48-f257-4834-fb02-59c7db2b4b32" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Enter the password: 23456\n", + "Incorrect password. Try again.\n", + "Enter the password: secret\n", + "Access granted!\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Calculate Average:\n", + "#Compute the average of a list of numbers entered by the user using a while loop.\n", + "\n", + "total = 0\n", + "count = 0\n", + "\n", + "while True:\n", + " num = float(input(\"Enter a number (or 0 to calculate the average): \"))\n", + " if num == 0:\n", + " break\n", + " total += num\n", + " count += 1\n", + "\n", + "if count > 0:\n", + " average = total / count\n", + " print(\"Average:\", average)\n", + "else:\n", + " print(\"No numbers entered.\")" + ], + "metadata": { + "id": "PwXGNECoMOJG" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "#Break and Continue -Part 1\n", + "\n", + "Break : We use break when we like to get out of or stop the loop.\n", + "\n", + "\n", + " " + ], + "metadata": { + "id": "JNdqzBNAAwCj" + } + }, + { + "cell_type": "code", + "source": [ + "# syntax\n", + "while condition:\n", + " code goes here\n", + " if another_condition:\n", + " break" + ], + "metadata": { + "id": "t0I_LvW7MOK4" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "count = 0\n", + "while count < 5:\n", + " print(count)\n", + " count = count + 1\n", + " if count == 3:\n", + " break" + ], + "metadata": { + "id": "LUvXReaSMOOV", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "4b78a07e-5005-4a5e-adc6-4ffc40b99f35" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "0\n", + "1\n", + "2\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Continue:\n", + "with the continue statement we can skip the current iteration, and continue with the next:" + ], + "metadata": { + "id": "rD5VGVWWBwXZ" + } + }, + { + "cell_type": "code", + "source": [ + " # syntax\n", + "while condition:\n", + " code goes here\n", + " if another_condition:\n", + " continue" + ], + "metadata": { + "id": "714RTm0jMOW6" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "count = 0\n", + "while count < 5:\n", + " if count == 3:\n", + " count = count + 1\n", + " continue\n", + " print(count)\n", + " count = count + 1 # while loop only prints 0,1,2 and 4 .It skip 3" + ], + "metadata": { + "id": "w3eiqizNMOY2", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "325eeff9-55ab-4a40-f14d-2ac346667fcd" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "0\n", + "1\n", + "2\n", + "4\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "#For Loop\n", + "\n", + "A for loop is a control flow structure in programming that allows you to repeatedly execute a block of code a specific number of times. It's typically used when you know beforehand how many times you want to repeat a certain task.\n", + "\n", + "\n", + "Loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary , a set or a string)." + ], + "metadata": { + "id": "fkYT--OzDOTX" + } + }, + { + "cell_type": "markdown", + "source": [ + "#examples:\n" + ], + "metadata": { + "id": "3mYeK7g5EBGx" + } + }, + { + "cell_type": "code", + "source": [ + "for i in range(5):\n", + " print(f\"Current value of 'i' is {i} \")" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "2WPSkhoSEEqQ", + "outputId": "810a544f-24a5-439a-fd3e-0d77f82abf3f" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Current value of 'i' is 0 \n", + "Current value of 'i' is 1 \n", + "Current value of 'i' is 2 \n", + "Current value of 'i' is 3 \n", + "Current value of 'i' is 4 \n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "#Pseudo-code Explanation:" + ], + "metadata": { + "id": "paFVnc7kES9L" + } + }, + { + "cell_type": "code", + "source": [ + "FOR each value 'i' in the range from 0 to 4 (inclusive):\n", + " Print \"Current value of 'i' is 'i'\"\n", + " # Code to be executed within the loop\n", + "END FOR\n" + ], + "metadata": { + "id": "rRnJK_4eEEmb" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Use case of for loop:\n", + "\n", + "for loops are versatile and can be used to solve a wide range of coding problems across various domains. Here are some common types of problems that can be solved using for loops:\n", + "\n", + "##Iteration Over Collections:\n", + "\n", + "Loop through elements in an array, list, or other data structures.\n", + "Process and manipulate each item in the collection.\n", + "\n", + "##Counting and Accumulation:\n", + "\n", + "1)Count the number of occurrences of a specific value in a list.\n", + "Calculate the sum, average, or other statistics of a list of numbers.\n", + "Pattern Generation:\n", + "\n", + "2)Generate and print patterns like triangles, squares, or any custom shapes.\n", + "\n", + "3)Create sequences, such as Fibonacci numbers, using loops.\n", + "File Processing:\n", + "\n", + "4)Read lines from a file and process them.\n", + "Write data to a file in a structured format.\n", + "\n", + "##Nested Loops:\n", + "\n", + "Solve problems that require multiple levels of iteration.\n", + "For example, a nested for loop can be used to traverse a 2D array or matrix.\n", + "\n", + "##Searching and Filtering:\n", + "\n", + "Search for specific values or elements in a collection.\n", + "Filter elements that meet certain conditions and create a new list.\n", + "\n", + "\n", + "##Validation and Input Handling:\n", + "\n", + "Validate user input by repeatedly asking for input until valid data is provided.\n", + "Ensure data meets specific criteria before proceeding.\n", + "\n", + "##Simulation and Modeling:\n", + "\n", + "Simulate complex systems or processes by iterating through time steps or events.\n", + "Implement numerical simulations using iterations.\n", + "\n", + "##Generating Sequences:\n", + "\n", + "Generate arithmetic or geometric sequences based on specific rules.\n", + "\n", + "##Game Development:\n", + "\n", + "Implement game loops to update game state and render frames.\n", + "Handle user input and game logic within loops.\n", + "\n", + "##Statistical Analysis:\n", + "\n", + "Perform statistical analysis on datasets using loops to calculate means, medians, and variances.\n", + "\n", + "##Iterative Algorithms:\n", + "\n", + "Implement algorithms that require iterations, such as searching, sorting, or graph traversal algorithms.\n", + "\n", + "##Automating Repetitive Tasks:\n", + "\n", + "Automate tasks that need to be performed repeatedly, such as batch processing of files or data.\n", + "\n", + "##Generating Reports and Output:\n", + "\n", + "Create reports, invoices, or data summaries by iterating through data and formatting it.\n", + "\n", + "##Calendar and Date Calculations:\n", + "\n", + "Calculate dates, days of the week, or holidays for a given year or range of years.\n" + ], + "metadata": { + "id": "VY0alTu1FadX" + } + }, + { + "cell_type": "code", + "source": [ + "#Iterative over collection:\n", + "\n", + "my_list = [1,2,3,4,5]\n", + "for item in my_list:\n", + " print(item)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "oEnX7hYTGNte", + "outputId": "d279bc2d-2176-4d08-8e17-1dfc49a3779f" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "5\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Counting and Accumulation:\n", + "\n", + "numbers = [1,2,3,4,1,2,1]\n", + "count = 0\n", + "for num in numbers:\n", + " if num == 1:\n", + " count += 1\n", + "print(\"Count of 1s:\",count)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "N2DmM_BjGj0u", + "outputId": "3c8f5922-4ad1-4fe2-eb4b-5f6f63e623c1" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Count of 1s: 3\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Pattern Generation (Triangle):\n", + "\n", + "n=5\n", + "for i in range(1, n + 1):\n", + " print(\"*\" * i)\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "Wwk_ogZoGj32", + "outputId": "9ec2fd4e-07a0-477e-dbb6-f9f9f6123d0a" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "*\n", + "**\n", + "***\n", + "****\n", + "*****\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# File Processing(Reading):\n", + "\n", + "with open(\"sample.txt\", \"r\") as file:\n", + " for line in file:\n", + " print(line.strip())\n" + ], + "metadata": { + "id": "AiPQNXfzGj_b" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "# Nested Loops:\n", + "\n", + "for i in range(3):\n", + " for j in range(3):\n", + " print(f\"{i},{j}\")" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "eW8qHK6EGPFg", + "outputId": "4f30eb96-086a-467b-de7f-0a2bb917b987" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "0,0\n", + "0,1\n", + "0,2\n", + "1,0\n", + "1,1\n", + "1,2\n", + "2,0\n", + "2,1\n", + "2,2\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Searching and Filtering:\n", + "\n", + "numbers = [10,20,30,40,50,60]\n", + "target = 30\n", + "found = False\n", + "for num in numbers:\n", + " if num == target:\n", + " found = True\n", + " break\n", + "print(\"Found:\", found)\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "gRy0G70AGO5-", + "outputId": "7b6d2f75-1597-41cb-e20e-2a3f48b4e675" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Found: True\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# Validation and Input Handling:\n", + "\n", + "while True:\n", + " user_input = input(\"Enter a positive number: \")\n", + " if user_input.isdigit() and int(user_input) > 0:\n", + " break\n", + "print(\"Valid input:\", user_input)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "x9u4EIpeK6og", + "outputId": "95d5a060-f2f2-4e78-8b7a-3361905eeaa8" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Enter a positive number: 23\n", + "Valid input: 23\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# Simulation and Modeling:\n", + "\n", + "total = 1000\n", + "interest_rate = 0.05\n", + "years = 5\n", + "for year in range(1, years + 1):\n", + " total = total * (1 + interest_rate)\n", + " print(f\"Year {year}: ${total:.2f}\")" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "iIwRaadLK6lC", + "outputId": "9d7cf178-a49b-48e3-89e6-3a8f47421ece" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Year 1: $1050.00\n", + "Year 2: $1102.50\n", + "Year 3: $1157.62\n", + "Year 4: $1215.51\n", + "Year 5: $1276.28\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Generating Sequence (Fibonacci):\n", + "\n", + "n = 10\n", + "a,b = 0,1\n", + "for _ in range(n):\n", + " print(a, end=\" \")\n", + " a, b = b, a+b" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "lepIp6vGGOrT", + "outputId": "1ce49412-c4b5-4161-d91a-6ce87eaea64c" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "0 1 1 2 3 5 8 13 21 34 " + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Automating Repetitive Tasks:\n", + "import os\n", + "\n", + "for filename in os.listdir(\"data/\"):\n", + " if filename.endswith(\".txt\"):\n", + " process_file(os.path.join(\"data/\", filename))\n" + ], + "metadata": { + "id": "27qLqxtsEEXI" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# How for loop is used in data analysis ?. write 10 demo code." + ], + "metadata": { + "id": "yP_adzV6NnhR" + } + }, + { + "cell_type": "markdown", + "source": [ + "for loops are commonly used in data analysis to iterate over datasets, perform calculations, filter data, and generate insights.\n", + "\n", + "Here are 10 demo code snippets that illustrate how for loops can be used in data analysis tasks using Python. These examples assume you have a list of data or a dataset represented as a list of dictionaries." + ], + "metadata": { + "id": "v1GPBwSvNx-k" + } + }, + { + "cell_type": "code", + "source": [ + "#Calculating the Mean of a Numeric Column:\n", + "\n", + "data = [10, 15, 20, 25, 30]\n", + "total = 0\n", + "for value in data:\n", + " total += value\n", + "mean = total / len(data)\n", + "print(\"Mean:\", mean)\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "NVp9LIGQNmQT", + "outputId": "4d1ab98e-3fcd-43c6-ef91-31c0e0b2e424" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Mean: 20.0\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Filtering Data Based on a Condition:\n", + "\n", + "data = [\n", + " {\"name\": \"Alice\", \"age\": 25},\n", + " {\"name\": \"Bob\", \"age\": 30},\n", + " {\"name\": \"Charlie\", \"age\": 22},\n", + "]\n", + "young_people = []\n", + "for person in data:\n", + " if person[\"age\"] < 30:\n", + " young_people.append(person)\n", + "print(\"Young people:\", young_people)\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "AgjfGw5cNmTX", + "outputId": "da4fc37f-f2b2-4f65-f9c9-83be52fcee75" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Young people: [{'name': 'Alice', 'age': 25}, {'name': 'Charlie', 'age': 22}]\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# Counting Occurrences of a Specific Value:\n", + "\n", + "data = [1, 2, 3, 2, 4, 2, 5]\n", + "count = 0\n", + "target = 2\n", + "for value in data:\n", + " if value == target:\n", + " count += 1\n", + "print(f\"{target} appears {count} times.\")\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "6G2A_NvbNmW5", + "outputId": "179359b3-d47e-45b7-8e47-df436ec5b0d7" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "2 appears 3 times.\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Aggregating Data by Category:\n", + "\n", + "data = [\n", + " {\"category\": \"A\", \"value\": 10},\n", + " {\"category\": \"B\", \"value\": 15},\n", + " {\"category\": \"A\", \"value\": 20},\n", + "]\n", + "category_totals = {}\n", + "for entry in data:\n", + " category = entry[\"category\"]\n", + " value = entry[\"value\"]\n", + " if category in category_totals:\n", + " category_totals[category] += value\n", + " else:\n", + " category_totals[category] = value\n", + "print(\"Category Totals:\", category_totals)\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "kziDTQDNNmk1", + "outputId": "a80fa644-e4f1-42ba-85e1-bcd4ca448801" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Category Totals: {'A': 30, 'B': 15}\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Finding Maximum and Minimum Values:\n", + "\n", + "data = [15, 30, 10, 45, 20]\n", + "max_value = float(\"-inf\")\n", + "min_value = float(\"inf\")\n", + "for value in data:\n", + " if value > max_value:\n", + " max_value = value\n", + " if value < min_value:\n", + " min_value = value\n", + "print(\"Max Value:\", max_value)\n", + "print(\"Min Value:\", min_value)\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "joSzQdfYNmmw", + "outputId": "93c8fb8b-5b17-422e-f8c9-b836a6edfc49" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Max Value: 45\n", + "Min Value: 10\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Data Transformation:\n", + "\n", + "data = [1, 2, 3, 4, 5]\n", + "squared_data = []\n", + "for value in data:\n", + " squared_data.append(value ** 2)\n", + "print(\"Squared Data:\", squared_data)\n" + ], + "metadata": { + "id": "0ydYdKiuMOaj", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "09735ddc-69b7-4033-b5f1-dde043da2569" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Squared Data: [1, 4, 9, 16, 25]\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Removing Outliers:\n", + "data = [10, 15, 20, 500, 25]\n", + "threshold = 100\n", + "filtered_data = [value for value in data if value <= threshold]\n", + "print(\"Filtered Data:\", filtered_data)\n" + ], + "metadata": { + "id": "jVeaGpfy0kU9", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "3bcecd4c-367c-43e8-ab6d-7dcc71225f98" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Filtered Data: [10, 15, 20, 25]\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Calculating Percentages:\n", + "\n", + "data = [20,30,40,10,5]\n", + "total = sum(data)\n", + "percentages = [(value / total) * 100 for value in data]\n", + "print(\"Percentages:\", percentages)" + ], + "metadata": { + "id": "D8ci88PB0kZA", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "48f8b901-5307-44c1-f66f-f36027b290b6" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Percentages: [19.047619047619047, 28.57142857142857, 38.095238095238095, 9.523809523809524, 4.761904761904762]\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Grouping Data by Date:\n", + "\n", + "data = [\n", + " {\"date\": \"2023-01-01\", \"value\": 10},\n", + " {\"date\": \"2023-01-02\", \"value\": 15},\n", + " {\"date\": \"2023-01-01\", \"value\": 20},\n", + "]\n", + "\n", + "daily_totals = {}\n", + "for entry in data:\n", + " date = entry[\"date\"]\n", + " value = entry[\"value\"]\n", + " if date in daily_totals:\n", + " daily_totals[date] += value\n", + " else:\n", + " daily_totals[date] = value\n", + "print(\"Daily Totals:\",daily_totals)\n" + ], + "metadata": { + "id": "SnR13BQWmuFN", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "bf2c5d10-af11-4222-8986-0ff46a87a5b2" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Daily Totals: {'2023-01-01': 30, '2023-01-02': 15}\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Data Visualization using Matplotlib:\n", + "\n", + "import matplotlib.pyplot as plt\n", + "\n", + "data = [10,20,30,40,50]\n", + "x_values = range(len(data))\n", + "plt.bar(x_values, data)\n", + "plt.xticks(x_values,[\"A\",\"B\",\"C\",\"D\",\"E\"])\n", + "plt.xlabel(\"Categories\")\n", + "plt.ylabel(\"Values\")\n", + "plt.title(\"Bar Chart\")\n", + "plt.show()\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 472 + }, + "id": "8-FkLxOnP1L-", + "outputId": "eb6380ff-39b3-4beb-eeb3-9fc1b9ef452a" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "display_data", + "data": { +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GrUKFVXV2vx4sW65pprtGLFCg0dOtRr37y8PL322msaN26cWrRooXbt2h3ztT/66CP98MMPGj9+vAIDA+s8c1pampo3b67JkyerqKhIs2fP1rhx4/Tqq6969snJyVFERITS09MVERGhvLw8TZo0SZWVlXryySe9jvf9999ryJAh+vOf/6zRo0crLi5O/fr1U1pamiIiIvTQQw9JkuLi4uo8I4DfwADASSxYsMBIOmoJCQkxOTk5R+1/8OBBr8fV1dXmwgsvNAMGDPBaL8kEBASYLVu2nHSGp59+2kgyy5Yt82nmpKQkU1tb61k/YcIEExgYaMrLy487rzHG3HnnnaZp06bm0KFDnnV9+/Y1ksy8efOO2r9Lly6mb9++dZoNQP3hrSUAdZaZmanVq1dr9erVeumll9S/f3/ddtttWrp0qdd+YWFhnn/et2+fKioq1KdPH23YsOGoY/bt21cXXHDBSV+7srJSkhQZGenTzHfccYfX21B9+vTR4cOHtWvXrmPOu3//fn333Xfq06ePDh48qC+//NLreCEhIRozZoxPMwBoOLy1BKDOevTo4XWz7/XXX6+LLrpI48aN07BhwxQcHCxJWrFihR599FFt3LhRbrfbs/+x7mtp3759nV47KipK0s+h4Yu2bdt6PW7evLmknwPriC1btujhhx9WXl6eJ5iOqKio8HrcunVrz58TgPO4IgPglAUEBKh///4qKSnR9u3bJUkffvihRowYodDQUGVlZenvf/+7Vq9erRtuuEHGmKOO8curISeSkJAgSdq8ebNPMx7vfpojs5SXl6tv3776/PPPNXXqVC1fvlyrV6/W448/LunnT1KdyrwATg+uyAD4TX766SdJUlVVlSTpjTfeUGhoqN59912FhIR49luwYMFvep3LLrtMzZs31yuvvKIHH3zQpxt+T2TNmjX6/vvvtXTpUl1++eWe9Tt37vTpOMe62gSg4XFFBsApq6mp0T/+8Q8FBwfr/PPPl/TzFRCXy+X10eWioiK9+eabv+m1mjZtqvvvv19bt27V/ffff8yrOy+99JIKCgp8Ou6RIPrl8aqrq5WVleXTccLDw1VeXu7TcwD8dlyRAVBnK1eu9Nz8unfvXi1atEjbt2/XAw884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DLFxcXKyclRTk6OduzYoV69emnOnDm69tprFR4e3lAzAgAAHFOdQ2bIkCF677331KJFC91000269dZb1blz54acDQAA4ITqHDJNmjTR66+/rmHDhikwMLAhZwIAAKiTOofM22+/3ZBzAAAA+Ow3fWoJAADASYQMAACwFiEDAACsRcgAAABrETIAAMBahAwAALAWIQMAAKxFyAAAAGsRMgAAwFqEDAAAsBYhAwAArEXIAAAAaxEyAADAWoQMAACwFiEDAACs5WjIZGRk6A9/+IMiIyN11llnaeTIkdq2bZvXPocOHVJqaqpiY2MVERGhlJQUlZWVOTQxAADwJ46GTH5+vlJTU7V+/XqtXr1aNTU1+uMf/6gDBw549pkwYYKWL1+uJUuWKD8/X8XFxbr66qsdnBoAAPiLICdffNWqVV6Pc3JydNZZZ6mwsFCXX365KioqlJ2drUWLFmnAgAGSpAULFuj888/X+vXr1bNnTyfGBgAAfsKv7pGpqKiQJMXExEiSCgsLVVNTo6SkJM8+CQkJatu2rdatW3fMY7jdblVWVnotAACgcXL0iswv1dbWavz48erdu7cuvPBCSVJpaamCg4PVrFkzr33j4uJUWlp6zONkZGRoypQpDT0uHNTugXecHsEqRdOHOj0CADQYv7kik5qaqi+++EKLFy/+TceZOHGiKioqPMuePXvqaUIAAOBv/OKKzLhx47RixQp98MEHOuecczzr4+PjVV1drfLycq+rMmVlZYqPjz/msUJCQhQSEtLQIwMAAD/g6BUZY4zGjRunZcuWKS8vT+3bt/fa3r17dzVp0kS5ubmeddu2bdPu3buVmJh4uscFAAB+xtErMqmpqVq0aJHeeustRUZGeu57iY6OVlhYmKKjozV27Filp6crJiZGUVFRSktLU2JiIp9YAgAAzobM3LlzJUn9+vXzWr9gwQLdcsstkqRZs2YpICBAKSkpcrvdSk5OVlZW1mmeFAAA+CNHQ8YYc9J9QkNDlZmZqczMzNMwEQAAsInffGoJAADAV4QMAACwFiEDAACsRcgAAABrETIAAMBahAwAALAWIQMAAKxFyAAAAGsRMgAAwFqEDAAAsBYhAwAArEXIAAAAaxEyAADAW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8//dQEBgaaRYsWmaKiIrNhwwbz9NNP19epBlBHhAyAOvvkk0+MJLN06VKfnrdkyRITGxvrebxgwQKv+DDGmF27dpnAwEDzz3/+02v9wIEDzcSJE40xxlx33XVm6NChXttHjRrldaxevXqZ22+/3Wufa665xlxxxRWex5LM+PHjvfb5dciMHTvW3HHHHV77fPjhhyYgIMD8+OOP5o033jBRUVGmsrLy5CcAQIPhrSUAdWaMqdN+7733ngYOHKjWrVsrMjJSN954o77//nsdPHjwuM/ZvHmzDh8+rE6dOikiIsKz5Ofn6+uvv5Ykbdu2TT169PB63q8fb926Vb179/Za17t3b23dutVr3SWXXHLCP8Pnn3+unJwcr1mSk5NVW1urnTt3atCgQTr33HPVoUMH3XjjjXr55ZdP+OcD0DC42RdAnZ133nlyuVwnvKG3qKhIw4YN01/+8hdNmzZNMTEx+uijjzR27FhVV1eradOmx3xeVVWVAgMDVVhYqMDAQK9tERER9frnkKTw8PATbq+qqtKdd96pe+6556htbdu2VXBwsDZs2KA1a9boH//4hyZNmqRHHnlEn376qd99IgtozLgiA6DOYmJilJycrMzMTK+bXo8oLy9XYWGhamtrNWPGDPXs2VOdOnVScXGx137BwcE6fPiw17qLLrpIhw8f1t69e9WxY0ev5ciniTp37qxPP/3U63m/fnz++efr448/9lr38ccf64ILLvDpz3rxxRfrv//7v4+apWPHjgoODpYkBQUFKSkpSU888YQ2bdqkoqIi5eXl+fQ6AH4bQgaATzIzM3X48GH16NFDb7zxhrZv366tW7dqzpw5SkxMVMeOHVVTU6NnnnlG//M//6MXX3xR8+bN8zpGu3btVFVVpdzcXH333Xc6ePCgOnXqpFGjRummm27S0qVLtXPnThUUFCgjI0PvvPOOJCktLU1///vfNXPmTG3fvl3PPfecVq5cKZfL5Tn23/72N+Xk5Gju3Lnavn27Zs6cqaVLl+q+++7z6c95//33a+3atRo3bpw2btyo7du366233tK4ceMkSStWrNCcOXO0ceNG7dq1SwsXLlRtba06d+78G88wAJ84fZMOAPsUFxeb1NRUc+6555rg4GDTunVrM2LECPP+++8bY4yZOXOmOfvss01YWJhJTk42Cxcu9LqR1hhj7rrrLhMbG2skmcmTJxtjjKmurjaTJk0y7dq1M02aNDFnn322ueqqq8ymTZs8z3v++edN69atTVhYmBk5cqR59NFHTXx8vNd8WVlZpkOHDqZJkyamU6dOZuHChV7bJZlly5Z5rfv1zb7GGFNQUGAGDRpkIiIiTHh4uOnatauZNm2aMebnG3/79u1rmjdvbsLCwkzXrl3Nq6+++ttOLACfuYyp4917AOCHbr/9dn355Zf68MMPnR4FgAO42ReAVZ566ikNGjRI4eHhWrlypf7zP/9TWVlZTo8FwCFckQFglWuvvVZr1qzR/v371aFDB6Wlpemuu+5yeiwADiFkAACAtfjUEgAAsBYhAwAArEXIAAAAaxEyAADAWoQMAACwFiEDAACsRcgAAABrETIAAMBahAwAALDW/wLUtnkIei9UaAAAAABJRU5ErkJggg==\n" + }, + "metadata": {} + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "##For Loop in Data Engineering:\n", + "\n", + "***for loops*** are also used in data engineering, especially when working with batch processing, data extraction, transformation, and loading (ETL) tasks, and handling files or directories.\n", + "\n", + " Here are some examples of how for loops are used in data engineering:\n", + "\n", + "\n" + ], + "metadata": { + "id": "ZASHIXk6TGES" + } + }, + { + "cell_type": "markdown", + "source": [ + "###Iterating Over Files in a Directory:\n", + "\n", + "You can use a for loop to iterate over files in a directory and process them one by one. For example, you might read and transform multiple data files and load them into a database." + ], + "metadata": { + "id": "0PVfykfhTp-M" + } + }, + { + "cell_type": "code", + "source": [ + "import os\n", + "\n", + "data_directory = '/path/to/data'\n", + "for filename in os.listdir(data_directory):\n", + " if filename.endswith('.csv'):\n", + " process_csv_file(os.path.join(data_directory, filename))\n" + ], + "metadata": { + "id": "j4C8FsSNP1Cq" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "###Batch Processing and ETL:\n", + "\n", + "In data engineering, it's common to process data in batches, especially when dealing with large datasets.\n", + "\n", + "for loops can be used to divide the data into smaller chunks and process them iteratively." + ], + "metadata": { + "id": "fgb21MqJUfii" + } + }, + { + "cell_type": "code", + "source": [ + "data = [data_chunk1, data_chunk2, data_chunk3, ...]\n", + "for chunk in data:\n", + " process_data(chunk)\n" + ], + "metadata": { + "id": "hzm0jJv_P0-f" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "###Data Validation and Cleansing:\n", + "\n", + "You may need to validate and cleanse data during ETL processes.\n", + "\n", + "A for loop can be used to iterate through rows or records in a dataset, check for data quality issues, and clean or transform the data as needed." + ], + "metadata": { + "id": "42awBejDUuO2" + } + }, + { + "cell_type": "code", + "source": [ + "for row in data:\n", + " if not is_valid(row):\n", + " clean_and_transform(row)" + ], + "metadata": { + "id": "ruit6nCAP060" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "###Data Import and Export:\n", + "\n", + "When importing or exporting data between different systems or formats, you can use for loops to iterate through records and handle the data exchange." + ], + "metadata": { + "id": "nIo09HcpVpgY" + } + }, + { + "cell_type": "code", + "source": [ + "for record in source_data:\n", + " transformed_data = transform(record)\n", + " target_system.save(transformed_data)\n" + ], + "metadata": { + "id": "cdXM5eVbP03d" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "###Data Aggregation:\n", + "\n", + "In data engineering, you may need to aggregate data from multiple sources or files. for loops can be used to iterate through data sources and combine or aggregate data as needed." + ], + "metadata": { + "id": "ma-IunT3V3wg" + } + }, + { + "cell_type": "code", + "source": [ + "aggregated_data = []\n", + "for data_source in data_sources:\n", + " data = extract_data(data_source)\n", + " aggregated_data.extend(data)\n" + ], + "metadata": { + "id": "QbvgjNEGVuCG" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "###ETL Workflow Automation:\n", + "Data engineering often involves creating automated ETL pipelines. for loops can be used to schedule and execute ETL tasks in sequence." + ], + "metadata": { + "id": "xZV3kcqQWFZP" + } + }, + { + "cell_type": "code", + "source": [ + "etl_tasks=[task1,task2,task3,...]\n", + "for task in etl_tasks:\n", + " execute_task(task)" + ], + "metadata": { + "id": "6C9db1z8Vt9n" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "###Data Partitioning and Sharding:\n", + "When working with distributed systems, data may be partitioned or sharded across multiple nodes or servers. for loops can be used to iterate through data partitions and perform parallel processing." + ], + "metadata": { + "id": "88i0lxlHWiO4" + } + }, + { + "cell_type": "code", + "source": [ + "partitions = [partition1, partition2,partitons3,...]\n", + "for partition in partitions:\n", + " process_partition(partition)" + ], + "metadata": { + "id": "FYFuWeH3Vt6k" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "###Log and Error Handling:\n", + "In data engineering, you often encounter logs and error records. for loops can be used to iterate through logs and handle errors, ensuring data pipeline reliability." + ], + "metadata": { + "id": "tTLlXwNAW_Kx" + } + }, + { + "cell_type": "code", + "source": [ + "for log_entry in log_file:\n", + " process_log(log_entry)" + ], + "metadata": { + "id": "6UnAItS0Vt21" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# For loop prilims:\n", + "\n", + "### for loop with string" + ], + "metadata": { + "id": "wLYwuxoTXMAt" + } + }, + { + "cell_type": "code", + "source": [ + "#syntax\n", + "for iterator in string:\n", + " ----code---" + ], + "metadata": { + "id": "Ss-W8Q46VtzB" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "language = \"Sanskrit\"\n", + "for letters in language:\n", + " print(letters)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "6D9u7i8aP0z0", + "outputId": "a26cf0d8-59c3-4aa7-fda8-7406ffbc5475" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "S\n", + "a\n", + "n\n", + "s\n", + "k\n", + "r\n", + "i\n", + "t\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "for i in range(len(language)):\n", + " print(language[i])" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "8U1TvdxkP0i-", + "outputId": "407ef093-9ff5-4c32-c0ab-cf7629001d7e" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "S\n", + "a\n", + "n\n", + "s\n", + "k\n", + "r\n", + "i\n", + "t\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "### for loop with tuple\n" + ], + "metadata": { + "id": "STKaZrc4YAdk" + } + }, + { + "cell_type": "code", + "source": [ + "# syntax\n", + "for iterator in tpl:\n", + " -- code --" + ], + "metadata": { + "id": "PJ3HzPeXX-yB" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "numbers = (0,1,2,3,4,5)\n", + "for number in numbers:\n", + " print(number)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "bB3Xi0uAX-1m", + "outputId": "95746d57-dba0-4162-9be8-fa5424aad7bb" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "0\n", + "1\n", + "2\n", + "3\n", + "4\n", + "5\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "For loop with dictionary Looping through a dictionary gives you the key of the dictionary." + ], + "metadata": { + "id": "4s6w03N5YZZc" + } + }, + { + "cell_type": "code", + "source": [ + "# syntax\n", + "for iterator in dct:\n", + " -- code --" + ], + "metadata": { + "id": "XrONaWHqX-5Q" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "person = {\n", + " 'first_name':'Soumya',\n", + " 'last_name':'Panda',\n", + " 'age':25,\n", + " 'country':'INDIA',\n", + " 'is_marred':False,\n", + " 'skills':['Python', 'Rest API', 'NUMPY','Pandas','sk-learn', 'MongoDB', 'Python'],\n", + " 'address':{\n", + " 'street':'Kusuma, down street',\n", + " 'zipcode':'753001'\n", + " }\n", + "}\n", + "for key in person:\n", + " print(key)\n", + "\n", + "for key, value in person.items():\n", + " print(key, value) # this way we get both keys and values printed out" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "FqbYLHWrX-9x", + "outputId": "998592fb-8f83-4cab-9ac8-dfddc1fdce43" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "first_name\n", + "last_name\n", + "age\n", + "country\n", + "is_marred\n", + "skills\n", + "address\n", + "first_name Soumya\n", + "last_name Panda\n", + "age 25\n", + "country INDIA\n", + "is_marred False\n", + "skills ['Python', 'Rest API', 'NUMPY', 'Pandas', 'sk-learn', 'MongoDB', 'Python']\n", + "address {'street': 'Kusuma, down street', 'zipcode': '753001'}\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "### Loops in set\n" + ], + "metadata": { + "id": "e-CDJWPybU1r" + } + }, + { + "cell_type": "code", + "source": [ + "# syntax\n", + "for iterator in st:\n", + " --code--" + ], + "metadata": { + "id": "bI7Pz_GTbUCd" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "MNC_companies = {'Facebook', 'Google', 'Microsoft', 'Apple', 'IBM', 'Oracle', 'Amazon'}\n", + "for company in MNC_companies:\n", + " print(company)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "WvOT1j_xbUGg", + "outputId": "523a33a4-f2bf-4ad1-e6d2-9c7817d31900" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Apple\n", + "Oracle\n", + "Facebook\n", + "Google\n", + "Microsoft\n", + "IBM\n", + "Amazon\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "##The Range Function\n", + "The range() function is used list of numbers.\n", + "\n", + "The range(start, end, step) takes three parameters: starting, ending and increment.\n", + "\n", + "By default it starts from 0 and the increment is 1. The range sequence needs at least 1 argument (end). Creating sequences using range" + ], + "metadata": { + "id": "CXBFqFcXcQOR" + } + }, + { + "cell_type": "code", + "source": [ + "lst = list(range(11))\n", + "print(lst)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "pIZ2Dg2ibUKv", + "outputId": "2231846c-3928-4eca-841f-83a07adb44a3" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "set= set(range(1,11)) # 2 arguments indicates start and end\n", + "print(set)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "wFNqWthmbUSR", + "outputId": "47077ada-64db-407e-a16f-38803045e322" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "lst = list(range(0,11,2))\n", + "print(lst)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "ka-2KzFoX_DI", + "outputId": "d595956b-6a62-44aa-f1c4-2b9ed94f1b15" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "[0, 2, 4, 6, 8, 10]\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# syntax\n", + "for iterator in range(start, end, step):" + ], + "metadata": { + "id": "rm2z3CwidupV" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "for number in range(11):\n", + " print(number) # prints 0 to 10, not including 11" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "oSq6JxMSduty", + "outputId": "9812429b-149c-4eb2-a874-621c7e588b18" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "0\n", + "1\n", + "2\n", + "3\n", + "4\n", + "5\n", + "6\n", + "7\n", + "8\n", + "9\n", + "10\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "##Nested For Loop\n", + "We can write loops inside a loop." + ], + "metadata": { + "id": "UytrrI-Jd8Gi" + } + }, + { + "cell_type": "code", + "source": [ + "# syntax\n", + "for x in y:\n", + " for t in x:\n", + " print(t)" + ], + "metadata": { + "id": "VFO1LepDduyb" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "person = {\n", + " 'first_name':'Soumya',\n", + " 'last_name':'Panda',\n", + " 'age':25,\n", + " 'country':'INDIA',\n", + " 'is_marred':False,\n", + " 'skills':['Python', 'Rest API', 'NUMPY','Pandas','sk-learn', 'MongoDB', 'Python'],\n", + " 'address':{\n", + " 'street':'Kusuma, down street',\n", + " 'zipcode':'753001'\n", + " }\n", + "}\n", + "\n", + "for key in person:\n", + " if key == 'skills':\n", + " for skill in person['skills']:\n", + " print(skill)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "x2fY_1bRdu2T", + "outputId": "9791745f-9399-439e-cc17-9b5befc7b14d" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Python\n", + "Rest API\n", + "NUMPY\n", + "Pandas\n", + "sk-learn\n", + "MongoDB\n", + "Python\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "##For Else\n", + "\n", + "If we want to execute some message when the loop ends, we use else." + ], + "metadata": { + "id": "o3IAZ_wOevoA" + } + }, + { + "cell_type": "code", + "source": [ + "# syntax\n", + "for iterator in range(start, end, step):\n", + " do something\n", + "else:\n", + " print('The loop ended')" + ], + "metadata": { + "id": "DzzP4916du_l" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "# Example:\n", + "\n", + "for number in range(11):\n", + " print(number) # prints 0 to 10 , not including 11\n", + "\n", + "else:\n", + " print('The loop stops at', number)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "IPRVkgM8dvB3", + "outputId": "8f71ea44-fb3a-4583-bcac-5f1d69d30d7c" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "0\n", + "1\n", + "2\n", + "3\n", + "4\n", + "5\n", + "6\n", + "7\n", + "8\n", + "9\n", + "10\n", + "The loop stops at 10\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "##Pass\n", + "\n", + "In python when statement is required , but we don't like to execute" + ], + "metadata": { + "id": "B6t0kxRIfaRq" + } + }, + { + "cell_type": "code", + "source": [ + "text=[\"sanskrit\",\"hindi\",\"urdhu\",\"devnagri\",\"odia\"]\n", + "for i in text:\n", + " pass" + ], + "metadata": { + "id": "YtOQtuwYdvEH" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [], + "metadata": { + "id": "G8v7X03ndvIw" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file