+ 1
Help me
The coading challenge says if you run 7 it should be Broke even but i think it should be profit The coading challenge is hovercrafts https://sololearn.com/compiler-playground/civSKFNi8IV2/?ref=app This is the coading challenge https://www.sololearn.com/coach/42?ref=app
9 Answers
+ 3
amount_sold = int(input())
hovercrafts_maded = 10
#this variable is better to asign like these
hovercrafts_left = hovercrafts_maded - amount_sold
#error1: is not good to name a variable like that, is better to name it hovercrafts_left, becouse that is the hovercrafts that you have not sold
money_earned = amount_sold * 3_000_000
#error2: you should use a new variable, so the code will be more understandable
hovercrafts_insurance = 1_000_000
#error3:you do not pay 1_000_000 for each hovercraft, you only pay 1_000_000 once in the month
hovercrafts_cost = hovercrafts_maded * 2_000_000
#the same as before, make a new variable to keep the code understandable
# loss made by making hovercrafts
hovercrafts_total = hovercrafts_insurance + hovercrafts_cost
# to see if it is profit or not
if money_earned > hovercrafts_total:
print("Profit")
elif money_earned < hovercrafts_total:
print("Loss")
elif money_earned == hovercrafts_total:
print("Broke Even")
+ 6
just for completeness:
this task is from the `community section`, `code coaches`, `hovercraft`
https://www.sololearn.com/coach/42?ref=app
+ 5
🇸🇾 Abdulaziz Alnaser 🇸🇩 You're calculating the cost of unsold hovercrafts incorrectly: hovercrafts = hovercrafts * 2000000. In this line, hovercrafts = hovercrafts * 2000000, you're essentially calculating the cost of all ten hovercrafts, not just the unsold ones. You should only calculate the cost of the unsold hovercrafts, since you've already sold some. You can fix this by subtracting the sold hovercrafts from the total hovercrafts before calculating the cost.
*Tips: Focus on the conditions as they are given.
+ 2
I did that already
+ 2
It is hovercrafts
+ 2
Did it now
+ 1
We don’t know the challenge that this code is meant to solve. Please link that as well.
+ 1
Granted, I missed where you said which challenge it was, but I don’t know how to look up coding challenges by name, since I never use them. I wish you would link it so I didn’t have to figure that out.
+ 1
`нттp⁴⁰⁶ But i did that in line 4