#๐Ÿ”’ Confused Math

38 messages ยท Page 1 of 1 (latest)

rough birchBOT
#

@vivid iron

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.

sly lintel
#

what inputs did you use when your program returned 15?

#

or which 15 are you talking about? line 26?

vivid iron
#

no it cant be line 26 because the only way the "15" on output changes is when i change the line 10 number from 4

#

i changed the number 4 to 5 and the output turned to 10. xD

#

im beyond lost right now haha

thin tinsel
#

be careful setting your charge to 0

#

right now it reads if your sign is oak, but not gold, then your sign is free

#

you don't need an else in both those situations

#

if the sign is not oak or the sign is not gold, the price does not adjust at all

supple heron
#

you are printing total_charge not charge, 35 - 20

vivid iron
#

i thought with how i did it the "total_charge" would be the "price and "additional_character_charge" which would add up the "base_price(35) with the "charge" of oak and(or) gold. ๐Ÿคฃ

vivid iron
supple heron
#

It'll reset a variable to 0, which doesn't seem to be what you want to do.

#

Instead, add the values to the total charge if the conditions are met

vivid iron
#

Okay, so if i change the print to print the "price" it sends the "base_price". if i change it to "charge" it sends it with the oak and gold charge. Why would it not add up with what i have written on line 11?

vivid iron
thin tinsel
supple heron
#

The lines are evaluated at the time they are reached.
if a = 2 and b = 3 and you encounter a line that says c = a + b c gets set to 5
If later on a or b changes it doesn't get recalculated.

thin tinsel
#

!e

a = 5
b = 7
c = a + b

print(c)
a = 100
print(c)
rough birchBOT
thin tinsel
#

an example of what Grote is saying

#

variables are not dynamic this way. Just because a changed doesn't mean c updates

#

We're not storing that formula in the variable. We're simply evaluating it

vivid iron
#

okay that makes sense thank you guys. ill try to fix this stuff and come back if i get lost lol.

vivid iron
#

okay so i fixed all the other issues. ive been experimenting with this. I understand you cant use length on integers, but what other way can i represent this?

thin tinsel
#

then you can use len on that string

#

I think you've also overcomplicated your if statements to check for gold and oak

#
if wood_type == 'oak':
    charge += 20

if color == 'gold':
    charge += 15
#

this is all it needs to be

vivid iron
thin tinsel
#

well then you don't need len at all, just use the value as is

#

if it's 15 characters, then isn't that the value that you want?

#

if you were able to get the len of this, it would be 2 digits. Is that useful information?

rough birchBOT
#
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.