#๐ Help with code:
401 messages ยท Page 1 of 1 (latest)
@hard sage
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.
Can you show the code and the input you entered and the output you get and the expected output you're supposed to get?
!code
!pastebin if that's easier for you
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
I ran your code and got this:
Number of pizza orders: 43
Number of salad: 7
Pizzas ordered: 43
Pizza cost: $ 687.57
Salad cost: 55.93
Total: $ 743.5
Discount: $ 103.13550000000001
Delivery fee: $ 20
Total amount: $ 660.3645
What are you supposed to get?
godbless I deleted it to fix it once more thank you sir. My outputs are suppose to be
Pizzas ordered: 11
Pizza cost $ 175.89000000000001
Salad cost $ 55.93
Total $ 231.82000000000002
Discount $26.3835
Delivery fee $ 20.0
Total amount due $ 225.43650000000002
supposed to be?
Guranteed to be
man that is painful
I'm assuming the float error is supposed to show something?
it took two hours to type this and im still crying im a freshman at all of this ๐ญ let me resend the whole code correctly apolgiese for my pure ignorance
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
Then you won't have to worry about code formatting in Discord
my brain is fried i read it wrong somehow
Thats why it took long
mb
Ik the else code in 28 is useless
it was my attempt to see if that would work ive been trying for so long
I love that i chose this as my profession but I can do a lot of nsfw jokes to myself right now
ok so explain this line for me:
print("\nPizzas ordered: ", whole_pies)
It seems to take the value from:
whole_pies = (total_slices + slice_pp - 1) // slice_pp
But that doesn't reflect what the actual print statement said. Especially since the answer is from the input:
num_pizzas = int(input("Number of pizza orders: "))
Okay so the print line you would like for me to explain is the pizzas ordered as the whole pizza pies. Which in theory of the code should become 11 yet it is not
Wgat does the \n do?
newline
^^^
thanks
Is 11 the user input at num_pizzas?
no number of pizzas (all slices) is suppose to be 43
ik the salad codes are correct for sure

