├── README.md ├── currency-converter.py ├── nba-scores.py └── path-finder.py /README.md: -------------------------------------------------------------------------------- 1 | # 3-Mini-Python-Projects-For-Intermediates 2 | 3 Mini Python Projects For Intermediate Programmers! 3 | 4 | 5 | # 💻 Launch Your Software Development Career Today! 6 | 7 | 🎓 **No degree? No problem!** My program equips you with everything you need to break into tech and land an entry-level software development role. 8 | 9 | 🚀 **Why Join?** 10 | - 💼 **$70k+ starting salary potential** 11 | - 🕐 **Self-paced:** Complete on your own time 12 | - 🤑 **Affordable:** Low risk compared to expensive bootcamps or degrees 13 | - 🎯 **45,000+ job openings** in the market 14 | 15 | 👉 **[Start your journey today!](https://techwithtim.net/dev)** 16 | No experience needed—just your determination. Future-proof your career and unlock six-figure potential like many of our students have! 17 | -------------------------------------------------------------------------------- /currency-converter.py: -------------------------------------------------------------------------------- 1 | from requests import get 2 | from pprint import PrettyPrinter 3 | 4 | BASE_URL = "https://free.currconv.com/" 5 | API_KEY = "562ddaf40c95f5d58108" 6 | 7 | printer = PrettyPrinter() 8 | 9 | 10 | def get_currencies(): 11 | endpoint = f"api/v7/currencies?apiKey={API_KEY}" 12 | url = BASE_URL + endpoint 13 | data = get(url).json()['results'] 14 | 15 | data = list(data.items()) 16 | data.sort() 17 | 18 | return data 19 | 20 | 21 | def print_currencies(currencies): 22 | for name, currency in currencies: 23 | name = currency['currencyName'] 24 | _id = currency['id'] 25 | symbol = currency.get("currencySymbol", "") 26 | print(f"{_id} - {name} - {symbol}") 27 | 28 | 29 | def exchange_rate(currency1, currency2): 30 | endpoint = f"api/v7/convert?q={currency1}_{currency2}&compact=ultra&apiKey={API_KEY}" 31 | url = BASE_URL + endpoint 32 | data = get(url).json() 33 | 34 | if len(data) == 0: 35 | print('Invalid currencies.') 36 | return 37 | 38 | rate = list(data.values())[0] 39 | print(f"{currency1} -> {currency2} = {rate}") 40 | 41 | return rate 42 | 43 | 44 | def convert(currency1, currency2, amount): 45 | rate = exchange_rate(currency1, currency2) 46 | if rate is None: 47 | return 48 | 49 | try: 50 | amount = float(amount) 51 | except: 52 | print("Invalid amount.") 53 | return 54 | 55 | converted_amount = rate * amount 56 | print(f"{amount} {currency1} is equal to {converted_amount} {currency2}") 57 | return converted_amount 58 | 59 | 60 | def main(): 61 | currencies = get_currencies() 62 | 63 | print("Welcome to the currency converter!") 64 | print("List - lists the different currencies") 65 | print("Convert - convert from one currency to another") 66 | print("Rate - get the exchange rate of two currencies") 67 | print() 68 | 69 | while True: 70 | command = input("Enter a command (q to quit): ").lower() 71 | 72 | if command == "q": 73 | break 74 | elif command == "list": 75 | print_currencies(currencies) 76 | elif command == "convert": 77 | currency1 = input("Enter a base currency: ").upper() 78 | amount = input(f"Enter an amount in {currency1}: ") 79 | currency2 = input("Enter a currency to convert to: ").upper() 80 | convert(currency1, currency2, amount) 81 | elif command == "rate": 82 | currency1 = input("Enter a base currency: ").upper() 83 | currency2 = input("Enter a currency to convert to: ").upper() 84 | exchange_rate(currency1, currency2) 85 | else: 86 | print("Unrecognized command!") 87 | 88 | main() -------------------------------------------------------------------------------- /nba-scores.py: -------------------------------------------------------------------------------- 1 | from requests import get 2 | from pprint import PrettyPrinter 3 | 4 | BASE_URL = "https://data.nba.net" 5 | ALL_JSON = "/prod/v1/today.json" 6 | 7 | printer = PrettyPrinter() 8 | 9 | 10 | def get_links(): 11 | data = get(BASE_URL + ALL_JSON).json() 12 | links = data['links'] 13 | return links 14 | 15 | 16 | def get_scoreboard(): 17 | scoreboard = get_links()['currentScoreboard'] 18 | games = get(BASE_URL + scoreboard).json()['games'] 19 | 20 | for game in games: 21 | home_team = game['hTeam'] 22 | away_team = game['vTeam'] 23 | clock = game['clock'] 24 | period = game['period'] 25 | 26 | print("------------------------------------------") 27 | print(f"{home_team['triCode']} vs {away_team['triCode']}") 28 | print(f"{home_team['score']} - {away_team['score']}") 29 | print(f"{clock} - {period['current']}") 30 | 31 | 32 | def get_stats(): 33 | stats = get_links()['leagueTeamStatsLeaders'] 34 | teams = get( 35 | BASE_URL + stats).json()['league']['standard']['regularSeason']['teams'] 36 | 37 | teams = list(filter(lambda x: x['name'] != "Team", teams)) 38 | teams.sort(key=lambda x: int(x['ppg']['rank'])) 39 | 40 | for i, team in enumerate(teams): 41 | name = team['name'] 42 | nickname = team['nickname'] 43 | ppg = team['ppg']['avg'] 44 | print(f"{i + 1}. {name} - {nickname} - {ppg}") 45 | 46 | 47 | get_stats() 48 | -------------------------------------------------------------------------------- /path-finder.py: -------------------------------------------------------------------------------- 1 | import curses 2 | from curses import wrapper 3 | import queue 4 | import time 5 | 6 | maze = [ 7 | ["#", "O", "#", "#", "#", "#", "#", "#", "#"], 8 | ["#", " ", " ", " ", " ", " ", " ", " ", "#"], 9 | ["#", " ", "#", "#", " ", "#", "#", " ", "#"], 10 | ["#", " ", "#", " ", " ", " ", "#", " ", "#"], 11 | ["#", " ", "#", " ", "#", " ", "#", " ", "#"], 12 | ["#", " ", "#", " ", "#", " ", "#", " ", "#"], 13 | ["#", " ", "#", " ", "#", " ", "#", "#", "#"], 14 | ["#", " ", " ", " ", " ", " ", " ", " ", "#"], 15 | ["#", "#", "#", "#", "#", "#", "#", "X", "#"] 16 | ] 17 | 18 | 19 | def print_maze(maze, stdscr, path=[]): 20 | BLUE = curses.color_pair(1) 21 | RED = curses.color_pair(2) 22 | 23 | for i, row in enumerate(maze): 24 | for j, value in enumerate(row): 25 | if (i, j) in path: 26 | stdscr.addstr(i, j*2, "X", RED) 27 | else: 28 | stdscr.addstr(i, j*2, value, BLUE) 29 | 30 | 31 | def find_start(maze, start): 32 | for i, row in enumerate(maze): 33 | for j, value in enumerate(row): 34 | if value == start: 35 | return i, j 36 | 37 | return None 38 | 39 | 40 | def find_path(maze, stdscr): 41 | start = "O" 42 | end = "X" 43 | start_pos = find_start(maze, start) 44 | 45 | q = queue.Queue() 46 | q.put((start_pos, [start_pos])) 47 | 48 | visited = set() 49 | 50 | while not q.empty(): 51 | current_pos, path = q.get() 52 | row, col = current_pos 53 | 54 | stdscr.clear() 55 | print_maze(maze, stdscr, path) 56 | time.sleep(0.2) 57 | stdscr.refresh() 58 | 59 | if maze[row][col] == end: 60 | return path 61 | 62 | neighbors = find_neighbors(maze, row, col) 63 | for neighbor in neighbors: 64 | if neighbor in visited: 65 | continue 66 | 67 | r, c = neighbor 68 | if maze[r][c] == "#": 69 | continue 70 | 71 | new_path = path + [neighbor] 72 | q.put((neighbor, new_path)) 73 | visited.add(neighbor) 74 | 75 | 76 | def find_neighbors(maze, row, col): 77 | neighbors = [] 78 | 79 | if row > 0: # UP 80 | neighbors.append((row - 1, col)) 81 | if row + 1 < len(maze): # DOWN 82 | neighbors.append((row + 1, col)) 83 | if col > 0: # LEFT 84 | neighbors.append((row, col - 1)) 85 | if col + 1 < len(maze[0]): # RIGHT 86 | neighbors.append((row, col + 1)) 87 | 88 | return neighbors 89 | 90 | 91 | def main(stdscr): 92 | curses.init_pair(1, curses.COLOR_BLUE, curses.COLOR_BLACK) 93 | curses.init_pair(2, curses.COLOR_RED, curses.COLOR_BLACK) 94 | 95 | find_path(maze, stdscr) 96 | stdscr.getch() 97 | 98 | 99 | wrapper(main) 100 | --------------------------------------------------------------------------------