]> Untitled Git - axy/ft/python03.git/commitdiff
Added so much slop but it works i think master
authorAxy <gilliardmarthey.axel@gmail.com>
Mon, 12 Jan 2026 14:39:26 +0000 (15:39 +0100)
committerAxy <gilliardmarthey.axel@gmail.com>
Mon, 12 Jan 2026 14:39:26 +0000 (15:39 +0100)
ex0/ft_command_quest.py
ex1/ft_score_analytics.py
ex2/ft_coordinate_system.py
ex3/ft_achievement_tracker.py
ex4/ft_inventory_system.py

index 852db63448755a7827918fef5b20ca3d5f36e428..e9f05b6eb98d647a4e3722d51960437ff0d37b63 100644 (file)
@@ -9,15 +9,16 @@ import sys
 def main() -> None:
     """Process and display command-line arguments."""
     print("=== Command Quest ===")
-    print(f"Program name: {sys.argv[0]}")
-
     if len(sys.argv) == 1:
         print("No arguments provided!")
+        print(f"Program name: {sys.argv[0]}")
     else:
+        print(f"Program name: {sys.argv[0]}")
         print(f"Arguments received: {len(sys.argv) - 1}")
 
-    for i, arg in enumerate(sys.argv[1:], 1):
-        print(f"Argument {i}: {arg}")
+    if len(sys.argv) > 1:
+        for i, arg in enumerate(sys.argv[1:], 1):
+            print(f"Argument {i}: {arg}")
 
     print(f"Total arguments: {len(sys.argv)}")
 
index c60aac74550dddef3e370a892013894d6828a0c0..53294b6154150b65a113f27fe4da457b5f5a8516 100644 (file)
@@ -30,7 +30,6 @@ def main() -> None:
         print("No valid scores provided.")
         return
 
-    print()
     print(f"Scores processed: {scores}")
     print(f"Total players: {len(scores)}")
     print(f"Total score: {sum(scores)}")
index 46a5bf088238b3bc6b5a85bd366a30e7d73b6776..a6958c7a39c803b5ec94be236ae666cdb45ea204 100644 (file)
@@ -41,47 +41,33 @@ def distance_3d(
 def main() -> None:
     """Demonstrate 3D coordinate system using tuples."""
     print("=== Game Coordinate System ===")
-    print()
-
-    # Create and demonstrate a position
     position1: tuple[int, int, int] = (10, 20, 5)
     origin: tuple[int, int, int] = (0, 0, 0)
-
     print(f"Position created: {position1}")
     dist: float = distance_3d(origin, position1)
     print(f"Distance between {origin} and {position1}: {dist}")
-    print()
-
-    # Parse coordinates from string
-    print('Parsing coordinates: "3,4,0"')
+    print('\nParsing coordinates: "3,4,0"')
+    position2: tuple[float, float, float] = (0.0, 0.0, 0.0)
     try:
-        position2: tuple[float, float, float] = parse_coordinates("3,4,0")
+        position2 = parse_coordinates("3,4,0")
         print(f"Parsed position: {position2}")
         dist = distance_3d(origin, position2)
         print(f"Distance between {origin} and {position2}: {dist}")
     except ValueError as e:
         print(f"Error parsing coordinates: {e}")
-
-    # Handle invalid coordinates
-    print('Parsing invalid coordinates: "abc,def,ghi"')
+    print('\nParsing invalid coordinates: "abc,def,ghi"')
     try:
         parse_coordinates("abc,def,ghi")
     except ValueError as e:
         print(f"Error parsing coordinates: {e}")
-        print(
-            'Error details - Type: ValueError, Args: ("invalid literal for '
-            "int() with base 10: 'abc'\",)"
-        )
-    print()
-
-    # Demonstrate tuple unpacking
-    print("Unpacking demonstration:")
+        print(f"Error details - Type: ValueError, Args: {e.args}")
+    print("\nUnpacking demonstration:")
     x: float
     y: float
     z: float
     x, y, z = position2
-    print(f"Player at x={x}, y={y}, z={z}")
-    print(f"Coordinates: X={x}, Y={y}, Z={z}")
+    print(f"Player at x={int(x)}, y={int(y)}, z={int(z)}")
+    print(f"Coordinates: X={int(x)}, Y={int(y)}, Z={int(z)}")
 
 
 if __name__ == "__main__":
index 1ec4be674a651f8ea9dae638f4513ba7eb973d44..5942b0b6a02b31d0f4f620b8a0c8285511ea3ae2 100644 (file)
@@ -56,9 +56,11 @@ def main() -> None:
     print(f"Rare achievements (1 player): {rare_achievements}")
 
     # Pairwise comparisons
+    # Note: Subject example shows pairwise difference (relative uniqueness),
+    # not globally unique achievements across all players.
     alice_bob_common: set[str] = alice & bob
-    alice_unique: set[str] = alice - bob - charlie
-    bob_unique: set[str] = bob - alice - charlie
+    alice_unique: set[str] = alice - bob
+    bob_unique: set[str] = bob - alice
 
     print(f"Alice vs Bob common: {alice_bob_common}")
     print(f"Alice unique: {alice_unique}")
index cf8ed1d5c75f82c6a97bc216a9dc4aac0651eb66..050c5025715297a95a54e0e0ed6cd958a5dcc70c 100644 (file)
@@ -102,6 +102,13 @@ def main() -> None:
     # Analytics
     print("\n=== Inventory Analytics ===")
 
+    # Recalculate Alice's stats after transaction
+    alice_total_value = 0
+    alice_item_count = 0
+    for item_data in alice_inventory.values():
+        alice_total_value += item_data["quantity"] * item_data["value"]
+        alice_item_count += item_data["quantity"]
+
     # Most valuable player
     bob_total_value: int = 0
     for item_data in bob_inventory.values():