Skip to content

Instantly share code, notes, and snippets.

@vicradon
Last active August 28, 2025 09:37
Show Gist options
  • Select an option

  • Save vicradon/5a8530545d63cc6037689c7a6143433a to your computer and use it in GitHub Desktop.

Select an option

Save vicradon/5a8530545d63cc6037689c7a6143433a to your computer and use it in GitHub Desktop.

Revisions

  1. vicradon revised this gist Aug 26, 2025. 4 changed files with 34 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions 0.1-where-python-runs.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    ## Where Python Runs

    Python runs in so many environments:

    1. On windows via the CMD, Powershell, or IDLE
    2. On anaconda via Jupyter Notebook or JupyterLab
    3. On Google Colab
    4. On Linux (default installed on Ubuntu)
    5. On macOS via Terminal or IDEs like PyCharm and VS Code
    6. On web browsers using platforms like Repl.it, Trinket, or Brython
    7. On mobile devices using apps like Pydroid (Android) or Pythonista (iOS)
    8. Embedded in other applications, for example as scripting in Blender, GIMP, or Autodesk Maya

    4 changes: 4 additions & 0 deletions 0.2-what-python-can-do.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    ## What Python can do


    <p style="font-size: 50; font-weight: bold">EVERYTHING</p>
    12 changes: 12 additions & 0 deletions 0.2.1-what-python-can-do.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    ## What Python can do

    1. Build data dashboards
    2. Build frontend applications
    3. Build backend applications
    4. Build AI models and workflows
    5. Build games
    6. Build reporting tools
    7. Compute the age of the earth
    8. Order your peppersoup

    etc
    5 changes: 5 additions & 0 deletions 0.3-but-python-is.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    ## But Python is

    <p style="font-size: 30; font-weight: bold">NOTHING WITHOUT YOU, THE PROGRAMMER</p>

    This is where you come in
  2. vicradon revised this gist Aug 24, 2025. 2 changed files with 19 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions 6.7-class-exercise-on-funcitons.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    Write a function that finds the min and max number in a list of numbers

    Your function should:

    1. Take several inputs as arguments find_min_max(arg1, arg2, arg3, …, argn)
    2. Finds the minimum and maximum number
    3. Returns both of them as a tuple (minimum, maximum)

    Write a few cases to verify that it works:
    [4, 7, 2, 9, 0, 3]
    [-9, -12, 38, 489, 38, 2, -2]
    [3903, 28, math.e, -90]
    7 changes: 7 additions & 0 deletions 6.7.1-class-exercise-on-functions.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    def find_min_max(*args):
    min_num = float("-inf") # smallest possible number in python
    max_num = float("inf") # largest possible number in python

    return (min_num, max_num)

    # TODO: write test cases and pass them to the function. Print the results
  3. vicradon revised this gist Aug 24, 2025. No changes.
  4. vicradon revised this gist Aug 24, 2025. 5 changed files with 36 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions 5.4-class-exercise-on-loops.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    ## Exercise 1 – Find an Account (for Loop)

    You are given a list of account numbers:

    ```py
    accounts = ["1234567890", "9876543210", "5555555555", "1111222233"]
    ```

    Task:
    1. Ask the user to enter an account number.
    2. Use a for loop to check if the account number exists in the list.
    3. If it exists, print "200 - Account found".
    4. Otherwise, print "404 - Account not found"
    7 changes: 7 additions & 0 deletions 5.4.1-class-exercise-on-loops.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    # Exercise 1 - For Loop
    accounts = ["1234567890", "9876543210", "5555555555", "1111222233"]

    account_to_search = input("Enter account number to search: ")

    # TODO: use a for loop to check if search_account is in accounts
    # Hint: loop through accounts and compare the `account_to_search` to the looped element
    11 changes: 11 additions & 0 deletions 5.5-class-exercise-on-loops-while-loop.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    ## Exercise 2 – Valid Account Number Input (While Loop)

    Banks only accept 10-digit numeric account numbers.

    Task:
    1. Ask the user to enter their account number.
    2. Keep asking until they provide a valid 10-digit number (all numbers, length 10).
    3. Once valid, print "Account number accepted".

    Goal:
    To practice using for loops to search lists, and while loops for input validation.
    5 changes: 5 additions & 0 deletions 5.5.1-class-exercise-on-loops.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    while True:
    account_number = input("Enter your 10-digit account number: ")

    # TODO: check that it is all digits and has length 10
    # If valid -> break loop, else keep asking
    File renamed without changes.
  5. vicradon revised this gist Aug 23, 2025. 8 changed files with 140 additions and 1 deletion.
    28 changes: 28 additions & 0 deletions 4.0-conditoinals-and-branching.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    ## Conditionals Branching within Programs

    You can define branching rules in your codebase using conditionals. So if a particular condition is true or false, it can determine if certains blocks/lines of code will be executed.

    Conditionals exist in many places, but are majorly implemented with if, elif, and else.

    ### Other places conditionals exist

    #### while loop, run once

    ```py
    """Run once example"""
    a = 3
    while a < 4:
    print("do something")
    a += 1
    ```

    #### while loop, infinite (run infinitely)

    ```py
    while True:
    print("Welp, it's over")
    ```




    54 changes: 54 additions & 0 deletions 4.1-conditionls-parts.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    """In this conditionals example, you collect the distance ran by a user and prints message to them.
    Ideally, you to guard against wrong input, since you are casting immediately to float (from string).
    You can replace line 15 with the try catch below to guard against wrong input (don't forget the "import sys")
    import sys
    try:
    distance = float(input("Enter distance run (in km): "))
    except:
    print("why did you enter a non-number?, sigh")
    sys.exit(1)
    """

    distance = float(input("Enter distance run (in km): "))
    MARATHON_DISTANCE = 42.195

    # simple if
    if distance >= 5:
    print("Yay, you ran at least 5K!")

    # if/else
    if distance < 1:
    print("That's basically a warm-up jog 😅")
    else:
    print("Nice effort!")

    # if/elif/else chain
    if distance < 5:
    print("Keep going, you'll reach 5K soon.")
    if distance < 10:
    print("Almost a quarter marathon!")
    elif distance < 22:
    print("Almost a half marathon!")
    elif distance < MARATHON_DISTANCE:
    print("You're close to a full marathon!")
    elif distance == MARATHON_DISTANCE:
    print("👏 Congrats, you completed a marathon!")
    else:
    print("You're god-level, you exceeded a marathon by", distance - MARATHON_DISTANCE, "km")

    # nested if
    if distance > 10:
    if distance < 15:
    print("You're in the 10-15km range, solid training ground!")
    elif distance < 20:
    print("You're in the 15-20km range, you're a strong one!")

    # logical operators
    if distance >= 5 and distance <= 10:
    print("That's a nice middle-distance run.")

    if distance == MARATHON_DISTANCE/2 or distance == MARATHON_DISTANCE/4:
    print("Exact amounts eh?")
    15 changes: 15 additions & 0 deletions 4.2-class-exercise-on-conditionals.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    Class Exercise on Conditionals

    ## Class Exercise on Conditionals

    Task: Write a program that:
    Asks the user for their exam score (0–100).
    Uses conditionals to print their grade:

    70 and above → "A"
    60–69 → "B"
    50–59 → "C"
    40–49 → "D"
    below 40 → "F"

    Goal: To help you learn how to branch logic with if/elif/else.
    4 changes: 4 additions & 0 deletions 4.2.1-conditionals-class-exercise-starting-point.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    score = int(input("Enter your exam score (0-100): "))

    # write your if/elif/else statements here

    3 changes: 2 additions & 1 deletion 5. loops intro.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    ## Loops Intro

    Notice how you needed to define `interest1`, `interest2`, and `interest3` manually? What if there was a way to write less code? That is where a for-loop comes in.
    In the collecting inputs section, remember how you needed to define `interest1`, `interest2`, and `interest3` manually?
    What if there was a way to write less code? That is where a for-loop comes in.
    File renamed without changes.
    18 changes: 18 additions & 0 deletions 8.5-oop-class-exercise.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    ## Class Exercise on OOP

    Task: Create a simple BankAccount class.
    It should store the account holder's name and balance.
    It should inherit from the AbstractBankAccount abstract class

    It should have methods:

    deposit(amount) -> adds to balance
    withdraw(amount) -> removes from balance (but not below 0)
    __str__() -> prints account details

    Then Create a subclass called SavingsAccount that:
    Inherits from BankAccount
    Adds a method add_interest(rate) that increases the balance by a percentage

    Goal: To practice creating your own classes, methods, inheritance, and state management.

    19 changes: 19 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    class BankAccount:
    def __init__(self, name, balance=0):
    self.name = name
    self.balance = balance

    def deposit(self, amount):
    pass # implement this

    def withdraw(self, amount):
    pass # implement this

    def __str__(self):
    return f"{self.name} has a balance of {self.balance}"

    # TODO: Create a SavingsAccount class that inherits from BankAccount

    # Example usage
    account = BankAccount("Alice", 1000)
    print(account)
  6. vicradon revised this gist Aug 23, 2025. 10 changed files with 223 additions and 37 deletions.
    2 changes: 1 addition & 1 deletion 2.2-variables-explanation.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## Variables
    ## Basic Explanation on Variables
    `my_name` is a string. It is used for things like names, and natural language \
    `my_age` is an integer. It is used for whole numbers, both negative and positive \
    `my_interests` is a list. It is used for grouping/ordering related variables
    30 changes: 16 additions & 14 deletions 2.4-class-exercise-data-types-and-structures.md
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,24 @@
    ## Class Exercise on Data Types and Structures

    Write a dictionary that has your name, twitter_handle, favorite constants, and what not.
    Task: Write a dictionary that has your name, twitter_handle, favorite constants, and what not.
    Goal: To help you understand the different data types you can work with in Python


    ```py
    my_internet_profile = {
    "name": None, # string
    "twitter_handle": None, # string
    "favorite_physics_constant": None, # float
    "age": None, # integer (you can lie about this lol)
    "finished_uni": None, # boolean
    "hobbies": None, # tuple
    "skills": None, # list
    "personal_quotes": None, # set (one or two)
    "contact_info": { # dictionary (nested)
    "phone_number": None, # integer (you can put a fake one)
    "email": None, # string (you can put a fake one)
    "website": None, # string
    },
    "name": None, # string
    "twitter_handle": None, # string
    "favorite_physics_constant": None, # float
    "age": None, # integer (you can lie about this lol)
    "finished_uni": None, # boolean
    "hobbies": None, # tuple
    "skills": None, # list
    "personal_quotes": None, # set (one or two)
    "contact_info": { # dictionary (nested)
    "phone_number": None, # integer (you can put a fake one)
    "email": None, # string (you can put a fake one)
    "website": None, # string
    },
    }

    print(my_internet_profile)
    11 changes: 9 additions & 2 deletions 3.4-class-exercise-on-collecting-input.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,16 @@
    ## Collecting Inputs Class Exercise

    Task: Write a program that collects your name and interests
    Goal: To teach you how to implement data collection and casting

    ```py
    name = input("What is your name: ")
    age = input("What")
    age = int(input("What"))
    interest1 = input("What is your number 1 interest: ")
    interest2 = input("What is ")
    interest3 = input("What ")

    combined = f"Your name is {name} and"

    print(combined)
    print(combined)
    ```
    7 changes: 0 additions & 7 deletions 4. class-exercise.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +0,0 @@
    ## Class Excersie 1

    Use what you've learnt so far to construct an app that can work for everyone.

    The idea here is to collect a person's name, age, and interests, store them in a variable, then print them in the end.

    Starting point
    9 changes: 0 additions & 9 deletions 4.1-starting-point.py
    Original file line number Diff line number Diff line change
    @@ -1,9 +0,0 @@
    name = input("What is your name: ")
    age = input("What")
    interest1 = input("What is your number 1 interest: ")
    interest2 = input("What is ")
    interest3 = input("What ")

    combined = f"Your name is {name} and"

    print(combined)
    2 changes: 2 additions & 0 deletions 5. loops intro.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,3 @@
    ## Loops Intro

    Notice how you needed to define `interest1`, `interest2`, and `interest3` manually? What if there was a way to write less code? That is where a for-loop comes in.
    3 changes: 0 additions & 3 deletions 6.x-using-external-libraries.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +0,0 @@
    ## Using External Libraries

    Python allows you to connect to websites, databases, robots, etc. Most of this functionality is stored in external libraries.
    54 changes: 53 additions & 1 deletion 8.3-oop-polymorphism.py
    Original file line number Diff line number Diff line change
    @@ -1 +1,53 @@
    a = 3
    """
    Polymorphism means one accessor, many implementation
    Here, the `add` method is implemented both on the Calculator and ScientificCalculator classes
    The former has a basic implementation while the later has a more involved implementation
    """

    class Calculator:
    def __init__(self, log_results: bool = True):
    self.__log_results = log_results

    def enable_logging(self):
    self.__log_results = True

    def disable_logging(self):
    self.__log_results = False

    @property
    def is_logging_enabled(self):
    return self.__log_results

    def add(self, num1: float, num2: float):
    result = num1 + num2
    if self.is_logging_enabled:
    print(f"The sum of {num1} and {num2} is {result}")
    return result


    class ScientificCalculator(Calculator):
    def __init__(self, log_results: bool = True):
    super().__init__(log_results)

    def add(self, *nums):
    result = sum(nums)

    if self.is_logging_enabled:
    stringified_nums = "The sum of "

    for i in range(len(nums) - 1):
    stringified_nums += f"{nums[i]}, "

    stringified_nums += f"and {nums[-1]}" # last element

    print(f"The sum of {stringified_nums} is {result}")

    return result


    normal_calc = Calculator()
    sci_calc = ScientificCalculator()

    normal_calc.add(3, 4)
    sci_calc.add(3, 4, 5)
    90 changes: 90 additions & 0 deletions 8.4-oop-abstraction.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,90 @@
    """In Abstraction, we define a base template every class must implement.
    Ignoring sub class inheritance, for example, the scientific calculator, if multiple defined classes implement the AbstractCalculator,
    they must define the add, subtract, multiply, and divide methods.
    """
    from abc import ABC, abstractmethod
    from fractions import Fraction


    class AbstractCalculator(ABC):
    @abstractmethod
    def add(self, num1, num2):
    pass

    @abstractmethod
    def subtract(self, num1, num2):
    pass

    @abstractmethod
    def multiply(self, num1, num2):
    pass

    @abstractmethod
    def divide(self, num1, num2):
    pass


    class BasicCalculator(AbstractCalculator):
    def add(self, num1, num2):
    return num1 + num2

    def subtract(self, num1, num2):
    return num1 - num2

    def multiply(self, num1, num2):
    return num1 * num2

    def divide(self, num1, num2):
    if num2 == 0:
    raise ValueError("Cannot divide by zero")
    return num1 / num2


    class RoundingCalculator(AbstractCalculator):
    """Always rounds to 2 decimal places (useful in finance)."""
    def add(self, num1, num2):
    return round(num1 + num2, 2)

    def subtract(self, num1, num2):
    return round(num1 - num2, 2)

    def multiply(self, num1, num2):
    return round(num1 * num2, 2)

    def divide(self, num1, num2):
    if num2 == 0:
    raise ValueError("Cannot divide by zero")
    return round(num1 / num2, 2)


    class FractionCalculator(AbstractCalculator):
    """Uses fractions for exact rational math."""
    def add(self, num1, num2):
    return Fraction(num1) + Fraction(num2)

    def subtract(self, num1, num2):
    return Fraction(num1) - Fraction(num2)

    def multiply(self, num1, num2):
    return Fraction(num1) * Fraction(num2)

    def divide(self, num1, num2):
    if num2 == 0:
    raise ValueError("Cannot divide by zero")
    return Fraction(num1) / Fraction(num2)



    calculators = [
    BasicCalculator(),
    RoundingCalculator(),
    FractionCalculator()
    ]

    for calc in calculators:
    print(f"\n{calc.__class__.__name__}")
    print("Add:", calc.add(7, 3))
    print("Subtract:", calc.subtract(7, 3))
    print("Multiply:", calc.multiply(7, 3))
    print("Divide:", calc.divide(7, 3))
    52 changes: 52 additions & 0 deletions 8.4.1-oop-abstraction-example-2.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    import locale
    from abc import ABC, abstractmethod

    try:
    locale.setlocale(locale.LC_ALL, "en_NG.UTF-8")
    except locale.Error:
    locale.setlocale(locale.LC_ALL, "")


    def format_currency(amount: float) -> str:
    formatted = locale.format_string("%0.2f", amount, grouping=True)
    return f"₦{formatted}"


    class Payment(ABC):
    @abstractmethod
    def pay(self, amount: float):
    pass


    class VerveCardPayment(Payment):
    def __init__(self, card_number: str, pin: str):
    self.card_number = card_number
    self.pin = pin

    def pay(self, amount: float):
    print(f"Charging {format_currency(amount)} to Verve card {self.card_number[-4:]}...")


    class MomoPayment(Payment):
    def __init__(self, phone_number: str):
    self.phone_number = phone_number

    def pay(self, amount: float):
    print(f"Processing MoMo payment of {format_currency(amount)} from {self.phone_number}...")


    class CryptoPayment(Payment):
    def __init__(self, wallet_address: str):
    self.wallet_address = wallet_address

    def pay(self, amount: float):
    print(f"Sending crypto payment of {format_currency(amount)} to wallet {self.wallet_address[:6]}...")


    def checkout(payment_method: Payment, amount: float):
    payment_method.pay(amount)


    checkout(VerveCardPayment("1234567890123456", "123"), 10000.0)
    checkout(MomoPayment("810548xxxx"), 23_435)
    checkout(CryptoPayment("0xAbCdEfGhIjKlMnOpQrStUvWxYz"), 2_000_000.0)
  7. vicradon revised this gist Aug 23, 2025. 5 changed files with 75 additions and 0 deletions.
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    ## Variables
    `my_name` is a string. It is used for things like names, and natural language \
    `my_age` is an integer. It is used for whole numbers, both negative and positive \
    `my_interests` is a list. It is used for grouping/ordering related variables
    33 changes: 33 additions & 0 deletions 2.3-more-data-structures.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    # floats
    PI = 3.14
    accelertion_due_to_gravity = 9.81

    print("Acceleration due to gravity on earth is", accelertion_due_to_gravity)

    # bools
    tech_bros_are_fraudsters = False
    is_raining_season = True

    print("Are techbros frauds?", tech_bros_are_fraudsters)
    print("Are we in raning season?", is_raining_season)

    # dictionary (hashmap)
    account_names_to_numbers = {
    "Ajibola Philips": 3110000000,
    "Moses Franklin": 3011000000,
    "Ijeoma Peters": 3021000000,
    }

    students = dict()
    students["you"] = {"name": "", "age": 26, "occupation": "tech bro"}

    print(type(account_names_to_numbers), type(students))

    # Tuple
    random_vector = (5, 45.0) # vector -> magnitude, direction
    mercy_details = ("Mercy Franklin", 25, False) # name, age, is_single

    # Set (hashset)
    account_numbers = set([3110000000, 3110000000, 3021000000])
    print("Account numbers", account_numbers)
    account_numbers = {3110000000, 3021000000}
    23 changes: 23 additions & 0 deletions 2.4-class-exercise-data-types-and-structures.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    ## Class Exercise on Data Types and Structures

    Write a dictionary that has your name, twitter_handle, favorite constants, and what not.

    ```py
    my_internet_profile = {
    "name": None, # string
    "twitter_handle": None, # string
    "favorite_physics_constant": None, # float
    "age": None, # integer (you can lie about this lol)
    "finished_uni": None, # boolean
    "hobbies": None, # tuple
    "skills": None, # list
    "personal_quotes": None, # set (one or two)
    "contact_info": { # dictionary (nested)
    "phone_number": None, # integer (you can put a fake one)
    "email": None, # string (you can put a fake one)
    "website": None, # string
    },
    }

    print(my_internet_profile)
    ```
    9 changes: 9 additions & 0 deletions 3.4-class-exercise-on-collecting-input.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    name = input("What is your name: ")
    age = input("What")
    interest1 = input("What is your number 1 interest: ")
    interest2 = input("What is ")
    interest3 = input("What ")

    combined = f"Your name is {name} and"

    print(combined)
    9 changes: 9 additions & 0 deletions 3.5-collecting-input-starting-point.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    name = input("What is your name: ")
    age = input("What")
    interest1 = input("What is your number 1 interest: ")
    interest2 = input("What is ")
    interest3 = input("What ")

    combined = f"Your name is {name} and"

    print(combined)
  8. vicradon revised this gist Aug 23, 2025. 10 changed files with 248 additions and 11 deletions.
    39 changes: 28 additions & 11 deletions 7.1-classes-intro.py
    Original file line number Diff line number Diff line change
    @@ -2,18 +2,35 @@ class Calculator:
    def __init__(self):
    pass

    def add(self):
    name = input("What is your name: ")
    age = input("What is your age: ")
    def add(self, a, b):
    return a + b

    def subtract(self, num1, num2):
    return num1 - num2

    def divide(self, num1, num2):
    try:
    return num1/num2
    except ZeroDivisionError:
    print("You attempted to divide by zero")

    interests = []

    for i in range(3):
    interest = input(f"What is your number {i} interest: ")
    interests.append(interest)
    def advanced_addition(self, *args):
    """This takes any number of arguments (numbers) and returns their sum."""
    result = 0

    for num in args:
    result = result + num

    return result


    interests_string = ", ".join(interests)
    return f"Your name is {name} and you are {age} years old with interests in {interests_string}"

    bank = Bank()
    bank.collect_input()
    calculator = Calculator()
    sum1 = calculator.add(4, 5)
    diff = calculator.divide(9, 2)
    sum2 = calculator.advanced_addition(4, 5, 6)

    print(sum1)
    print(diff)
    print(sum2)
    6 changes: 6 additions & 0 deletions 7.2-parts-of-a-class.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    ## Parts of a class

    1. name - Calculator
    2. self - a secret first argument that the snitch, Python, passes to every function defined within a class to make them `methods`.
    3. __init__ - a `dunder` method that python invokes when initializing a class. There are others like __str__, __converting a class to string
    4. Methods
    14 changes: 14 additions & 0 deletions 7.3-passing-data-to-class-initialization.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    class Calculator:
    def __init__(self, log_results: bool = False):
    self.log_results = log_results

    def add(self, num1: float, num2: float):
    result = num1 + num2

    if self.log_results:
    print(f"The sum of {num1} and {num2} is {result}")

    return result

    calculator = Calculator(log_results=True)
    calculator.add(4, 5) # no need for print
    3 changes: 3 additions & 0 deletions 7.4-classes-are-just-ways-to-create-your-own-object.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    ## Classes are simply ways to create your own type of logic

    So you can create behaviors, like how printing occurs, how data is accessed, in very specific ways.
    27 changes: 27 additions & 0 deletions 7.5-keeping-state-across-operations.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    class Calculator:
    def __init__(self, log_results: bool = False):
    self.log_results = log_results
    self.history = {
    "addition": [],
    "subtraction": [],
    "division": [],
    "multiplication": []
    }

    def add(self, num1: float, num2: float):
    result = num1 + num2

    if self.log_results:
    print(f"The sum of {num1} and {num2} is {result}")

    self.history["addition"].append((num1, num2, result))

    return result

    calculator = Calculator()

    calculator.add(4, 5)
    calculator.add(20, 25)
    calculator.add(-20, 30)

    print(calculator.history)
    45 changes: 45 additions & 0 deletions 7.6-excercise-pratice-keeping-state.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    ## Practice Keeping State

    Task: implement a new class called CalculatorHistory, then initialize it within the __init__ method of the calculator class.
    Purpose: To make it possible to use object accessors to access history methods rather than dictionary accessors
    Starting point:

    ```py
    class CalculatorHistory:
    def __init__(self):
    # add the remaining
    self.addition = []

    def __str__(self):
    return f"""
    Addition: {self.addition}
    """

    class Calculator:
    def __init__(self, log_results: bool = False):
    self.log_results = log_results
    self.history = {
    "addition": []
    }

    def add(self, num1: float, num2: float):
    result = num1 + num2

    if self.log_results:
    print(f"The sum of {num1} and {num2} is {result}")

    self.history["addition"].append((num1, num2, result))
    # goal
    # self.history.addition.append((num1, num2, result))

    return result


    calculator = Calculator()

    calculator.add(4, 5)
    calculator.add(20, 25)
    calculator.add(-20, 30)

    print(calculator.history)
    ```
    7 changes: 7 additions & 0 deletions 8.0-object-oriented-programming.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    ## Object Oriented Programming (OOP)

    Python allows you to implement some object oriented programming principles like inheritance, encapsulation, and polymorphism, with other principles (abstraction) supported to some degree.

    OOP princples help you write leaner, more organised code.

    In this module, you will implement some OOP principles on the calculator exmple.
    64 changes: 64 additions & 0 deletions 8.1-oop-inheritance.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,64 @@
    import math

    class Calculator:
    def __init__(self, log_results: bool = False):
    self.log_results = log_results

    def add(self, num1: float, num2: float):
    result = num1 + num2

    if self.log_results:
    print(f"The sum of {num1} and {num2} is {result}")

    return result

    def subtract(self, num1, num2):
    return num1 - num2

    def divide(self, num1, num2):
    try:
    return num1/num2
    except ZeroDivisionError:
    print("You attempted to divide by zero")


    def advanced_addition(self, *args):
    """This takes any number of arguments (numbers) and returns their sum."""
    result = 0

    for num in args:
    result = result + num

    return result

    class ScientificCalculator(Calculator):
    def __init__(self, log_results: bool = False):
    super().__init__(log_results)

    def sin(self, x):
    return math.sin(x)

    def cos(self, x):
    return math.cos(x)

    def tan(self, x):
    return math.tan(x)

    def log(self, x, base=10):
    result = math.log(x, base)

    if self.log_results:
    print(f"The log to base 10 of {x} is: {result}")

    return result

    def nat_log(self, x):
    return math.log(x, math.e)

    def factorial(self, n):
    return math.factorial(n)


    sci_calc = ScientificCalculator(log_results=True)
    sci_calc.add(4, 5) # from the main calculator
    sci_calc.log(100)
    53 changes: 53 additions & 0 deletions 8.2-oop-encapsulation.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    """
    Encapsulation equals method/variable hiding
    In Python, we are all adults here
    So if you see underscores, don't use that method or accesor
    Single underscore _something -> still accessible
    Double underscores __something -> not accessible directly
    """
    import math

    class Calculator:
    def __init__(self, log_results: bool = False):
    self.__log_results = log_results

    def enable_logging(self):
    self.__log_results = True

    def disable_logging(self):
    self.__log_results = False

    @property
    def is_logging_enabled(self):
    return self.__log_results

    def add(self, num1: float, num2: float):
    result = num1 + num2
    if self.is_logging_enabled:
    print(f"The sum of {num1} and {num2} is {result}")
    return result


    class ScientificCalculator(Calculator):
    def __init__(self, log_results: bool = False):
    super().__init__(log_results)

    def log(self, x, base=10):
    result = math.log(x, base)

    if self.is_logging_enabled:
    print(f"The log to base 10 of {x} is: {result}")

    return result

    sci_calc = ScientificCalculator()

    sci_calc.__log_results = True
    print(sci_calc.is_logging_enabled)
    sci_calc.add(3, 4)

    sci_calc.enable_logging()
    print(sci_calc.is_logging_enabled)
    sci_calc.add(3, 4)
    1 change: 1 addition & 0 deletions 8.3-oop-polymorphism.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    a = 3
  9. vicradon revised this gist Aug 23, 2025. 11 changed files with 48 additions and 20 deletions.
    2 changes: 2 additions & 0 deletions 5.2-parts-of-a-loop.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    ## Parts of a loop

    1. increment variable
    2. iterator/iteration
    3. repeated code
    3 changes: 2 additions & 1 deletion 6.0-functions-intro.md
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,3 @@
    ## Functions Intro
    ## Functions Intro

    Functions allow you to group logic. So the input collector you’ve built so far can be stored as a function that can be called anytime.
    15 changes: 15 additions & 0 deletions 6.2-a-simpler-function.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    def add(num1, num2):
    return num1 + num2

    number_sum = add(2, 3)
    print(number_sum)

    '''
    num1 is the first parameter
    num2 is the second parameter
    2 is the first argument (things passed to functions)
    3 is the second argument
    return is a keyword for returning from a function
    '''
    14 changes: 0 additions & 14 deletions 6.2-function_params.py
    Original file line number Diff line number Diff line change
    @@ -1,14 +0,0 @@
    def collect_input(save_):
    name = input("What is your name: ")
    age = input("What is your age: ")

    interests = []

    for i in range(3):
    interest = input(f"What is your number {i} interest: ")
    interests.append(interest)

    interests_string = ", ".join(interests)
    return f"Your name is {name} and you are {age} years old with interests in {interests_string}"

    collect_input()
    5 changes: 5 additions & 0 deletions 6.3-subtract-function.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    def subtract(num1, num2):
    return num1 - num2

    difference = subtract(7, 3)
    print(difference)
    5 changes: 5 additions & 0 deletions 6.4-divide-function.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    def divide(num1, num2):
    return num1/num2

    print("5 divide by 2 is", divide(5,2), "\n\n")
    print("3 divide by 0 is", divide(3, 0)) # throws error
    8 changes: 8 additions & 0 deletions 6.5-preventing-your-code-from-breaking.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    def divide(num1, num2):
    try:
    return num1/num2
    except Exception as e:
    print(str(e))

    print("5 divide by 2 is", divide(5,2))
    print("3 divide by 0 is", divide(3, 0)) # throws error
    8 changes: 8 additions & 0 deletions 6.6-specific-way-to-catch-exceptions.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    def divide(num1, num2):
    try:
    return num1/num2
    except ZeroDivisionError:
    print("You attempted to divide by zero")

    print("5 divide by 2 is", divide(5,2))
    print("3 divide by 0 is", divide(3, 0)) # throws error
    2 changes: 1 addition & 1 deletion 6.x-using-external-libraries.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,3 @@
    ## Using External Libraries

    Python allows you to connect to websites, databases, robots, etc. Most of this functionality is stored in external libraries
    Python allows you to connect to websites, databases, robots, etc. Most of this functionality is stored in external libraries.
    2 changes: 0 additions & 2 deletions 7.0-classes.md
    Original file line number Diff line number Diff line change
    @@ -2,5 +2,3 @@

    A Class is a more advanced way to group several functions and related logic in one place



    4 changes: 2 additions & 2 deletions 7.1-classes-intro.py
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    class Bank:
    class Calculator:
    def __init__(self):
    pass

    def collect_input(self):
    def add(self):
    name = input("What is your name: ")
    age = input("What is your age: ")

  10. vicradon revised this gist Aug 23, 2025. 6 changed files with 58 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions 6.0-functions-intro.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    ## Functions Intro
    Functions allow you to group logic. So the input collector you’ve built so far can be stored as a function that can be called anytime.
    14 changes: 14 additions & 0 deletions 6.1-your-first-function.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    def collect_input():
    name = input("What is your name: ")
    age = input("What is your age: ")

    interests = []

    for i in range(3):
    interest = input(f"What is your number {i} interest: ")
    interests.append(interest)

    interests_string = ", ".join(interests)
    return f"Your name is {name} and you are {age} years old with interests in {interests_string}"

    collect_input()
    14 changes: 14 additions & 0 deletions 6.2-function_params.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    def collect_input(save_):
    name = input("What is your name: ")
    age = input("What is your age: ")

    interests = []

    for i in range(3):
    interest = input(f"What is your number {i} interest: ")
    interests.append(interest)

    interests_string = ", ".join(interests)
    return f"Your name is {name} and you are {age} years old with interests in {interests_string}"

    collect_input()
    3 changes: 3 additions & 0 deletions 6.x-using-external-libraries.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    ## Using External Libraries

    Python allows you to connect to websites, databases, robots, etc. Most of this functionality is stored in external libraries
    6 changes: 6 additions & 0 deletions 7.0-classes.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    ## Python Classes

    A Class is a more advanced way to group several functions and related logic in one place



    19 changes: 19 additions & 0 deletions 7.1-classes-intro.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    class Bank:
    def __init__(self):
    pass

    def collect_input(self):
    name = input("What is your name: ")
    age = input("What is your age: ")

    interests = []

    for i in range(3):
    interest = input(f"What is your number {i} interest: ")
    interests.append(interest)

    interests_string = ", ".join(interests)
    return f"Your name is {name} and you are {age} years old with interests in {interests_string}"

    bank = Bank()
    bank.collect_input()
  11. vicradon revised this gist Aug 23, 2025. 2 changed files with 29 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions 5.2-parts-of-a-loop.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    1. increment variable
    2. iterator/iteration
    3. repeated code


    In the previous loop, `i` is the increment variable, \
    `range(3)` is the iterator
    and the snippet below is the repeated code
    ```
    interest = input(f"What is your number {i} interest: ")
    interests.append(interest)
    ```
    17 changes: 17 additions & 0 deletions 5.3-while-loop.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    name = input("What is your name: ")
    age = input("What is your age: ")

    interests = []

    i = 1 # increment variable

    while i <= 3: #
    interest = input(f"What is your number {i} interest: ")
    interests.append(interest)

    i += 1 # iteration

    interests_string = ", ".join(interests)
    combined = f"Your name is {name} and you are {age} years old with interests in {interests_string}"

    print(combined)
  12. vicradon revised this gist Aug 23, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 1-hello-world.py
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    print("Hello world")
    print("What's good, world?")
  13. vicradon revised this gist Aug 23, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 2.2-vriables-explanation.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,3 @@
    `my_name` is a string. It is used for things like names, and natural language \
    `my_name` is a string. It is used for things like names, and natural language \
    `my_age` is an integer. It is used for whole numbers, both negative and positive \
    `my_interests` is a list. It is used for grouping/ordering related variables
  14. vicradon revised this gist Aug 23, 2025. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions 2.2-vriables-explanation.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,3 @@
    `my_name` is a string. It is used for things like names, and natural language
    `my_age` is an integer. It is used for whole numbers, both negative and positive
    `my_name` is a string. It is used for things like names, and natural language \
    `my_age` is an integer. It is used for whole numbers, both negative and positive \
    `my_interests` is a list. It is used for grouping/ordering related variables
  15. vicradon renamed this gist Aug 23, 2025. 1 changed file with 0 additions and 0 deletions.
  16. vicradon revised this gist Aug 23, 2025. 3 changed files with 5 additions and 9 deletions.
    3 changes: 3 additions & 0 deletions 2,2-vriables-explanation.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    `my_name` is a string. It is used for things like names, and natural language
    `my_age` is an integer. It is used for whole numbers, both negative and positive
    `my_interests` is a list. It is used for grouping/ordering related variables
    9 changes: 0 additions & 9 deletions 2. variables.py
    Original file line number Diff line number Diff line change
    @@ -3,12 +3,3 @@
    my_interests = ["Anime", "Archery", "Skating"]

    print("My name is", my_name, "and I am", my_age, "and my interests are", *my_interests)

    # alternate way
    # message = f"My name is {my_name} and I am {my_age} and my interests are {my_interests[0]}, {my_interests[1]}, and {my_interests[2]}"
    # print(message)


    # my_name is a string. It is used for things like names, and natural language
    # my_age is an integer. It is used for whole numbers, both negative and positive
    # my_interests is a list. It is used for grouping/ordering related variables
    2 changes: 2 additions & 0 deletions 2.1-variables-alternate-way.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    message = f"My name is {my_name} and I am {my_age} and my interests are {my_interests[0]}, {my_interests[1]}, and {my_interests[2]}"
    print(message)
  17. vicradon renamed this gist Aug 23, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  18. vicradon created this gist Aug 23, 2025.
    1 change: 1 addition & 0 deletions 1-hello-world.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    print("Hello world")
    14 changes: 14 additions & 0 deletions 2. variables.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    my_name = "Mr. Brother Man"
    my_age = 42
    my_interests = ["Anime", "Archery", "Skating"]

    print("My name is", my_name, "and I am", my_age, "and my interests are", *my_interests)

    # alternate way
    # message = f"My name is {my_name} and I am {my_age} and my interests are {my_interests[0]}, {my_interests[1]}, and {my_interests[2]}"
    # print(message)


    # my_name is a string. It is used for things like names, and natural language
    # my_age is an integer. It is used for whole numbers, both negative and positive
    # my_interests is a list. It is used for grouping/ordering related variables
    4 changes: 4 additions & 0 deletions 3. collecting-input.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    input("What is your name: ")

    name = input("What is your name: ")
    print(name)
    7 changes: 7 additions & 0 deletions 4. class-exercise.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    ## Class Excersie 1

    Use what you've learnt so far to construct an app that can work for everyone.

    The idea here is to collect a person's name, age, and interests, store them in a variable, then print them in the end.

    Starting point
    9 changes: 9 additions & 0 deletions 4.1-starting-point.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    name = input("What is your name: ")
    age = input("What")
    interest1 = input("What is your number 1 interest: ")
    interest2 = input("What is ")
    interest3 = input("What ")

    combined = f"Your name is {name} and"

    print(combined)
    1 change: 1 addition & 0 deletions 5. loops intro.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    Notice how you needed to define `interest1`, `interest2`, and `interest3` manually? What if there was a way to write less code? That is where a for-loop comes in.
    13 changes: 13 additions & 0 deletions 5.1-loops-intro.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    name = input("What is your name: ")
    age = input("What is your age: ")

    interests = []

    for i in range(3):
    interest = input(f"What is your number {i} interest: ")
    interests.append(interest)

    interests_string = ", ".join(interests)
    combined = f"Your name is {name} and you are {age} years old with interests in {interests_string}"

    print(combined)
    3 changes: 3 additions & 0 deletions _python-intro.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    # Python Intro

    An introductory course to Python programming