Immanuel Mboowa About Computers

I am passionate about Computers and Art. I show my skills and passion through Computational Biology, Computer Graphics, and Computer Science Projects. I specialize in Python and C programming languages but seldom tap the Assembly world. I aim to contribute to these fields of Computers.

Computer Science

Python

C

ARM Assembly

Computer Graphics

Blender

Python

company.py

class Employee:
    def __init__(self, employee_name, employee_address, shift_hours):
        self.name = employee_name
        self.address = employee_address
        self.hours = shift_hours

class Task:
    def __init__(self, task_doer, task_name, due_date):
        self.task_doer = task_doer
        self.task_name = task_name
        self.due_date = due_date

class Product:
    def __init__(self, product_name, product_price, product_tax):
        self.product_name = product_name
        self.product_price = product_price
        self.product_tax = product_tax

class Company:
    def __init__(self, company_id):
        self.employees = list()
        self.tasks = list()
        self.id = company_id
        self.products = list()

    def get_employees(self):
        return self.employees
    def get_tasks(self):
        return self.tasks
    def get_products(self):
        return self.products

    def add_employee(self, employee):
         self.employees.append(employee)
    def add_task(self, task):
         self.tasks.append(task)
    def add_product(self, product):
         self.products.append(product)

    def update_employee(self, old_employee_name, new_employee_object):
        for index, employee in enumerate(self.employees):
            if employee.name is old_employee_name:
                self.employees[index] = new_employee_object
                break
    def update_task(self, old_task_name, new_task_object):
        for index, task in enumerate(self.tasks):
            if task.task_name is old_task_name:
                self.tasks[index] = new_task_object
                break
    def update_product(self, old_product_name, new_product_object):
        for index, product in enumerate(self.products):
            if product.product_name is old_product_name:
                self.products[index] = new_product_object
                break

    def remove_employee(self, employee_name):
        for index, employee in enumerate(self.employees):
            if employee.name is employee_name:
                self.employees[index] = None
                break
    def remove_task(self, task_name):
        for index, task in enumerate(self.tasks):
            if task.task_name is task_name:
                self.tasks[index] = None
                break
    def remove_product(self, product_name):
        for index, product in enumerate(self.products):
            if product.product_name is product_name:
                self.products[index] = None
                break

company_1 = Company(1001)
company_1.add_employee(Employee("John Doe", "10 Mel Dr", 8))
company_1.add_task(Task("John Doe", "Clean countertop", "tomorrow"))
company_1.add_task(Task("John Doe", "Counting drawer", "next one hour"))
company_1.add_employee(Employee("Mike Lime", "2 New York Ave.", 9))
company_1.add_task(Task("Mike Lime", "Do nothing", "now"))
company_1.add_employee(Employee("Kim Kent", "1 Wayne Ln.", 8))
company_1.add_task(Task("Kim Kent", "Close store", "next one hour"))
company_1.add_product(Product("Jacket", 79.99, 2.99))
company_1.add_product(Product("Belt", 9.99, 1.99))
company_1.update_employee("John Doe", Employee("John Doe", "10 Jude St", 8))
company_1.update_task("Counting drawer", Task("John Doe","Save money", "now"))
company_1.update_product("Jacket", Product("Bucket", 9.99, 0.99))
company_1.remove_employee("John Doe")
company_1.remove_task("Clean countertop")
company_1.remove_product("Bucket")

for object_employee in company_1.get_employees():
    if object_employee is None:
        continue
    print(f"Name: {object_employee.name}\nAddress: {object_employee.address}\nShift hours: {object_employee.hours}\n")
print()
for object_task in company_1.get_tasks():
    if object_task is None:
        continue
    print(f"Employee: {object_task.task_doer}\n\tTask name: {object_task.task_name}\n\tDue date: {object_task.due_date}")
print()
for object_product in company_1.get_products():
    if object_product is None:
        continue
    print(f"Product name: {object_product.product_name}\n\tPrice: {object_product.product_price}\n\tTax: {object_product.product_tax}")
                    

A class in Python is a feature that allows the user to create a "store" that has different kinds of datatypes.



In this scenario, the employee class stores variables with different datatypes:

employee_name, string
employee_address, string
shift_hours, int

The Task class stores variables:

task_doer, string
task_name, string
due_date, string

The product class stores variable:

product_name, string
product_price, float
product_tax, float

The Company class stores a list of employees, a list of tasks, a company_id, and a list of products.



In the company class a manager can get a list of employees objects by using the get_employees() method, a manager can get a list of tasks objects by using the get_tasks() method, a manager can get a list of products objects by using the get_products() method. In addition, a manager can add an employee object by using the add_employee(employee) method, a manager can add a task by using the add_task(task) method, a manager can add a product by using the add_product(product) method. All employees, tasks, and products can be updated by a manager by using these methods:

update_employee(old_employee_name, new_employee_object), update_task(old_task_name, new_task_object), update_product(old_product_name, new_product_object) respectively.

A manager can remove employees, tasks, and products by using these methods:

remove_employee(employee_name),
remove_task(task_name),
remove_product(product_name)


credit_card_validator.py

# Create variables to handle variants
card_number = input("Enter a card number ")
card_number = card_number.replace(" ","")
card_number = card_number.replace("-","")
# Reverse the card number
card_number = card_number[::-1]

sum_of_odd_nums = 0
sum_of_even_nums = 0
total = 0

# Loop for all odd places and sum them all up
for i in card_number[::2]:
    sum_of_odd_nums += int(i)

# Loop for all even places and multiply
for i in card_number[1::2]:
    x = int(i) * 2
    # If greater than 9
    if x >= 10:
        # Split it using modulus
        sum_of_even_nums += (1 + (int(x) % 10))
    else:
        # Else, sum them all up
        sum_of_even_nums += int(x)

# Sum the total of even places and odd places
total = sum_of_even_nums + sum_of_odd_nums

# If sum is divisible by 10, valid
if total % 10 == 0:
    print("Valid")
# Else, invalid
else:
    print("Invalid")
                    

The code receives a credit or debit card number and removes all -, spaces. The code reverses the card number like 12345 would be 54321.


Loop through the reversed card number on only odd positions and sum them all up by adding that number to the sum_of_odd_nums.


Loop through the reversed card number.

Multiply the numbers in the even positions by 2.

If the product is greater than 9, split the number like 18 would become 1 and 8 (modulus helps achieve this) then add those two numbers like 1 and 8 will be 9 and add that number, in this case 9, to the sum_of_even_nums

Else, just add that product to the sum_of_even_nums


Add the sum_of_odd_nums and sum_of_even_nums


If the total is divisible by 10, that credit or debit card number is valid. Else, it is invalid.

countdown.py

import time

tik_tok = int(input("enter a number of seconds: "))  # enter some time to be calculated

for i in range(tik_tok,0,-1):  # iterate for every second
    seconds = int(i) % 60  # the seconds shouldn't exceed 60 seconds(% means modulus in math)
    minutes = int(i / 60) % 60  # minutes don't go above 60 minutes
    hours = int(i / 3600) % 24  # hours shouldn't exceed 24 hours
    days = int(i / 86400) % 7  # days shouldn't exceed 7 days
    weeks = int(i / 604800)
    time.sleep(1)  # time will delay by 1 second
    print(f"W{weeks:02} D:{days:02} H:{hours:02} M:{minutes:02} S:{seconds:02}")
                    
Contact
Github LinkedIn