Python Project – Simple One

* Dear reader, you may consider re-sizing screen smaller than 90%; potentially removing the need to scroll right to view the code (I’ve re-written it with more vertical lines to make it more visual-friendly).

# Inspired by Andy Sterkowitz (GitHub post, 3 Levels of Portfolio Projects. https://github.com/andysterks/three-levels-of-projects; 3 Types of Projects That Will Make You a Programmer. https://www.youtube.com/watch?v=RYE0QQKJI9o).

# Reinforcing/refining Python fundamentals and problem-solving

# KIV enhance speed by replacing <if> + <elif> + <else> loops with hash/lookup tables e.g. dictionaries or tuples (see Nicholas Obert. Nov 1, 2021. https://betterprogramming.pub/get-rid-of-excessive-if-else-statements-with-lookup-and-hash-tables-c7dbed808996; Parewa Labs Pvt Ltd. accessed 1 Aug 2022. Python Lists Vs Tuples. https://www.programiz.com/python-programming/list-vs-tuples).

# Algorithm (problem-solving recipe/logic) uses: risk classification, test grading, commission amounts etc.

***

Given the below, create a programme to provide estimated license fees.

V. Anton Spraul. 2012. Think like a programmer : an introduction to creative problem solving. San Franciso. No Starch Press. p. 68 (book teaches thru C++)
def biz_license_cost():
    
    # prints only once
    print("Welcome to your yearly",end=" ") # same line
    print("business licence cost estimator!")
    print() # prettier layout
    
    '''
    Extended comments
    Completed - 2022 Jul 29
    
    Lines 40 to 46 
    <while True> + <try> + <except> + <else> 
    with <float>, for decimals:
    validates user input without crashing. 
    
    Lines multiple <break> 
    ensures the loop ends and exits the programme. 
    
    Line 59 <else> 
    resolves negative number input. 
    
    Line 64 <else> 
    covers final scenario for sales_amount > 500000, 
    and provides licence cost.
    
    Note to self
    Ensure alignment: <try> + <except> + <else>.
    <finally>, unused, is only other 
    part of this Exception process. 
    
    Further study
    Al Sweigart. 2019. accessed 2022 Jul 29. 
    San Francisco. No Starch Press. 
    Automate the Boring Stuff with Python, 2nd Edition. 
    Chapter 8. 
    https://automatetheboringstuff.com/2e/chapter8/. 
    '''
    
    while True: 
        try:
            sales_amount = float(input("Enter positive sales_amount $:"))
        except:
            print("Do only enter +ve",end=" ")
            print("amount without symbols")
        else:
            if 0 < sales_amount <= 50000:
                print("License -> $25",end=" ")
                print("/ Cat One")
                break
            elif (50000 < sales_amount <= 150000):
                print("License -> $200",end=" ")
                print("/ Cat Two")
                break
            elif (150000 < sales_amount <= 500000):
                print("License -> $1000",end=" ")
                print("/ Cat Three")
                break
            else:
                if int(sales_amount) < 0:
                    print("License -> None:",end=" ")
                    print("please reconsider your business options.")
                    break
                else:
                    print("License -> $5000",end=" ")
                    print("/ Cat Four")
                    break
        
biz_license_cost() # run function
Sample output = )

Cosine Similarity v Cosine Distance

# Statistics / Machine Learning

# Note that cosine similarity cosine distance!

***

***

Python coding -> Excel

# to up office automation / efficiency

PIP -> Python programmers!

# Upgrading packages/libraries/modules generally reduce cyberattack risks and enhance performance;

# but they can break your code, so from the beginning it would be ideal to set up virtual environments for each coding project.

# If you use Python through data science platforms like Anaconda, there may be other things you have to type to upgrade.

# All the best!

***

“PIP is a package manager for Python packages, or modules…” (W3Schools. https://www.w3schools.com/python/python_pip.asp).