Sythra
All tracks

Advanced · 4 labs

Sythra Progress Saver: File Handling

Read and write learner progress on disk — line logs, streak history, and JSON profiles like Sythra's local backup tools.

Total labs

4

Completed

0

Remaining

4

Progress

0%

In this track

Labs

0 / 4 done

Lab 01Easy

Read Progress File

Sythra counts meaningful lines in a progress text file. Write count_lines(path) → int Rules - Open the file at path for reading - Count lines that are not blank after stripping whitespace - Empty file → 0 Examples - file with "Loops\n\nLists\n" → 2 - file with only spaces/newlines → 0

Not started · 0%

Start →
Lab 02Easy

Write Study Log

Sythra exports a study session as one line per entry. Write write_log(path, entries) → None Rules - Write each string in entries on its own line - Overwrite the file if it already exists - Empty entries list creates an empty file Examples - write_log("log.txt", ["Loops", "Lists"]) → file contains "Loops\nLists\n" - write_log("log.txt", []) → empty file

Not started · 0%

Start →
Lab 03Medium

Append Streak History

Sythra appends each study day to a streak history file. Write append_streak(path, day) → None Rules - Append one line containing day (as given) plus a newline - Use append mode; create the file if it does not exist - Multiple calls stack lines in order Examples - append_streak("streak.txt", "2024-01-01") then append_streak("streak.txt", "2024-01-02") → file "2024-01-01\n2024-01-02\n"

Not started · 0%

Start →
Lab 04Hard

Save and Load Profile

Sythra saves learner profiles as JSON files. Write: 1. save_profile(path, profile) — write profile dict as JSON to path (use json.dump) 2. load_profile(path) → dict — read JSON; if file missing or invalid JSON return {} Examples - save then load round-trips {"name": "Asha", "xp": 40} - load_profile("missing.json") → {} - corrupt file → {}

Not started · 0%

Start →