MOBI BOOT CAMP CORP. logoLearning Buddy
  • SIGN IN
  • Introduction
  • Setup
  • 1A: Fundamental Building Blocks
  • 1B: Compound Statements
  • 2: Ordered Collection
  • 3: Unordered Collection
  • 4: More Data types
  • 5: Iteration Constructs
    • Loops
    • Zip operation
    • Quiz
    • Colab Exercise
  • 6: Other constructs
  • 7. Regex
  • 8. Date and Time
  • Revision
  • Practice Exercise
  • Titanic Workshop

Quiz

    <question >
        <p>What is the output of the given code? 
        <pre><code>while true:
print('a')
break

Error a Infinite loop true is not same as True. In Python boolean value is True with the uppercase T

    <question >
                <p>What is the output of the given code? <pre><code>while True:
print('a')

break

Error a Infinite loop break is not inside the while block and you get an infinite loop. As such you cannot have a 'break' outside of a loop. However even before the interpreter can find out about this problem, it is busy looping endlessly through the while loop which comes before the break

    <question>
           <p>What is the output of the given code?<pre><code>a = 0

while a < 10: a + 2 print(a)

10 12 Infinite Loop a+2 is not saved back to 'a'. So a's value never changed. If you replace a = a + 2 or a += 2 then it prints 10

Exercise

Privacy Policy | Terms & Conditions