Hovercraft help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hovercraft help

Hello everybody Please help me with the code, but don't tell me the solution. Something is wrong, there's 5 task, and one of 5 is bad. If I make 7 hovercraft It should broke even, but it's profit.... Please really don't tell me the solution, just help me think. Here's the code https://www.sololearn.com/coach/42?ref=app hovercraft = int(input()) b_cost = 2e6 s_cost = 3e6 insurance = 1e6 hc = (10 * b_cost) + (10* insurance) #10 pieces/month: 21.000.000 spending = hc- hovercraft * (b_cost + insurance) make_m = (s_cost * hovercraft ) if make_m < spending: print ("Loss") elif make_m == spending: print ("Broke Even") else: print("Profit")

14th Dec 2023, 7:25 PM
Flóra-Szekeres Barbara
Flóra-Szekeres Barbara - avatar
2 Answers
+ 2
Flóra-Szekeres Barbara , Without telling you anything specific, I say you have too many variables and calculations. Your code is more complicated than the problem. Try removing stuff until you can't remove anything else, and in that process of refactoring, you'll surely realize where you slipped. Also, if you could use better variable names, it would make your code easier to read. Since this is a financial problem, basically mimicking a miniature version of an accountant's monthly profit and loss statement for a company, you could try researching the common accounting terms, and use those as variable names. Accounting problems have been with us as far back as written history, evidenced by the Sumerian clay tablets, and accountants have had plenty of time to hone their craft, so there's no need to reinvent it.
15th Dec 2023, 3:56 AM
Rain
Rain - avatar
0
The logic i use is: Profit = sales >7 Broke even = >5 Loss = <=5
14th Dec 2023, 7:52 PM
Jaelani Kusuma
Jaelani Kusuma - avatar