<jupyter_start><jupyter_text>Looping<jupyter_code>for number in [2, 3 ,5]:
    print(number)
letter = ""
for letter in "abc":
    print(letter)
letter
primes = [2, 3, 5]
for p in primes:
    squared = p**2
    cubed = p**3
    print(p, squared, cubed)
for n in range(0, 3):
    print(n)
print(n)
mass = 3.45
if mass > 3.0:
    print(mass, 'is large')
else:
    print(mass, 'is small')
masses = [3.54, 2.07, 9.222, 1.86, 1.71]
for m in masses:
    if m > 3.0:
        print(m, 'is large')
    else:
        print(m, 'is small')
masses = [3.54, 2.07, 9.222, 1.86, 1.71]
for m in masses:
    if m > 9.0:
        print(m, 'is huge')
    elif m > 3.0:
        print(m, 'is large')
    else:
        print(m, 'is small')
type(m > 9.0)
True
4 > 3
4 < 3
True or False
True or True
False or False
True and False
a = 5
a < 3
a > 4
a < 3 or a > 4
def print_greeting():
    print("Hello!")
print_greeting()
import numpy as np
np.mean([1, 2, 3, 4])
def print_date(year, month, day):
    joined = str(year) + '/' + str(month) + '/' + str(day)
    print(joined)
print_date(1871, 3, 19)
def average(values):
    if len(values) == 0:
        return None
    return sum(values) / len(values)
average([1, 2, 3, 4])
average([])
len([])
for m in masses:
    pass
def average(values):
    """Computes average of values.
    
    If values is an empty collection, returns None.
    """
    if len(values) == 0:
        return None
    return sum(values) / len(values)
help(average)
def first_negative(values):
    """Returns the first item in values that is negative,
    or None if all values are positive."""
    for v in values:
        if v < 0:
            return v
    return None
assert first_negative([4, -5, 3]) == -5
assert first_negative([1, 2, 3]) == None
assert first_negative([]) == None
assert first_negative([-3, 0, -1]) == -3
x = 3
x == 3
def all_negatives(values):
    negatives = []
    for v in values:
        if v < 0:
            negatives.append(v)
    return negatives
all_negatives([-3, 0, -1])
[v for v in values if v < 0]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1517509727626459, 'fraction_numerical': 0.048638132295719845, 'mean_word_length': 2.6278659611992947, 'pattern_counts': {'":': 1, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '208279', 'license': 'Apache-2.0', 'n_tokens_mistral': 844, 'n_tokens_neox': 780, 'n_words': 267, 'path': 'Control.ipynb', 'repo_name': 'jhidding/20200916-pbl-notebooks', 'size': '2056'}