Skip to main content

Python Starters

Code samples for algorithm, API calls, and data structures written in Python.

Requirements

This project requires minimal setup and you need to have the following installed in your local machine:

Python Git

Installation

Clone Repo

git clone https://github.com/mkeithX/python-starters.git
cd python-starters

Setup Virtual Environment

py -m venv .venv
.venv\Scripts\activate

Managing Dependencies

py -m pip install --upgrade pip
py -m pip install --upgrade -r requirements.txt

What's inside

TitleDescription
Fibonacci GeneratorGenerates a sequence of numbers where each term is the sum of the two preceding terms.
BMI CalculatorDetermines your BMI status—Normal, Overweight, or Obese.
Cipher/DecipherEncrypts or decrypts messages using the Caesar Cipher Algorithm.
Password GeneratorGenerates random passwords with three complexity levels.
Video DownloaderEasily downloads videos.
Countdown TimerSet and track countdowns.
QR Code GeneratorCreate QR codes.
Word Guess GameA fun game for guessing words.
Currency ConverterConvert between currencies.
Weather ForecastProvides current weather conditions and forecasts. Learn more.

Show code sample
import os

class Fibonacci:
def __init__(self) -> None:
self.sequence = [0, 1]

def get(self, index: int):
"""
Get Fibonacci sequence up to the specified index.

>>> Fibonacci().get(10)
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
>>> Fibonacci().get(5)
[0, 1, 1, 2, 3]
"""
difference = index - len(self.sequence) + 2
if difference > 0:
self.sequence.extend(self.sequence[-1] + self.sequence[-2] for _ in range(difference))
return self.sequence[:index]

def clear_console():
os.system('cls' if os.name == 'nt' else 'clear')

def main():
clear_console()
app_name = "Fibonacci Sequence Generator"
msg = "(To exit, enter 'exit' or press Ctrl-C)"
print(f'{"-" * 48}\n{" " * 10}{app_name}\n{" " * 5}{msg}{" " * 12}\n{"-" * 48}')

fibonacci = Fibonacci()

while True:
print()
prompt = input(">> ").lower()

if prompt in {"exit", "quit"}:
break

try:
index = int(prompt)
except ValueError:
print("Enter a number or 'exit'")
continue

print(*fibonacci.get(index), sep=', ')

if __name__ == "__main__":
main()

License

This project is licensed under MIT.

Support

🎉 Give this project a star ⭐ on GitHub. 🙏