Python chapter 1 What are the Operators & Control Structures/Statement in python

 



href="https://blogger.googleusercontent.com/img/a/AVvXsEi0SaRxwVxpipob-U6eJkzkvzkbNVlCpJ6sVb_pnZf-8KrC7PH7_rCDaMB42xd0q7CQkKfcxqNbD18XEnQejhjdcUvCS3MSzcEuqwwC1w-bbTwG8UDy4VWvMuZHzpnCigLAdkKqqjmI8GwBVEyZBcInLTeKCqM0dwZhRB6pQ-8DHUSEZ_Xd_l23Ovay=s320"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="181"
data-original-width="320"
src="https://blogger.googleusercontent.com/img/a/AVvXsEi0SaRxwVxpipob-U6eJkzkvzkbNVlCpJ6sVb_pnZf-8KrC7PH7_rCDaMB42xd0q7CQkKfcxqNbD18XEnQejhjdcUvCS3MSzcEuqwwC1w-bbTwG8UDy4VWvMuZHzpnCigLAdkKqqjmI8GwBVEyZBcInLTeKCqM0dwZhRB6pQ-8DHUSEZ_Xd_l23Ovay=s16000"
/>













>Hello everyone! Welcome back.......... >



>We are going to learn the python programming language, which is very useful
from the future point of view. >

 


> >Installation of Python on windows/Linux. > >




  • >For Windows- Download python from-  href="https://www.python.org/"
    target="_blank"
    >Download Python
    > >


  • >For Linux- Python is already installed on Linux. >


> After installing Python: >




  • >We will install an Anaconda navigator, you can use the different tools
    also like pycharm and vs code. >


  • >Download and install anaconda for windows/Linux-  href="https://www.anaconda.com/products/individual"
    target="_blank"
    >www.anaconda.com
    > >





>After this installation open anaconda navigator and select jupyter
notebook >






href="https://blogger.googleusercontent.com/img/a/AVvXsEhVQUm4c2Sz6_dHI0zJXP06EpIHhQMhbLaOTByNyUU7GLOXeE-nv23gDcLC4zoZnXMSTOIaTdOtwZ0HbHWUXOWcQGknviGEJKHQfICqK1tr72xlE_u22RwwlvOGpcPFMcCkdhNIUVsx15X7QPubKtgmj5O6fMfMlB2oA1SWhV2fRilwV3srixEdxj7N=s320"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="128"
data-original-width="320"
height="128"
src="https://blogger.googleusercontent.com/img/a/AVvXsEhVQUm4c2Sz6_dHI0zJXP06EpIHhQMhbLaOTByNyUU7GLOXeE-nv23gDcLC4zoZnXMSTOIaTdOtwZ0HbHWUXOWcQGknviGEJKHQfICqK1tr72xlE_u22RwwlvOGpcPFMcCkdhNIUVsx15X7QPubKtgmj5O6fMfMlB2oA1SWhV2fRilwV3srixEdxj7N"
width="320"
/>



Just click on python 3 as a new file


So let's get started.


Course content:





  • >Arithmetic Operators. >


  • >Relational Operators. >


  • Logical Operators.


  • >User input and output >


  • Control structure.



>What are the operators and expressions? >




  • >A simple example of an expression is 2+3. >


  • > >Most statements (logical lines) that you write will contain an
    expression.
    >



  • > >An expression can be broken down into operators and operands. >




  • Operators are functions that do something and can be represented by
    symbols such as "+" or particular keywords.




  • Operators require some data to operate on, and such data is called
    operands.




