From c9cce501bc8cfa29e3b6a84f73a6ce836ac77e35 Mon Sep 17 00:00:00 2001 From: Cal Wing Date: Thu, 27 Feb 2025 21:22:01 +1000 Subject: [PATCH] Task 8 --- a1.py | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/a1.py b/a1.py index e29e0b5..153102b 100644 --- a/a1.py +++ b/a1.py @@ -171,6 +171,39 @@ def calc_daily_profit(energy: tuple[float, ...], peak_tariff: float, return total_profit +# Task 9 +def print_table(start_relative_elevation: float, step_size: float, + num_steps: int, initial_height: float, final_height: float, + reservoir_area: float, outlet_area: float, time_inc: float, + peak_tariff: float, off_peak_tariff: float, efficiency: float): + + # Print the header + print("#"*79) + print("# Relative elevation (m) # Daily Profit ($) # Total Energy (kWh) #") + print("#"*79) + + table_data = () + + rel_elevation = start_relative_elevation + for i in range(num_steps): + + heights, water_mass_outs = calc_heights_water_out(initial_height, final_height, reservoir_area, outlet_area, time_inc) + energy, _ = calc_energy_power(heights, water_mass_outs, rel_elevation, efficiency, time_inc) + + total_energy = sum(energy) + + profit = calc_daily_profit(energy, peak_tariff, off_peak_tariff, efficiency) + + table_data += (rel_elevation, profit, total_energy), + + rel_elevation += step_size + + # Print the table + for elevation, profit, total_energy in table_data: + print(f"#{elevation:^25d}#{profit:^25.2f}#{total_energy:^25.2f}#") + + print("#"*79) + # 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 @@ -196,4 +229,6 @@ def sheet_tasks(): if __name__ == '__main__': - sheet_tasks() \ No newline at end of file + #sheet_tasks() + + print_table(280, 20, 6, 30, 20, 40000, 1, 30, 0.02, 0.005, 85) \ No newline at end of file