Python 3 HU Year 1 CLI Architecture

Nan Platform

A first-year project developed for Hogeschool Utrecht. A Python-based CLI gaming platform featuring automated user authentication, JSON data persistence, and adaptive score calculation algorithms.

Project Overview

Nan Title Screen
Python 3 JSON Data Storage REST APIs CLI Architecture

Nan is a modular command-line application hosting multiple mini-games. The system includes an automated authentication and account creation module using JSON files for persistent data storage.

Nan Game Selection

Skills Learned

Python 3 API Integration Data Handling Modular Design

During this first-year project at Hogeschool Utrecht, I deepened my fundamentals of Python programming. I mastered structured modular code design across multiple modules, external API integration (such as OpenWeather and OpenTDB), and handling persistent JSON data structures.

User Management & Scoring

JSON Storage User Auth High Scores

The core of the platform is the account management system. It validates user credentials, tracks high scores across mini-games, and automatically registers new accounts if a username is not found in the database.

account_manager.py
Python
import json

def user_account_handler(user_name, user_password):
    file_path = "account.json"
    with open(file_path, 'r+') as json_file:
        data = json.load(json_file)
        accounts = data["accountDetails"]

        for user_account in accounts:
            if user_account["username"] == user_name and user_account["password"] == user_password:
                print(f"User found logging in, Welcome {user_name}")
                return True

        print("User not found creating account")
        new_entry = {"username": user_name, "password": user_password}
        accounts.append(new_entry)
        
        json_file.seek(0)
        json.dump(data, json_file, indent=2)
        json_file.truncate()

Number Guesser Game

The Guesser game incorporates dynamic difficulty levels, adaptive scoring algorithms, and automated player performance feedback based on attempt counts.

Guesser Gameplay 1 Guesser Gameplay 2
guesser_game.py
Python
def calculate_score(difficulty_level, user_tries):
    score = (user_max_tries(difficulty_level) - user_tries) * difficulty_level
    print("Your score is: " + str(score))

def calculate_difficulty(user_score):
    low_score = 5
    normal_score = 12

    if user_score < low_score:
        return print("Try a lower difficulty")
    elif low_score <= user_score <= normal_score:
        return print("Keep this difficulty")
    else:
        return print("Advice: you can handle a higher difficulty level!")

Hangman (Galgje)

In Hangman, player progress is tracked visually as letters are guessed. Users can dynamically customize the active word list by adding or removing vocabulary.

Hangman Title Hangman Gameplay
hangman.py
Python
def show_progress(word, guessed_letters):
    display = []
    for letter in word:
        if letter in guessed_letters:
            display.append(letter.upper())
        else:
            display.append("_")
    return " ".join(display)

def calculate_score(lives_left, difficulty):
    return lives_left * difficulty

API Integration

The Animal Facts quiz uses the Python requests library to fetch dynamic trivia questions from the OpenTDB REST API, exploring asynchronous network requests and JSON response parsing.

animal_facts.py
Python
import requests
import html

def start_api_animal(user_name):
    response = requests.get("https://opentdb.com/api.php?amount=10&category=27&type=boolean")
    data = response.json()
    questions = data.get("results", [])

    for item in questions:
        question_text = html.unescape(item["question"])
        correct_answer = item["correct_answer"]
        user_answer = input(f"{question_text} (True/False): ")
        # ... logic to check answer and update score