#๐Ÿ”’ My Code isn't working successfully

104 messages ยท Page 1 of 1 (latest)

ashen gulchBOT
#

@lyric vessel

Python help channel opened

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.

static viper
#

Is the picture what you want or what you're getting?

lyric vessel
static viper
#

Ok and what do you want?

lyric vessel
#
 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

static viper
#

In your code you never print meal cost or excursion cost, ist that from the same problem?

lyric vessel
#

@static viper some dumb shi happened in my crib

#

Apologies two seconds

lyric vessel
#

Did it wrong on my phone ๐Ÿ˜ญ

lyric vessel
#

@static viper back

#

is that what you mean though?

hasty cypress
#

you sure u linked the right code?

lyric vessel
#

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

#

๐Ÿซก

hasty cypress
#
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? ๐Ÿ˜ฎ

lyric vessel
#

no no sexy

hasty cypress
#

seems like they arent related

lyric vessel
#

def this

hasty cypress
#

thats whats on the link u posted :x

lyric vessel
#

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```
lyric vessel
hasty cypress
#

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"

lyric vessel
#

Ahhhh

#

@hasty cypress you trying to say all those y/n questions

#

do

hasty cypress
#

ya

lyric vessel
#

๐Ÿ˜‰

#

two seconds

#

@hasty cypress ngl struggling do I put it after the ") at the end of the line

#

or outside the parentheses

hasty cypress
#

for which line

lyric vessel
#
    snorkeling  = input("Snorkeling  [y/n]: ")
    guided_hike = input("Guided Hike [y/n]: ")
    boat_dinner = input("Boat Dinner [y/n]: ")```
ashen gulchBOT
#

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.
lyric vessel
#

these

hasty cypress
#

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

lyric vessel
hasty cypress
#

it'll still be wrong, in the meal_cost fuction the math.ceil function rounds the value. you dont want to round it

lyric vessel
#

it into return total?

hasty cypress
#

yep

lyric vessel
#

๐Ÿ˜… 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 ๐Ÿ˜ญ

hasty cypress
#

for lines 18-27, all ur if statements need to check for a value ("y")

#

a.k.a if ___ == "y":
...

lyric vessel
hasty cypress
#

nah not there :p

#

for lines uhhh sec lemme reopen

#

delete those ๐Ÿ™‚ the lines up taht

#

the actual if statement

#

18-21-24-27

lyric vessel
#

๐Ÿ˜…

hasty cypress
#

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

lyric vessel
#

if snorkeling: == 'y'

hasty cypress
#

yaya

#

nonono

#

put the : at the end

#

if snorkeling == "y":

lyric vessel
#

@hasty cypress im comprehending thank you sir one momment fixing my github rn ๐Ÿ˜ญ

hasty cypress
#

๐Ÿซก

lyric vessel
#

@hasty cypress ๐Ÿซก

#

guess what worked ๐Ÿ˜œ

#

thank you bro heavy

hasty cypress
#

โค๏ธ

lyric vessel
#

can have a calm sat night now

#

โค๏ธ

ashen gulchBOT
#
Python help channel closed

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