# # Fibonacci numbers module
# def fib(n):     # write Fibonacci series up to n
#     a, b = 0, 1
#     while a < n:
#         print(a, end=' ')   # end=' ' appends space instead of newline
#         a, b = b, a+b
#     print()


# def fib2(n):    # return Fibonacci series up to n
#     result = []
#     a, b = 0, 1
#     while a < n:
#         result.append(a)
#         a, b = b, a+b
#     return result

# def fib3():    # return Fibonacci series up to n
#     result = ""
#     # a, b = 0, 1
#     # while a < n:
#     #     result.append(a)
#     #     a, b = b, a+b
#     return "result"


# (NOTE: run in interpreter)
# python
# import fibo_module
# fibo_module.fib(100)
    # 0 1 1 2 3 5 8 13 21 34 55 89

# fibo_module.fib2(100)
    # [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]

# fibo_module.__name__
    # 'fibo_module'

# (NOTE: assigning a function to a local name; for often use)
# fib = fibo_module.fib
# fib(1000)
    # 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987

#############################################################
# (NOTE: imports names from a module directly into the importing module’s symbol table)

# from fibo_module import fib, fib2
# (OR)
# from fibo_module import *
# (then,)
# fib(100)
    # 0 1 1 2 3 5 8 13 21 34 55 89

# (OR)
# from fibo_module import fib as fibonacci
# fibonacci(100)
    # 0 1 1 2 3 5 8 13 21 34 55 89

#############################################################

# import fibo_module as fibo
# fibo.fib(100)
    # 0 1 1 2 3 5 8 13 21 34 55 89

#############################################################
# (NOTE: To make the file usable as a script as well as an importable module)
# (NOTE: PYTHON INTERPRETER)

# if __name__ == "__main__":
#     import sys
#     fib(int(sys.argv[1]))

# (NOTE: COMPILER)

# python fibo.py 100
    # 0 1 1 2 3 5 8 13 21 34 55 89

#############################################################
# 'random' module

import random
print(random.randint(0, 5))



import random
print(random.random() * 100)



import random
myList = [2, 109, False, 10, "Lorem", 482, "Ipsum"]
print(random.choice(myList))


from random import shuffle
x = [[i] for i in range(10)]
print(shuffle(x))


import random
for i in range(3):
    print(random.randrange(0, 101, 5))


############################
# 'random' module


import random
import itertools

outcomes = { 'heads':0,
             'tails':0,
             }
sides = outcomes.keys()

for i in range(10000):
    outcomes[ random.choice(sides) ] += 1

print('Heads:', outcomes['heads'])
print('Tails:', outcomes['tails'])