From 136f1a698185f01c55b285c5ffe38ccd1ecb5fc6 Mon Sep 17 00:00:00 2001 From: Cal Wing Date: Thu, 27 Feb 2025 22:09:11 +1000 Subject: [PATCH] Finalise Ass 1 --- a1.py | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/a1.py b/a1.py index ea1d6a8..adc57d7 100644 --- a/a1.py +++ b/a1.py @@ -214,7 +214,7 @@ def main(): print(HELP_MESSAGE) # Quit - if cmd[0] == "s": + if cmd[0] == "q": while True: cmd = input("Are you sure (y/n): ").lower() if cmd in ['y', 'n']: @@ -233,21 +233,33 @@ def main(): elif cmd[0] == "p": if data is None: print("Please load data before using this command") + continue - cmd = cmd.split() - if len(cmd) != 4: + cmds = cmd.split() + if len(cmds) != 4: print("Please enter the correct number of arguments") continue - print_table(*cmd[1:], *data) + # This makes ints & floats + foo = () + for c in cmds: + if "." in str(c): + foo += float(c), + elif c.isnumeric(): + foo += int(c), + else: + foo += c, + + print_table(*foo[1:], *data) # Make Graph elif cmd[0] == "s": if data is None: print("Please load data before using this command") + continue print("Simulating water heights...") - heights = calc_heights_water_out(*data[0:5]) + heights, _ = calc_heights_water_out(*data[0:5]) plot_water_height(heights, data[4]) @@ -257,6 +269,8 @@ def main(): +##### End of Assisgnment ##### + # See if I get what the task sheet wants # [NOTE] It seems I am witing my own test suite :/ that wasn't the initention lol # Tests do equal what I get when i test it in the shell @@ -284,11 +298,15 @@ def sheet_tasks(): print("\nTask 9") - global input + global input # This is some magic I wrote a while ago to be an automatic input func input = auto_input([ "h", "s", "q", "n", "r", "test", "test_data.txt", - "p 280 20 6", "s", + "p 280 20 6", + + "r", "test", "test_data_2.txt", + 's', + "q", "y" ]) main()