diff --git a/submissions/mrfiiqane/assigment 01/quiz.py b/submissions/mrfiiqane/assigment01/quiz.py similarity index 93% rename from submissions/mrfiiqane/assigment 01/quiz.py rename to submissions/mrfiiqane/assigment01/quiz.py index 52f1144..6178ee1 100644 --- a/submissions/mrfiiqane/assigment 01/quiz.py +++ b/submissions/mrfiiqane/assigment01/quiz.py @@ -1,3 +1,5 @@ +# mrfiiqane == so dhowow magacaygu waa mohamed mohamud Kani waa assignment 2 == + # general question name = input("what is your name?") print("welcome!", name, "let start question.\n") diff --git a/submissions/mrfiiqane/assigment02/note.txt b/submissions/mrfiiqane/assigment02/note.txt new file mode 100644 index 0000000..26c2548 --- /dev/null +++ b/submissions/mrfiiqane/assigment02/note.txt @@ -0,0 +1,2 @@ +mohamed +xamdi diff --git a/submissions/mrfiiqane/assigment02/study_log.py b/submissions/mrfiiqane/assigment02/study_log.py new file mode 100644 index 0000000..6c77923 --- /dev/null +++ b/submissions/mrfiiqane/assigment02/study_log.py @@ -0,0 +1,58 @@ +# mrfiiqane == so dhowow magacaygu waa mohamed mohamud Kani waa assignment 2 == + +from pathlib import Path +BASE_DIR = Path(__file__).parent + +note_path = BASE_DIR / "note.txt" + +# soo jiido notes ka +def load(path): + try: + with open(path, "r", encoding="utf-8") as f: + notes = [] + for line in f: + notes.append(line.strip()) + return notes + except FileNotFoundError: + print("File not found") + return [] + +# save garee note ka +def save(path, notes): + with open(path, "w", encoding="utf-8") as f: + # if not "./note.txt": + # mkdir("./note.txt") + for note in notes: + f.write(note + "\n") + +# qeybta menu oo leh add,list,quit +def menu(): + notes = load(note_path) + print("Welcome to Study Log") + + while True: + print("\n1. Add \n2. List \n3. Quit") + choice = input("Enter your choice: ") + + if choice == "1": + note = input("enter note: ") + notes.append(note) + + elif choice == "2": + if not notes: + print("No notes found") + else: + print("\nYour Notes: ") + for note in notes: + print("-", note) + + elif choice == "3": + save(note_path, notes) + print("Notes saved. Bye!") + break + + else: + print("Invalid choice") + +if __name__ == "__main__": + menu() \ No newline at end of file diff --git a/submissions/mrfiiqane/assigment03/catalog.py b/submissions/mrfiiqane/assigment03/catalog.py new file mode 100644 index 0000000..70d213b --- /dev/null +++ b/submissions/mrfiiqane/assigment03/catalog.py @@ -0,0 +1,103 @@ + +# mrfiiqane == so dhowow magacaygu waa mohamed mohamud Kani waa assignment 3 == +from dataclasses import dataclass +from pathlib import Path +BASE_DIR = Path(__file__).parent + +catalog_file = BASE_DIR / "catalog.txt" + +@dataclass +class CatalogItem(): + title: str + year: int + + def __str__(self): + return f"{self.title}, {self.year}" + + +class Catalog: + def __init__(self): + self.items = [] + + def add_item(self, item): + self.items.append(item) + + def list_all(self): + if not self.items: + print("No books found.") + return + + print("\n Book Catalog:") + + for item in self.items: + print("-", item) + +# soo jiido notes ka +def load(path, catalog): + try: + with open(path, "r", encoding="utf-8") as f: + items = [] + for line in catalog.items: + line = line.strip() + if not line: + continue + + title, year = line.split("|") + items.append(CatalogItem(title, int(year))) + + return items + + except FileNotFoundError: + print("file not found") + return [] + +# save garee +def save(path, catalog): + with open(path, "w", encoding="utf-8") as f: + for item in catalog.items: + f.write(f"{item.title}|{item.year}\n") + + +def main(): + + catalog = Catalog() + + load(catalog_file, catalog) + + print("Welcome to Book Catalog") + + while True: + + print("\n1. Add Book, \n2. List Books, \n3. Save \n4. Quit") + + choice = input("choice: ") + + if choice == "1": + + title = input("Title: ") + year = int(input("Year: ")) + + item = CatalogItem(title, year) + catalog.add_item(item) + + print("Book added!") + + elif choice == "2": + catalog.list_all() + + elif choice == "3": + + save(catalog_file, catalog) + print("Catalog saved!") + + elif choice == "4": + save(catalog_file, catalog) + print("Saved. Bye!") + break + + else: + print("Invalid choice.") + + +if __name__ == "__main__": + main() diff --git a/submissions/mrfiiqane/assigment03/catalog.txt b/submissions/mrfiiqane/assigment03/catalog.txt new file mode 100644 index 0000000..318f375 --- /dev/null +++ b/submissions/mrfiiqane/assigment03/catalog.txt @@ -0,0 +1,2 @@ +tailwingcss|2020 +rich dad poor dad|2019