The Fibonacci Sequence is the series of numbers:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
The next number is found by adding up the two numbers before it.
Iteration means executing the same block of code over and over, potentially many times. A programming structure that implements iteration is called a loop.
Python, in general, processes commands from top to bottom.
All control structures in Python use indentation to define blocks.
Think of a variable as a name attached to a particular object. To create a variable, you just assign it a value and then start using it. Assignment is done with a single equals sign (=):
t = 17 # This is read or interpreted as “t is assigned the value 17.”
print(t)
t = 27 # if you change the value of n and use it again, the new value will be substituted instead.
print(t)
s = 11
print(s)
s = 99
print(s)
a = 0
b = 1
print(a)
m = 77 # This assignment creates an integer object with the value 77.
type (m)
m1 = 77.7
type (m1)
i = 1
while i < 6:
print(i)
i += 1
n = 7
while n > 0:
n -=1
print(n)
n = 7
while n > 0:
print(n)
n -= 1
Tuples are defined by enclosing the elements in parentheses (( )) instead of square brackets ([ ]).
a, b = 0, 1
print(a)
type(a)
type((a,b))
a = 0
b = 1
while a<2:
print(a)
a, b = b, a+b
# Fibonacci Sequencce
a = 0
b = 1
while a < 100:
print(a)
a, b = b, a+b
a, b = 0, 1
while a < 100:
print(a)
a = b
b = a+b
a = 0
b = 1
while a < 1000000:
print(a)
a, b = b, a+b