0

2 cases not correct what's the problem

import math def calculate_art_cost(num_colors): """ Calculates the total cost of art supplies including tax, rounded up. Args: num_colors: An integer representing the number of paint colors. Returns: An integer representing the final cost rounded up to the nearest whole number. """ # Define the constant costs and tax rate canvas_and_brushes_cost = 40.00 cost_per_color = 5.00 tax_rate = 0.10 # Calculate the subtotal before tax paint_cost = num_colors * cost_per_color subtotal = canvas_and_brushes_cost + paint_cost # Calculate the total cost including tax total_cost_with_tax = subtotal * (1 + tax_rate) # Round the total cost up to the nearest whole number and return as an integer final_cost = math.ceil(total_cost_with_tax) return int(final_cost) # --- Example Usage --- # Get input from the user and handle potential errors try: colors_needed = int(input("")) # Calculate and print the result total_project_cost = calculate_art_cost(colors_needed)

19th Aug 2025, 6:21 AM
Manish
1 Answer
+ 3
Manish i guess you mean code coach 'Paint costs' ? i don't know if that's your complete code, but a try without an except or finally block is a syntax error. anyway, for code coach problems, try-except are not needed. also, you're supposed to print the answer. surprise: math.ceil is the wrong thing to use.😁 the wording of the problem is problematic.🧐 it shouldn't have used 'rounded UP' when it's actually expecting 'rounded TO'. the first example is your clue to what it's actually expecting: in my app, the input is n=2 the result is 55.00000000000001 the expected answer is 55 math.ceil will give you 56 round gives you 55 so you should use round instead of math.ceil it shouldn't really be that complicated: n = int(input()) print(round((40 + 5 * n) * 1.10))
19th Aug 2025, 6:55 AM
Bob_Li
Bob_Li - avatar