So if I, a customer, entered my order of pizzas that I want is 43, then the display output should display 11 pizzas?
for context to every beautiful soul reading this post this is the suppose output
Seems confusing, no?
yes it 100% is.
Is this an assignment or exercise or something?
it is suppose to translate to 11 pizza pies
yes assignment exercise. But Im not in here to simply ask for cheats and answer. Im really crap out of luck and so deeply lost
So am I going to get 11 pizzas or 43 pizzas?
11 pizzas ordered ^^
to answer
That's fine. Can you share the entire assignment problem text?
yes ofcx
Just to make sure you understood the assignment
@honest sandal offtopic, but could you attempt helping me out with selenium if u are available after this? Sorry for bothering
I don't know selenium. Sorry
No worries lol
Write a Python program that will determine food costs for the KSU CCSE hackathon.
The hackathon will have pizza and salad option. The program should ask the number of
people who ordered pizza and the number of people who ordered a salad. Each person
who orders pizza is allocated three (3) slices of pizza. Each salad costs $7.99 per
person. Each whole pizza costs $15.99 and has 12 slices per pizza. Only whole pizzas
can be ordered.
If more than ten (10) whole pizzas are ordered, then there will be a 15% discount to the
pizza cost. If more than 10 salads are ordered there will be a 15% discount to the salad
cost. The delivery charge is 7% of the entire order prior to discounts or $20 minimum.
Display the number of each type of meal ordered (input is not considered as a display/output). Determine and display the number of whole pizzas needed.
Display
the cost of the pizzaโs and display the cost of salads (before any discounts). Display the
discount amount and delivery charge. Finally display the total amount due. You do not
need to round or truncate your output.
Example of input
Number of pizza orders 43
Number of salad orders 7
Example of output
Pizzas ordered: 11
Pizza cost $ 175.89000000000001
Salad cost $ 55.93
Total $ 231.82000000000002
Discount $26.3835
Delivery fee $ 20.0
Total amount due $ 225.43650000000002
if you want me to fix the post to be correct in discord and not look deformed i gotchu]
oh "pizza orders" being the number of people ordering pizzas.
I clearly didnt explain that as it states my apologies Im rereading what I typed
Such a weird assignment
it's been mind screwing me
and I couldn't neccesiarly import math
and do all that
I had to do it like this rather
So 1 person order is 3 slices.
1 pizza is 12 slices
So you need at least 4 people to order for 1 whole pizza
And that costs $15.99
If you have more than 10 pizzas (or at least 40 people ordered), then there will be a 15% discount to the pizza cost
Ok well, let's focus on the pizzas ordered
sir yes sir! lol thank you again for your time btw. but continue im reading
OK so assume that its 40 people who ordered pizza, that should get us the 10 pizzas. that doesn't get us the 15% pizza discount, right?
@hard sage
ok
Explain this line for me:
total_slices = num_pizzas * slice_pp
whole_pies = (total_slices + slice_pp - 1) // slice_pp
One whole pizza pie = the total slices (number of pizzas * slice per person)
-1 // slice per person
essentially
So if number of pizzas is 40, what is slice per person?
13.3333 but since you cant have a fraction to it
simply 13
cause 40 (number of pizzas) / by 3 (which is the 3 slices for what each person gets)
SORRY
slice per person is 3
but doing 40/3
makes 13 people getting those slices
yeah its not supposed to be dividing by slice per person
think about it
1 whole pizza is supposed to be 12 slices
which variable has 12 in it?
pizza_slices
so the formula should be?
I'm saying this line's formula is wrong
whole_pies = (total_slices + slice_pp - 1) // slice_pp
Correct it
real fast you did '''...''' to make it into the code?
!code instructions below
gotchu
print("Like this")
i feel smart for doing that right okay typing rn
print("pizza_slices + slice_pp -1) // slice_pp
?
nope
ok then
Oh i thought format was incorrect
print("pizza_slices * slice_pp -1) // slice_pp
I dont wanna act as if im simply guessing but it's fully not clicking uhm idk this other way would be correct instead then tbh.
Im gonna scroll up
and reread rq
two seconds before answer
whole_pies = (total_slices + slice_pp - 1) * slice_pp
its not suppose to be dividing but the format is correct
so then that?
^ just incase
format is ok but you still need to fix your formula
ok ok
This formula is wrong too
this one i panicked lol
I'll give you a hint, replace each "variable" with the "value" that you set
see if that makes sense
MMMMMMMMM
Sorry I gtg
FUHHHHHH
can u just give me this part cause im stil lthinking
at least with that
I can try to
go from there
i think
total_slices is correct. But the whole_pies needs to be fixed
Think of 43 * 3 // 12
good luck!
ok ok. Sir really thank you for ur time
please if u come back!
CHECK UP
I BEG
๐ thank you man
ping me to post my version when you get a final answer (it will not follow the instructions exactly in the output but that's easily changeable. Instead I will give sensical output with only two decimal digits)
(whole_pies = (total_slices * slice_pp) // pizza_slices @rich frost my bad just to clarify you mean when I finish all of it or like this step agent Q left me with. Cause I do believe it will be whats in print
I dont wanna bs that shi is gonna take the whole night as Ive been tweaking out since I got stuck here. I've been in constant loops so I wouldn't be able to properly get into the end as fast as u did my work ๐ญ ๐ญ I know teaching is only for the few but can you put me on and help a little
so I dont sit here lost
if not all good but just truthfully thats where im at rn
but i get wym
asd the whole situation
would essientally show all
just yk i cant get to all rn ๐ญ as im messing up
AHHH i thought that too i've tried to simply
burh
LMAO ik ๐ญ
the price is 15.99
mhm for a whole pizza yeah
^^
just threw a bunch of round(..., 2) in lol
I was doing that for the salads to get proper cents, but yeah doing it for pizzas now
appreciate gang if it goes well please lmk if you could work this out with me so I can be done
yeah got it all working now
with proper cents vs the shitshow that is those inaccurate floats
the trick to make this readable is to define lots of constants, and use descriptive variable names
So I should rechange some
e.g. I have those constants
PIZZA_PRICE = 15.99
SALAD_PRICE = 7.99
DISCOUNT_THRESHOLD = 10
DISCOUNT_RATE = 0.15
DELIVERY_RATE = 0.07
MINIMUM_DELIVERY_CHARGE = 20.00
SLICES_PER_PIZZA = 12
although i did do this
# Each person who orders pizza is allocated three (3) slices of pizza.
pizza_slices_desired = pizza_orders * 3
because idk
it just fits better in ur head i get wym
but when doing all that does it give the proper output of what Im not getting? or still on that?
yeah basically
can you post your whole current code?
mhm
I went to change it
but after I did that
It was still wrong ik there is more though
I think what you should do is making the constants SCREAMING_SNAKE_CASE
that will make it clearer when you are using a constant
I'm pretty sure this is wrong, but didn't think about it super thoroughly
whole_pies = (total_slices + slice_pp - 1) // slice_pp
that gets change into
this
oh I think I see how it works now
if it's exactly a multiple of 12, then adding 11 and floor-dividing will give the correct answer still
and if it's one more than a multiple of 12, then adding 11 will make it to the next multiple of 12
I just used math.ceil
thats the catch
i can't import
math
and use math.ceil
so when im trying all of this
im screwed
thats why we are here
and im trying to do all this bs
^^
well you only gotta use ceil once so no worries, that is a fine substitute
and it looks smort
k
appreciate and to change that one line u said was wrong its
no it's not wrong it's fine
I just didn't understand it at first
ok this is semantically wrong
if num_salads > discounted_pizza: ...
what I did is name that variable DISCOUNT_THRESHOLD
then it applies in meaning to both items
ok ok
well in that case how would we change the formulas to make the output finally correct? I did change it
also you can do this
discount = 0
if whole_pies > DISCOUNT_THRESHOLD:
discount += total_pizza_cost * discount_rate
if num_salads > DISCOUNT_THRESHOLD:
discount += total_salads_cost * discount_rate
two seconds running to restroom but im still here!!!
hours
digest this
incremting the total_pizza_cost * discount rate
so how would that change much then? as keeping it equal too only and adding that value keep the same output?
Copy copy
there is someone grading your work afterall
ok the order in which you do things is confusing
how so, what can I fix to make it understandable
you make the values, then do something that depends on only those values later
after going through some other fluff
rather, I could have them together and be much more neat you're saying? From my eyes, I only wrote all this way as his wants for each step but I'm grasping what your saying would help much better
I think calling it the "total" pizza cost is kinda misleading
I feel like a total means everything in, like discounts and such
could just be me
maybe prediscount_pizza_cost or something
what next would be better to fix?
I think this is wrong
total_pre_discount = pre_discount_charge - (pizza_discount + salad_discount)
why would the prediscount total incorporate the discounts?
I saw it as to connect to the entire total of the calculations with the codes up at 32-34. But what woudl be better instead
plus after I wanted to connect it with the delivery fee
to add it as like the final total sum
but yes sounds too much fluff
what would be better then? @rich frost
remember a lot of this is new to me so as I been learning codes some is simply
rewriting step by step when im sure it can be abbreivated
and with these tweaks to make it less fluff, will it make me setup my output to be simpler shown and the same the example output
cause thats what is scaring me mostly
we use an app where the AI reads it and makes sure it gives the correct output
so sometimes im not sure if he is grading it fully in each code writing
which is why im more scared
to fix the output problem
but please this advice
helps more for future coding
@rich frost
but why do you need to do that?
I cant give you an educated answer other than that's what reassured me to at least make sure the codes works
ok wait I see
^
"throwing extra"?
Without messing it up i mean
erroring?
yes
what IDE are you using?
pycharm
ok lemme look up the pycharm equivalent of this
๐ thank you bro ik i keep saying that but this shi been long
messing up too much ๐ญ
ok click on the variable name
then press F6
deselect "Search in comments and strings"
then replace with the new variable name
okay now what I changed it to total_with_discount
ok so what are we talking about again
the output must be
exactly that
with the same input
now since i can't use import math & math.ceil
i need help with the proper equation
in order for it to work
I thought you already got the equation?
show output again
Example of output
Pizza cost $ 175.89000000000001
Salad cost $ 55.93
Total $ 231.82000000000002
Discount $26.3835
Delivery fee $ 20.0
Total amount due $ 225.43650000000002 ```
MY output is putting this:
```Pizzas ordered: 43
Pizza cost: $ 687.57
Salad cost: 55.93
Total: $ 743.5
Discount: $ 103.13550000000001
Delivery fee: $ 52.045
Total amount: $ 692.4095```
it needs to match with top
I think we should start from the beginning, and work through the code until we find the source of the first problem
pastebin current code
(the wrong amount of pizzas ordered)
@rich frost
LMAOOOOO
good looks twin
i just wanna get this done
its killing me deep
thank you
PLS dont expose me now LMAOOOOOOO
in-game
LMAOOOOOO cant report now
yes its saved
AHA
??
whole_pies = (total_slices + slice_pp - 1) // slice_pp
slice_pp is wrong
whole pies are groups of 12
your poorly named pizza_slices
YOOOOOOOOOOO
YOOOOOOOOOOOOOOOO
OK OK
WAIT
I CAN
LITERALLY
AND NON RELATIONSHIP OR ANY FREAKY FRISDAY WAY
CAN KISS
UUUU
SIR
I CAN SLEEP
YOU RELEASED MY TRAPPED SOUL
YOU SEXY MAN
k
power of reading
ik crazy words were saved
but please
bottom of heart
thank you
I actually
was sad
for the longest
i ran around my room rn
my bed has been calling me
U R THE GOAT
yw
@rich frost
I could hug u no bs
goodnight me dear friend I loved this whole journey us 3 made
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.
๐ Help with code: