Finalise Ass 1
This commit is contained in:
parent
4a47f58935
commit
136f1a6981
32
a1.py
32
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user