Quick Dash Calculator Fixed -
# Handle percentages: "15% of 200" or "200 + 15%" if '% of' in expr: parts = expr.split('% of') percent = float(parts[0]) total = float(parts[1]) return percent / 100 * total
# Built-in dash functions if expr.startswith('sum'): nums = [float(x) for x in expr[3:].strip('()').split(',')] return sum(nums) if expr.startswith('avg'): nums = [float(x) for x in expr[3:].strip('()').split(',')] return sum(nums) / len(nums) if nums else 0 if expr.startswith('tip'): # tip(total, percentage) args = expr[3:].strip('()').split(',') total, pct = float(args[0]), float(args[1]) return round(total * pct / 100, 2) if expr.startswith('split'): args = expr[5:].strip('()').split(',') total, people = float(args[0]), int(args[1]) return round(total / people, 2) quick dash calculator
if expr.endswith('%'): # relative to last result (simplified: returns % as decimal) return float(expr[:-1]) / 100 # Handle percentages: "15% of 200" or "200