Arithmetic Operators:





  • ( plus +)- Adds two objects.



  • ( minus -)Gives the subtraction of one number from the other; If the
    first operand is absent, it is considered zero.




  • ( multiply *)- Gives the multiplication of two numbers or can return the
    string multiple times.



  • >( power **)- Returns x to the power of y. >


  • ( divide /)- divide x by y.


  • >( floor division //)- Returns the integer parts of the quotient. >


  • >( modulo %)- Returns the remainder of the division. >



> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1iaUfFAn2RHpc9LKOySsO6Xf-UUFSYDdHWgYJdQC75mYJU73JFvDJsRD4zjZ8PthrapfKJZr-m0wXAdTh9ca_i_t4tj5C1BtLG-D-YsVpdgyt79T5Nwsk3PVGfLX1Xg5J_UQvl2uiAeo/s1041/Screenshot-_148_.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="521"
data-original-width="1041"
height="160"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1iaUfFAn2RHpc9LKOySsO6Xf-UUFSYDdHWgYJdQC75mYJU73JFvDJsRD4zjZ8PthrapfKJZr-m0wXAdTh9ca_i_t4tj5C1BtLG-D-YsVpdgyt79T5Nwsk3PVGfLX1Xg5J_UQvl2uiAeo/s320/Screenshot-_148_.webp"
width="320"
/>





> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkUiKZAuTMJuA_6IIaLYnF2i2OeAFOyOF-A6bv7-R5wxSBNmpZuVqwPHv6ZFxZeDaoPI_AVmQo5CPDbAEx7XZkVqQ2sTMODTdFYOVOYvEvd_oe8z8-hDmhyphenhyphenVc9d35VMWo90CXU_YWTUqw/s746/Screenshot-_147_.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="519"
data-original-width="746"
height="223"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkUiKZAuTMJuA_6IIaLYnF2i2OeAFOyOF-A6bv7-R5wxSBNmpZuVqwPHv6ZFxZeDaoPI_AVmQo5CPDbAEx7XZkVqQ2sTMODTdFYOVOYvEvd_oe8z8-hDmhyphenhyphenVc9d35VMWo90CXU_YWTUqw/s320/Screenshot-_147_.webp"
width="320"
/>





Relational Operators:






  • ( less than <)- Returns whether x is less than y. All comparison
    operators return True and
    False.




  • Note - Capitalization of these names (
    True and False ). Comparison can be
    chained arbitrarily.



  • >( grater than >)- Returns whether x is more significant than
    y. >



  • ( less than or equal to <=)- Returns whether x is less than or equal
    to y.




  • ( greater than or equal to >=)- Returns whether x is greater than or
    equal to y.



  • >( equal to = = )- Compares if the objects are equal. >


  • >( not equal to !=)- Compares if the objects are not equal. >



> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBNu0I7WYa_8tU3547rT1S30pE9RYEZaEXd-16bwGfh_rpHdFChhszHLgK5RMiQa2I7Zow0dLJFyrEORwdMUqP9zfEn-eDzvLCm9uApep0keULp8ccY90eW7J-17D_rC_JA55SevAVWfQ/s1029/Screenshot-_151_.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="527"
data-original-width="1029"
height="164"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBNu0I7WYa_8tU3547rT1S30pE9RYEZaEXd-16bwGfh_rpHdFChhszHLgK5RMiQa2I7Zow0dLJFyrEORwdMUqP9zfEn-eDzvLCm9uApep0keULp8ccY90eW7J-17D_rC_JA55SevAVWfQ/s320/Screenshot-_151_.webp"
width="320"
/>





> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinA72BxMexLF7TyX3AnKBBXklXHwwvAIefEHlpJ99YvKFRpQyhijwdD2pWjTqt7TssN4VHclpL2FPL9ED2lH-Wow6HaiMdHz3aSwxpI6gpZuvr-0h_0fn2-W0A6NoghsGbupQc24zkysM/s583/Screenshot-_152_.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="240"
data-original-width="583"
height="132"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinA72BxMexLF7TyX3AnKBBXklXHwwvAIefEHlpJ99YvKFRpQyhijwdD2pWjTqt7TssN4VHclpL2FPL9ED2lH-Wow6HaiMdHz3aSwxpI6gpZuvr-0h_0fn2-W0A6NoghsGbupQc24zkysM/s320/Screenshot-_152_.webp"
width="320"
/>





Logical Operators:






  • not ( boolean not)- If x is
    True it returns
    False. If x is
    False it returns
    True.




  • or ( boolean or)- If x is > True, >
    it returns True, else it
    returns the evaluation of y.




  • and ( boolean and)- x and y return
    false, else it returns the
    evaluation of y.





> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT-_3IjWQrV21r7seIiDGW64Cqz4qzH7jisMgxyYzZLU1pXEiHVq8aCkJARZCWKaf523PPLy7DaHd_g3fUSjcUUBpH6IDg-L14BERrPGUODjKoag-DH_aXvJh1XHSYUVtNvIMkPPLvbiY/s1029/Screenshot-_154_.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="526"
data-original-width="1029"
height="164"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT-_3IjWQrV21r7seIiDGW64Cqz4qzH7jisMgxyYzZLU1pXEiHVq8aCkJARZCWKaf523PPLy7DaHd_g3fUSjcUUBpH6IDg-L14BERrPGUODjKoag-DH_aXvJh1XHSYUVtNvIMkPPLvbiY/w320-h164/Screenshot-_154_.webp"
width="320"
/>


>
User input and output:







  • This is a specific topic and easy to understand. Just see the below
    example.




> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNdk7avHLo_v8FQcD9krGN-Cli9CHO7pqLnnWRiDXHAW933OaBiFES_hbhGOpFIhgi0CWUkuUyJz_AyHqO8D-y89AQxZQdUsLgwr5ZJpXXfIDUuoqViecf0yBY2uuHQKIkoghh4zGfCMs/s1110/Screenshot-_156_.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="348"
data-original-width="1110"
height="100"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNdk7avHLo_v8FQcD9krGN-Cli9CHO7pqLnnWRiDXHAW933OaBiFES_hbhGOpFIhgi0CWUkuUyJz_AyHqO8D-y89AQxZQdUsLgwr5ZJpXXfIDUuoqViecf0yBY2uuHQKIkoghh4zGfCMs/s320/Screenshot-_156_.webp"
width="320"
/>





Control Statements :



> >This topic is vast, so be careful. > >


Control Statements




  • Conditional Statements



  1. If statement

  2. If ------ else statement

  3. If ------ elif statement




  • Looping Statements



  1. For loop

  2. While loop




  • Loop Control Statements



  1. Break Statement

  2. Continue Statement

  3. Pass Statement



Conditional Statements:





  • Decision-making is the anticipation of conditions occurring while
    executing the program and specifying actions taken according to the
    conditions.




  • Decision structures evaluate multiple expressions which produce
    True or
    False as the outcome. We need to
    determine which action to take and which statements to execute if the
    outcome is True or
    False otherwise.




  • The general form of a typical decision-making structure found in most
    of the programming languages is given here. 




  • Python programming language assumes any non-zero and non-null values
    as True, and if it is either zero
    or null, then it is assumed as
    False value.




> >Conditional Statements : " if "  > >






  • An if statement consists of a Boolean expression followed by one or
    more statements.




  • It is similar to that of other languages. The if statement contains a
    logical expression using which data are compared, and a decision is
    made based on the comparison result. 




  • If the Boolean expression evaluates to True, then the block of a
    statement(s) inside the if statement is executed. If the Boolean
    expression evaluates to False, then the first code set after the end
    of the if statement(s) is executed.




> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghcNkkCk-m7Cbf_urP05BM2GDf93w2mKFKAaN1HH0gi8h8shv1VGtfiPv3i6Hybf0JO2WDpCL137lysWEl4eLd2V8XiYGySwESh7VkO-Po3xvJTGaJWZKEnwLcEKVz-aucz3rxlHre3p0/s1284/Screenshot-_163_.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="521"
data-original-width="1284"
height="130"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghcNkkCk-m7Cbf_urP05BM2GDf93w2mKFKAaN1HH0gi8h8shv1VGtfiPv3i6Hybf0JO2WDpCL137lysWEl4eLd2V8XiYGySwESh7VkO-Po3xvJTGaJWZKEnwLcEKVz-aucz3rxlHre3p0/s320/Screenshot-_163_.webp"
width="320"
/>





> >Conditional Statements : " if " , "else" > >







  • An if statement can be followed by an optional statement, which executes
    when the Boolean expression is False. 




  • An else statement can be combined with an if statement. An else
    statement contains the block of code that executes if the conditional
    expression in the if statement resolves to 0 or a False value.




  • The else statement is an optional statement, and there could be only one
    else statement following if. 




> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsKvLiAW1ezGNdMhpbnnEeF5-enumB_crBoe-6vbN80I5noEvIxsLCZURnGwWnyISCQ-eXj8hdTTN_E-Ws5uWeywNNWvaupMNE2kTOHKYHnpJnAGfBm93x001UvgHVuXN1yxqQ-y8lqV8/s1237/Screenshot-_171_.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="518"
data-original-width="1237"
height="134"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsKvLiAW1ezGNdMhpbnnEeF5-enumB_crBoe-6vbN80I5noEvIxsLCZURnGwWnyISCQ-eXj8hdTTN_E-Ws5uWeywNNWvaupMNE2kTOHKYHnpJnAGfBm93x001UvgHVuXN1yxqQ-y8lqV8/s320/Screenshot-_171_.webp"
width="320"
/>





> >Conditional Statements : " if " , "elif" > >






  • The elif statement allows one to check multiple expressions for True and
    execute a block of code as soon as one of the conditions evaluates to
    True. 




  • Similar to the else, the elif statement is optional. However, there can
    be at most one statement; there can be an arbitrary number of elif
    statements following an if. 




  • Core Python does not provide a switch or case statements like other
    languages, but we can use if...elif statements to simulate switch cases.




> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghjG8Pc2JY_DYbGJOvdVoO6cpQKSbq4tcYsBnAX74oJY9nk7C0vfzZW0Yxg1Zqvdu0ZOI1gSfzGUoWQgZrghBrHYfedo41PXTLJL671O_Iv7rn9CWTMruz-w9gvsn4nuK7LD6mYdtl3Mk/s1204/Screenshot-_174_.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="517"
data-original-width="1204"
height="137"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghjG8Pc2JY_DYbGJOvdVoO6cpQKSbq4tcYsBnAX74oJY9nk7C0vfzZW0Yxg1Zqvdu0ZOI1gSfzGUoWQgZrghBrHYfedo41PXTLJL671O_Iv7rn9CWTMruz-w9gvsn4nuK7LD6mYdtl3Mk/s320/Screenshot-_174_.webp"
width="320"
/>





Looping Statement






  • In general, statements are executed sequentially. The first statement in
    a program is executed first, followed by the second, and so on. There
    may be a situation when one needs to execute a block of code several
    times.




  • Python Programming language provides various control structures that
    allow for more complicated execution paths.




  • A loop statement allows us to execute a statement or group of statements
    multiple times. 




> >Looping Statement: " While " and  " Infinite" > >


> async=""
crossorigin="anonymous"
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9869442004118280"
>
class="adsbygoogle"
data-ad-client="ca-pub-9869442004118280"
data-ad-format="auto"
data-ad-slot="3195394695"
data-full-width-responsive="true"
style="display: block;"
>






  •  A while loop statement in Python programming language repeatedly
    executes a target statement as long as a given condition is
    True.




  •  Here, statement(s) may be a single statement, or a block of
    statements. The condition may be any expression, and
    True is any non-zero value.




  • The loop iterates while the condition is
    True. When the condition becomes
    False, program control passes
    to the line immediately following the loop. 




  • In Python, all the statements indented by the same number of character
    spaces after the programming construct are considered part of a
    single block of code. Python uses indentation as its method of
    grouping statements.



  • >The critical point of the while loop is that the loop might not ever
    run. When the condition is tested and the result is
    False, the loop body will be
    skipped,       and the first statement after
    the while loop will be executed.




  • A loop becomes an infinite loop if a condition never becomes
    False. One must use caution when
    using while loops because of the possibility that a given condition
    never resolves to a False value.




  • This results in a loop that never ends. Such a loop is called an
    infinite loop. An infinite loop might be helpful in client/server
    programming, where the server needs to run continuously so that client
    programs can communicate with it as and when required.




> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMcOtVUheLeE5sNwwyuYbD_boUTTZgHrQnHqQgQoRHSojA4EMPkUe9TGrwNk6wdpy8E2lsMEC7_zI4j_R4NQyDPN5KVbb8XFVgQk7maA6SRewGPgEI4ppkjncwQ9eYdPTBe8IzKw5CfGc/s1178/Screenshot-_180_.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="536"
data-original-width="1178"
height="146"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMcOtVUheLeE5sNwwyuYbD_boUTTZgHrQnHqQgQoRHSojA4EMPkUe9TGrwNk6wdpy8E2lsMEC7_zI4j_R4NQyDPN5KVbb8XFVgQk7maA6SRewGPgEI4ppkjncwQ9eYdPTBe8IzKw5CfGc/s320/Screenshot-_180_.webp"
width="320"
/>





Looping Statement: " For "






  • Executes a sequence of statements multiple times and abbreviates the
    code that manages the loop variable.




  • It can iterate over the items of any sequence, such as a list or a
    string. If a sequence contains an expression list, it is evaluated
    first. Then, the first item in the sequence is assigned to the iterating
    variable iterating_var. Next, the statements block is executed.




  • Each item in the list is assigned to iterating_var, and the statement(s)
    block is executed until the entire sequence is exhausted.




> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicTjr-5AKxQmePJELwUB6oIQTbnELBY0O8HBNjHYveQqUxtQefXIc8LIk_-n2ABRGlOUZGHahyphenhyphentMVxfEhnZ27Jsvul2R8-Dg0nqakjWhQkViM8Owvafb6BrSNffXiAyrzbssEUuAVxCEA/s1242/Screenshot-_183_.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="503"
data-original-width="1242"
height="130"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicTjr-5AKxQmePJELwUB6oIQTbnELBY0O8HBNjHYveQqUxtQefXIc8LIk_-n2ABRGlOUZGHahyphenhyphentMVxfEhnZ27Jsvul2R8-Dg0nqakjWhQkViM8Owvafb6BrSNffXiAyrzbssEUuAVxCEA/s320/Screenshot-_183_.webp"
width="320"
/>



Nested Loops:





  • >One can use one or more loops inside any other for or while loop. >



  • Python programming language allows using one loop inside another loop.




> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqcYonYvW1ufH6j40QrKQD4kPKd6xouCq4JiHlVPJICV0pI__IRI-zzncpCX-eR8fANltu5s-enMKQFDlzNm2HOA2APMbf-thUDrgPwIYbvZQ8qmFAJ6BQpQJ6i8ifGLw5IJZbAEECTYw/s1185/Screenshot-_185_.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="540"
data-original-width="1185"
height="146"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqcYonYvW1ufH6j40QrKQD4kPKd6xouCq4JiHlVPJICV0pI__IRI-zzncpCX-eR8fANltu5s-enMKQFDlzNm2HOA2APMbf-thUDrgPwIYbvZQ8qmFAJ6BQpQJ6i8ifGLw5IJZbAEECTYw/s320/Screenshot-_185_.webp"
width="320"
/>





> >Looping Control Statement: "break." > >






  • Terminates the loop statement and transfers execution to the statement
    immediately following the loop. 




  • The most common use for a break is when some external condition is
    triggered, requiring a hasty exit from a loop.



  • >The break statement can be used in both whiles and for
    loops.  >



  • If we are using nested loops, the break statement stops the execution of
    the innermost loop and starts executing the following line of code after
    the block.




> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqwAAvdqFNICSRxrjwjzEbw5lBMeiN8MxpBEdhQdpwTGeN2cWoBKXNrkc5YiKsqpK3Qf3SlaDlqgZMOMjpmzovlSIlmTzpVuBS0kjWcrchKbwnvsBAHZHqSTbeGxOnuEQjUlFEckiRqFY/s1222/Screenshot+%2528188%2529.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="423"
data-original-width="1222"
height="111"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqwAAvdqFNICSRxrjwjzEbw5lBMeiN8MxpBEdhQdpwTGeN2cWoBKXNrkc5YiKsqpK3Qf3SlaDlqgZMOMjpmzovlSIlmTzpVuBS0kjWcrchKbwnvsBAHZHqSTbeGxOnuEQjUlFEckiRqFY/s320/Screenshot+%2528188%2529.webp"
width="320"
/>





Continous while loop:






  • With indefinite iteration, the number of times the loop is executed
    isn't specified explicitly in advance.





  • Instead, the designated block is executed repeatedly as long as some
    condition is met.




  • In the example given, the while loop will continuously execute until the
    user enters 0.



  • >Here condition may be either True or any. >






href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9zCTmC5bU2AP3I8lPhD9gpdttA76BSjTY2BTgFJlP7W30zQ1blK9b0If4tPxaJlHJ3jMlazdCLAelGB739YxF1J9PPJwFkWhiQ8Fb1ucNzD6Ga_ujFICDmb33bwqeAG3ByOFxI56H0LE/s1113/Screenshot+%2528192%2529.webp"
style="margin-left: 1em; margin-right: 1em;"
> > border="0"
data-original-height="292"
data-original-width="1113"
height="84"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9zCTmC5bU2AP3I8lPhD9gpdttA76BSjTY2BTgFJlP7W30zQ1blK9b0If4tPxaJlHJ3jMlazdCLAelGB739YxF1J9PPJwFkWhiQ8Fb1ucNzD6Ga_ujFICDmb33bwqeAG3ByOFxI56H0LE/s320/Screenshot+%2528192%2529.webp"
width="320" /> >




> >Looping Control Statement: "continue" > >





  • Causes the loop to skip the remainder of its body and immediately retest
    its condition before reiterating.




  • It returns the control to the beginning of the loop. The continue
    statement rejects all the remaining statements in the current loop
    iteration and moves the control back to the top of the loop.



  • >The continue statement can be used in both whiles and for loops. >



> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwFXxWT9Tpp5GwEyKx7uOnL0RjZaG-BXIiUbWaWjN7ZehXv2vhKL3WyNcLqprKY7nHsdiZbAsoULwPUxyIf2ZJkB6RupL1TdbCHDcrwwHAjBIyuuD1B2a7aCdzINpkubSDY361qH04lbs/s1209/Screenshot+%2528195%2529.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="497"
data-original-width="1209"
height="132"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwFXxWT9Tpp5GwEyKx7uOnL0RjZaG-BXIiUbWaWjN7ZehXv2vhKL3WyNcLqprKY7nHsdiZbAsoULwPUxyIf2ZJkB6RupL1TdbCHDcrwwHAjBIyuuD1B2a7aCdzINpkubSDY361qH04lbs/s320/Screenshot+%2528195%2529.webp"
width="320"
/>





> >Looping Control Statement: "pass." > >






  • The pass statement in Python is used when a statement is
    required syntactically, but you do not want any command or
    code to execute. The pass statement is a null operation;
    nothing happens when it executes.




  • The pass is also helpful in places where our code will eventually
    go but has not been written yet (e.g., in stubs, for example) >. >





> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfIE3887RL6r6DhsueCFGgwH9rCqPkCSVS4f-qWbjuP1VdKran2zhjDWx2OGAxEznLTZ6tSNgH7tdl7Gf_ZImfootsMTCG2RXdLoybIb1Ta8h8ywJcogaoKc0s1hUDK_7cb46tEpxcnrE/s980/Screenshot+%2528198%2529.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="317"
data-original-width="980"
height="104"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfIE3887RL6r6DhsueCFGgwH9rCqPkCSVS4f-qWbjuP1VdKran2zhjDWx2OGAxEznLTZ6tSNgH7tdl7Gf_ZImfootsMTCG2RXdLoybIb1Ta8h8ywJcogaoKc0s1hUDK_7cb46tEpxcnrE/s320/Screenshot+%2528198%2529.webp"
width="320"
/>


>
Using else statement with loops:







  • Python supports have an else statement associated with a loop statement.




  • If the else statement is used with a for loop, the else statement is
    executed when the loop has exhausted iterating the list. 




  • If the else statement is used with a while loop, the else statement is
    executed when the condition becomes false.




  • If it encounters the break command in the loop, the other part will not
    be called.




  • If it does not encounter the break command in the loop, the other part
    will be called.




> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9npJNPpfaV4g0BvWs3ZgVpv5DcKziRAd_4oaBSkLBW4fRT8gk1POuDTXvQ9j4uCgfA8-EK3FtWCI4Qgm-8q8g3iCuWQy9uhfDS6i4p20xouA5r__iiqlJUbaXjkOo4Yg5KQ_0_E5PI6o/s1132/Screenshot+%2528202%2529.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="504"
data-original-width="1132"
height="142"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9npJNPpfaV4g0BvWs3ZgVpv5DcKziRAd_4oaBSkLBW4fRT8gk1POuDTXvQ9j4uCgfA8-EK3FtWCI4Qgm-8q8g3iCuWQy9uhfDS6i4p20xouA5r__iiqlJUbaXjkOo4Yg5KQ_0_E5PI6o/s320/Screenshot+%2528202%2529.webp"
width="320"
/>





> href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9X9UaMunT68-lo_DKQe2sD_-R648U0W7KrMco674af0JIfq9JMVAy2kBAMLfANof39weMV7ui6s_snP1WjX9lVHV5E5De4qo4tZBRx0x3wQmOcgqvgScuBMuw1HqJU4Dp3TGAKocEtpA/s1259/Screenshot+%2528203%2529.webp"
style="margin-left: 1em; margin-right: 1em;"
> border="0"
data-original-height="494"
data-original-width="1259"
height="126"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9X9UaMunT68-lo_DKQe2sD_-R648U0W7KrMco674af0JIfq9JMVAy2kBAMLfANof39weMV7ui6s_snP1WjX9lVHV5E5De4qo4tZBRx0x3wQmOcgqvgScuBMuw1HqJU4Dp3TGAKocEtpA/s320/Screenshot+%2528203%2529.webp"
width="320"
/>










> >Just do practice on all operators and control statements. If you face any
difficulty, then comment below. >
>


> >We will meet in the next chapter. > >


See you soon.


THANK YOU!



async=""
crossorigin="anonymous"
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9869442004118280"
>
class="adsbygoogle"
data-ad-client="ca-pub-9869442004118280"
data-ad-format="auto"
data-ad-slot="3195394695"
data-full-width-responsive="true"
style="display: block;"
>

Comments