In [3]:
def count_odd(lst: list[int]) -> int:
    """Return the number of odd integers in the 
    list lst using recursion"""
    # Base case: empty list has 0 odd numbers
    if len(lst) == 0:
        return 0
    if lst[0] % 2 == 1:
        return 1 + count_odd(lst[1:])
    else:
        return 0 + count_odd(lst[1:])

# Example 
print(count_odd([1, 2, 3, 4, 5]))  
print(count_odd([2, 4, 6]))  
3
0
In [12]:
import csv
import numpy as np
import matplotlib.pyplot as plt

with open("plot_me.csv") as ifh:
    inCSV = csv.DictReader(ifh)
    x_lst = []
    y_lst = []
    for line in inCSV:
        x_lst.append(float(line["X"]))
        y_lst.append(float(line["Y"]))
    
    x_arr = np.array(x_lst)
    y_arr = np.array(y_lst)
    
    mask = (x_arr >= 0.0) & (x_arr <= 10.0)
    
    plt.plot(x_arr[mask], y_arr[mask], "co")
    plt.xlabel("x values")
    plt.ylabel("y value")
    plt.show()
In [6]:
class Counter: 
    """
    Stores a value and a step as integers and will
    allow a countdown from the value with a label
    """
    value: int
    step: int
    label: str
    
    def __init__(self, value: int, step: int, label: str) -> None:
        self.value = value
        self.step = step
        self.label = label
        
    def countdown(self) -> None:
        if self.value < 0:
            return None
        else:
            print(f"{self.label}: {self.value}")
            self.value -= self.step
            return self.countdown()
        
Counter(5, 1, "Launch").countdown()
Launch: 5
Launch: 4
Launch: 3
Launch: 2
Launch: 1
Launch: 0
In [ ]: