Home Backend Development Python Tutorial Calculate savings with Python!

Calculate savings with Python!

Dec 03, 2024 pm 09:30 PM

I started learning coding and programming about a month and a half ago on Codecademy and decided to pursue a CS certification. This is my first ever project and I actually started it before I got the project assignment for Codecademy's CS Course. I fleshed it out to give it a bit of terminal eye candy before publishing it.

A bit of backstory before I get into the nitty gritty of the codebase. I am a lifelong gamer. I started on the Atari 2600 when I was a wee boy and stuck with consoles all the way up to the Series X. Back in 2022 Valve announced the Steam Deck and reminded me that I had signed up for a Steam account back in college and kind of just forgot about it, because I never had a machine worthy of playing games.

Fast forward back to 2022. I decided I really wanted a Steam Deck, and bought a laptop to revive my Steam account while waiting for my turn in the reservation queue. After I got my hands on the Deck, I realized what kind of monster Linux had become in the decade since I had last even touched it. So that inspired me to do what every gamer nerd ultimately does, if they are of the PC variety. I build my own computer.

Calculate savings with Python!

I knew from the offset that it was going to be a Linux box, I just had to get it put together first. After spending many many dollars acquiring and assembling parts, I had my beast, and it was ready for Linux.

I started learning Bash and RPi and Linux. Then I wanted more. I knew Linux was comprised of bash, Python and C. So I signed up for Codecademy, tried the free 7 days for the paid methods, and kept it. Which brings us to today.

I started writing Python functions as I started learning Python to flex my mental muscles outside of the course work. I work at a bank, so as I made my way through Intermediate and Advanced Python, I started putting together a calculator. First it was just loans, then it was certificates of deposit. Then I was learning how to use JSON and lambdas to create a table for money market dividend rates.

I got it to where it could calculate all three formulas before even starting the CS Cert course, so when I got to this assignment, I decided to add visuals and other sugar to the syntax to make it a proper terminal game/app.

The code uses classes and objects to do most of the work, save for the JSON/lambda shenanigans. There are a total of 5 classes in a family setup with a parent/child/grandchild relationship. The first class is the BankProduct class. It handles the flow of the rest of the app by passing the user to either the LoanProduct or DepositProduct logic depending on their first choice. If the chosen product is a savings product, the DepositProduct class repeats the same methods used by the BankProduct class to direct the user to either the Certificate logic or the MoneyMarket logic depending on how they answer the following prompt.

The app is built for people who work with finances and would need a quick way to calculate these figures. So the expectation is that they would know at the very least the amount, interest rate, and term of the product. With this in mind, the products will ask for that information from the user and then do the math. The exact information required varies but some form of input is requested. For example, the user may enter the name of the loan product as the calculations work the same for all loan types.

At the same time the names for "Certificate" and "Money Market" are static and so they are not required to be entered. And in the case of the Money Market account the dividends are dependent on the deposit balance, so the user does not have to enter the rate in that case, as the JSON has the tiered rates for money market accounts stored. As rates fluctuate with the market, a savvy user could edit the dividend rates in the JSON to reflect those changes.

After providing the requested three or four pieces of information, the program does the calculations using algorithms scripted in, using the information provided by the user as the variables. The program will return all the information about the product (name, balance, rate, term) as well as monthly payment, total interest, and total balance paid for loans and total dividends and new balance for savings accounts.

After returning the requested information, it will ask if the user wants to do another calculation. If the answer is yes, it will loop back to start, if no, it will terminate.

Feel free to view the GitHub repo here.

It was a lot of fun to write and I can't wait to see what I come up with next. Programming is fun!

The above is the detailed content of Calculate savings with Python!. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to avoid being detected by the browser when using Fiddler Everywhere for man-in-the-middle reading? How to avoid being detected by the browser when using Fiddler Everywhere for man-in-the-middle reading? Apr 02, 2025 am 07:15 AM

How to avoid being detected when using FiddlerEverywhere for man-in-the-middle readings When you use FiddlerEverywhere...

How to solve permission issues when using python --version command in Linux terminal? How to solve permission issues when using python --version command in Linux terminal? Apr 02, 2025 am 06:36 AM

Using python in Linux terminal...

How to teach computer novice programming basics in project and problem-driven methods within 10 hours? How to teach computer novice programming basics in project and problem-driven methods within 10 hours? Apr 02, 2025 am 07:18 AM

How to teach computer novice programming basics within 10 hours? If you only have 10 hours to teach computer novice some programming knowledge, what would you choose to teach...

How to get news data bypassing Investing.com's anti-crawler mechanism? How to get news data bypassing Investing.com's anti-crawler mechanism? Apr 02, 2025 am 07:03 AM

Understanding the anti-crawling strategy of Investing.com Many people often try to crawl news data from Investing.com (https://cn.investing.com/news/latest-news)...

Python 3.6 loading pickle file error ModuleNotFoundError: What should I do if I load pickle file '__builtin__'? Python 3.6 loading pickle file error ModuleNotFoundError: What should I do if I load pickle file '__builtin__'? Apr 02, 2025 am 06:27 AM

Loading pickle file in Python 3.6 environment error: ModuleNotFoundError:Nomodulenamed...

What is the reason why pipeline files cannot be written when using Scapy crawler? What is the reason why pipeline files cannot be written when using Scapy crawler? Apr 02, 2025 am 06:45 AM

Discussion on the reasons why pipeline files cannot be written when using Scapy crawlers When learning and using Scapy crawlers for persistent data storage, you may encounter pipeline files...

See all articles