+ 1
The Hovercraft test
Hallo I have made the Hovercraft test (python) and I have written this code. cost_hover = int(2000000) sell_price_hover = int(3000000) insurance_cost = int(1000000) sales = int(input("how much did you sell?")) cost_made = cost_hover * 10 + insurance_cost revenue = sales * sell_price_hover x = "Profit" y = "Loss" z = "Broke Even" if revenue > cost_made: print(x) if revenue == cost_made: print(z) if revenue < cost_made: print(y) And it says its wrong Some one please help 🤔 Problem solved see answer
16 odpowiedzi
+ 3
Is there any errors?
While taking input, don't put any message, just only take input..
sales=int(input(""))
+ 3
replace the missing variable 'reven' with 'revenue' in the last if condition
+ 2
I made the same mistake first.
But your factory makes every Mont 10 hoovers if you sell it or not.
So every month your cost will be
cost = 10 * price_hover + insurance_cost
And that sums up to 21.000.000
+ 2
total_sales = int(input())
cost_of_one_hovercraft = 2000000
cost_of_monthly_insurance = 1000000
total_no_of_hovercraft = 10
selling_price_of_one_hovercraft = 3000000
monthly_cost = (cost_of_one_hovercraft * total_no_of_hovercraft) + cost_of_monthly_insurance
current_monthly_sales = (selling_price_of_one_hovercraft * total_sales )
if monthly_cost == current_monthly_sales :
print('Broke Even')
elif monthly_cost > current_monthly_sales :
print('Loss')
else:
print('Profit')
+ 2
Yeah So... I have analysed your code here are the problems, 1. Remove 10 from int(input (10)); 2. A colon ":" Isn't required after elif it is used after the condition also there you don't have to use a condition after else, because else is exclusively for stuff left for no condition mentioned, so second last line will be "else:" Only; 3. You formula for sure is right 👌 but the thing is your formula gives a value which can be any.. I got it that by <0 you meant loss but- it will give constant values so you need to directly compare sales to production cost; 4. In elif condition to compare value you have to use "==" Not "=" because single = means assigning that we aren't doing here (also don't forget to use the actual values).... I hope this helps.
+ 1
I have replaced it but still.
https://www.sololearn.com/coach/42?ref=app
+ 1
Check out my solution and let me know if it works.
https://code.sololearn.com/cvoiK5auyci2/?ref=app
+ 1
I am struggling with if else or elif codes. Always invalid syntax and after reading other sites and examples I still don't get my error. Same with the BMI challenge so I tried this test to try another way but always invalid on line 9. Doesn't matter if I cut the rest to run it as loss or profit and only use else and make it read else: profit > 0: print (profit)
My attempt is as below
sold = int (input(10))
overhead = 20
value = 30
insurance = 10
profit = ((sold * value) - (sold * overhead)) - insurance
print (profit)
if profit < 0:
print ("Loss")
elif: profit = 0:
print ("Broke Even")
else: profit > 0:
print ("Profit")
+ 1
Thank you for your help. In-between posting and answering I re wrote as below which solves the issues you highlighted. Still don't fully get else if but 1 victory in this long battle is a start! Also didn't read the statement correct as it's 10 units produced regardless of sold so need to read things better!
sold = int(input())
cost = 2000000
insur = 1000000
prod = 10
price = 3000000
monthly_cost = (prod * cost) + insur
monthly_sales = (price * sold)
if monthly_cost == monthly_sales:
print ("Broke Even")
elif monthly_cost > monthly_sales:
print ("Loss")
else:
print ("Profit")
0
Thank you it worked I got + 10xp
0
Hey guys see my answers to hovercraft and other quizzes I have solved a lot of them and I am still solving they will help you. Check on my id
0
Is your problem solved now? Moreover I think you should remove 10 from int(input(10)) and can you make the values upto the actual ones? I will surely try upon it then. ;)
0
Very simple way to solve !
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int sales = sc.nextInt();
if (sales<5 && sales>=0) {
System.out.println("Loss");
}else if (sales==7){
System.out.println("Broke Even");
}else if (sales>7 && sales<=10){
System.out.println("Profit");
}
}
}
0
HELP PLEASE!!
I have this and it's seems to be something wrong I the second line (syntaxerror)
sales = (int(input())
insurance = sales * 1000000
production = 10 * 2000000
price = 3000000
benefits = sales * (insurance - production + price)
if benefits > 0:
print("Profit")
elif benefits = 0:
print("Broke Even")
else:
print("Loss")