# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# ### Ranges

for x in range(1,5):
    print(x)

x = list(range(1,5))
x


# +
def frange(start, stop, step=1.0):
    i = start
    while i < stop:
        yield i
        i += step
    
for i in frange(0.5, 1.0, 0.1):
    print(i) 
# -

# ### Comprehensions

y = [x for x in range(1,10) if x % 2 == 0]
y

y = [x in range(1,10)]
y

[[1 if col == row else 0 for col in range(0,3)] for row in range(0,3)]

# +
names = [ 'Bob', 'JOHN', 'alice', 'bob', 'ALICE', 'J', 'Bob' ]

{ name[0].upper() + name[1:].lower() if len(name) > 1 else name.upper() for name in names }

# +
mcase = {'a':10, 'b': 34, 'A': 7, 'Z':3}

mcase_frequency = { k.lower() : mcase.get(k.lower(), 0) + mcase.get(k.upper(), 0) for k in mcase.keys() }
mcase_frequency
# -

# ### Builtin Functions

list(filter(lambda e: e % 2 == 0, range(1,10)))

list(map(lambda e: e**2, [1,2,3,4,5]))

# !conda install -y scikit-learn

from sklearn import datasets
iris = datasets.load_iris()
digits = datasets.load_digits()



StarcoderdataJupyterScriptsDedupFiltered