a, b = 0, 5
while a < b:
    print(a)
    a += 1

"""
Explanation: Python Logic and Control Flow
This notebook introduces Python control flow.
While
Like most programming languages Python includes a while loop. The loop executes for as long as the condition remains true.
python
a, b = 0, 5
while a &lt; b:
    print(a)
    a += 1
End of explanation
"""


a, b = 0, 5
while a < b:
    print(a)
    a += 1 
else:
    print('loop over')

"""
Explanation: Unlike most other programming languages however Python adds an else clause to the while loop. This takes the form:
python
a, b = 0, 5
while a &lt; b:
    print(a)
    a += 1 
else:
    print('loop over')
End of explanation
"""


a, b = 0, 5
while a < b:
    print(a)
    a += 1 
    if a > 3:
        break
else:
    print('loop over')

"""
Explanation: Note that when the loop is exited via a break clause the else clause will not be executed.
End of explanation
"""


x = int(input("Please enter an integer: "))
if x == 42:
    print('That is the answer')

"""
Explanation: If
The if statement allows the programmer to control program flow based on a boolean condition. For example:
python
x = int(input("Please enter an integer: "))
if x == 42:
    print('That is the answer!')
End of explanation
"""


x = int(input("Is this a 5 or a 30 minute argument?"))
if x == 5:
    print('That will be five pounds please')
elif x == 30:
    print('That will be ten pounds please')
else:
    print('Sorry I can only offer 5 or 30 minutes')

"""
Explanation: You can also provide an else clause that will be executed if the statement is not true:
python
x = int(input("Please enter an integer: "))
if x == 42:
    print('That is the answer!')
else:
    print('Wrong')
You can also chain together several conditions using another condition chained on to the else. Python supports this directly with the elif clause:
python
x = int(input("Is this a 5 or a 30 minute argument?"))
if x == 5:
    print('That will be five pounds please')
elif x == 30:
    print('That will be ten pounds please')
else:
    print('Sorry I can only offer 5 or 30 minutes')
End of explanation
"""


print(range(5))

"""
Explanation: For
Unlike other programming languages Python's for loop iterates over a sequence rather than an arthimetic progression.
For example in C++ we might have:
C
for (int i = 0; i &lt; limit; ++i)
{
   ...
}
In Python we would have:
python
for i in range(limit):
   ...
Here range is a function that returns a sequence of numbers, in the example above the sequence goes from 0 to limit - 1.
the range function accepts multiple arguments, for example:
python
range(5)        # the sequence 0 to 5
range(1, 5)     # the sequence 1 to 5
range(1, 10, 3) # the sequence 1, 4, 7
Finally note that range is an interesting function, try printing it below.
End of explanation
"""


tup = 3, 7
print(max(*tup))

"""
Explanation: range does not return the sequence directly, instead it returns an iterable that can be repeatedly called to get the next item in the sequence. This lazy evaluation allows you to use a very big sequence without the cost of creating all the items at once.
Python Tuple Unpacking
Tuples can be upacked:
python
tup = 1, 2
a, b = tup
Tuple unpacking can also be used for function calls:
python
tup = 3, 7
print(max(*tup))
End of explanation
"""


tup = 3, 7, 4, 1, 2
print(max(*tup[2:4]))

"""
Explanation: We can also unpack using wild cards:
python
tup = 1, 2, 3, 4
a, b, * = tup
This can also be done in the middle:
python
tup = 1, 2, 3, 4
a, *, b = tup
By convention if we want to disregard we use the underscore:
python
tup = 1, 2, 3, 4
a, _, _, b = tup
It is also possible to use a slice:
python
tup = 3, 7, 4, 1, 2
print(max(*tup[2:4]))
End of explanation
"""


