#๐ My Code isn't working successfully
104 messages ยท Page 1 of 1 (latest)
@lyric vessel
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Is the picture what you want or what you're getting?
I'm getting it
Ok and what do you want?
Expected Ouput: meal cost1006.25
Your output: excursion cost 334
Expected Ouput: excursion cost0
Your output: total cost 7991
Expected Ouput: total cost7656.25```
Expected Ouput: meal cost1523.75
Your output: excursion cost 502
Expected Ouput: excursion cost400
Your output: total cost 9901
Expected Ouput: total cost9798.75```
Expected Ouput: excursion cost118
Your output: total cost 4898
Expected Ouput: total cost4598.0``` so its something with my code
my int maybe?
i really dont know
In your code you never print meal cost or excursion cost, ist that from the same problem?
Like set as 0?
'''Meal cost = 0'''
Did it wrong on my phone ๐ญ
you sure u linked the right code?
I believe so since my output
is as the photo
but Idk where you think the code is wrong?
๐ @hasty cypress I swear
it worked for the last guy
๐ซก
pizza_slices = 12
slice_pp = 3
pizza_price = 15.99
salad_price = 7.99
discounted = 10
discount_rate = 0.15
delivery_rate = 0.07
min_discount = 20
#Ask the user to input how many pizzas / salads are needed
num_pizzas = int(input("Number of pizza orders: ")) #Must be 43
num_salads = int(input("Number of salad: ")) #Must 7
#Figure out how many whole pizzas are needed
total_slices = num_pizzas * slice_pp
whole_pies = (total_slices + slice_pp) // pizza_slices
#calculate costs for pizzas / salads
total_pizza_cost = whole_pies * pizza_price
total_salads_cost = num_salads * salad_price
#Calculate discounts
pizza_discount = 0
salad_discount = 0
if whole_pies > discounted:
pizza_discount = total_pizza_cost * discount_rate
if num_salads > discounted:
salad_discount = total_salads_cost * discount_rate
#Calculate delivery fees
pre_discount_charge = total_pizza_cost + total_salads_cost
delivery = max(pre_discount_charge * delivery_rate, min_discount)
#Calculate the total cost
total_with_discount = pre_discount_charge - (pizza_discount + salad_discount)
total_amount = total_with_discount + delivery
#Finally, print pizza / salad ordered
print("\nPizzas ordered: ", whole_pies)
print("Pizza cost: $", total_pizza_cost)
print("Salad cost: ", total_salads_cost)
print("Total: $", total_pizza_cost + total_salads_cost)
print("Discount: $", pizza_discount + salad_discount)
print("Delivery fee: $", delivery)
print("Total amount: $", total_amount)
this? ๐ฎ
no no sexy
seems like they arent related
thats whats on the link u posted :x
complete wrong code
old one
THIS
is my problem
run that
and it will make more sense
๐ญ
mine matches with the output
Expected Ouput: meal cost1006.25
Your output: excursion cost 334
Expected Ouput: excursion cost0
Your output: total cost 7991
Expected Ouput: total cost7656.25```
Expected Ouput: meal cost1523.75
Your output: excursion cost 502
Expected Ouput: excursion cost400
Your output: total cost 9901
Expected Ouput: total cost9798.75
Expected Ouput: excursion cost118
Your output: total cost 4898
Expected Ouput: total cost4598.0```
๐ญ wrong one mb
im def something with ur excursion cost fuction
cause thats all the difference
for ur if statements you have to check what the input is
cant just do a blanket if statement
i.e "if boat_dinner == "y"
ya
๐
two seconds
@hasty cypress ngl struggling do I put it after the ") at the end of the line
or outside the parentheses
for which line
snorkeling = input("Snorkeling [y/n]: ")
guided_hike = input("Guided Hike [y/n]: ")
boat_dinner = input("Boat Dinner [y/n]: ")```
Hey @lyric vessel!
It looks like you pasted Python code without syntax highlighting.
Please use syntax highlighting to improve the legibility of your code and make it easier for us to help you.
To do this, use the following method:
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
You can **edit your original message** to correct your code block.
these
oh no u leave those as is
u wanna change the if statements in the excusion_cost function
cause all ur input is taking in is a value of y or n
so u can just check with a blanket if
all it checks for is if there is a value in it
and ur meal_cost is returning wrong value, cause ur rounding the sum when it wants the actual float value
okay bet I changed this part on lines 43-44 into floats
it'll still be wrong, in the meal_cost fuction the math.ceil function rounds the value. you dont want to round it
then instead change
it into return total?
yep
๐ step by step
now real shi @hasty cypress still fucking up on the excursion part. It's 100% not ur writing on explaining just me confused as I dont wanna attempt to fix the wrong thhing and put me worse in my predicament ๐ญ
for lines 18-27, all ur if statements need to check for a value ("y")
a.k.a if ___ == "y":
...
๐ซฃ or after the ':'
nah not there :p
for lines uhhh sec lemme reopen
delete those ๐ the lines up taht
the actual if statement
18-21-24-27
๐
trying to explain it as best i can :x
when u take ur inputs on them
its assigning either the value y or n( ideally)
so the value of picnic/ snorkeling/ guided hike and boat dinner will either be y or n
and an if statement with no conditional attached to it
as long as a value is present, will always return true
if snorkeling: == 'y'
@hasty cypress im comprehending thank you sir one momment fixing my github rn ๐ญ
๐ซก
โค๏ธ
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
๐ My Code isn't working successfully