#!/usr/bin/env python # -*- coding: utf-8 -*- # This program is copyright 2016, P. Lutus and is released under the GPL. import sys args = sys.argv[1:] if(len(args) != 4): print('Sloped-bottom tank solver') print('Usage: values for h x y z') else: try: h,x,y,z = [float(v) for v in args] if(h == 0): h = 1e-9 if(y >= h): v = z * ((y-h) * x + h * x / 2) else: v = z * y * x * y/(2 * h) labels = ('h','x','y','z') print('Arguments:\n') for n,a in enumerate([h,x,y,z]): print(' %s: %6.2f' % (labels[n],a)) print('\nResult volume: %.2f' % v) except: print("Error: non-numeric entry.")