#๐Ÿ”’ Help me guys

96 messages ยท Page 1 of 1 (latest)

gilded heart
next oceanBOT
#

@gilded heart

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.

weary drift
#

What have you written so far?

#

@gilded heart

gilded heart
#

I've written nothing so far

#

oh wait

weary drift
#

You've asked a lot of similar questions to this before. There will be a lot of the same code as the others

gilded heart
#

So i should open a variable first?

weary drift
#

What do you think the order should be?

weary drift
gilded heart
#

a_member = ("yes or no")

#

like this

weary drift
#

Look at your previous code examples. How did you get the user to type something in?

gilded heart
#

input

weary drift
#

Yes exactly

#

So make sure you use that here as well

#

Use input to ask the user if they are a member
Use input to ask the user to input the product price.
Calculate the total based on whether or not they are a member
Display the price

#

These are your steps

#

Start by trying to write the code for each of those steps

gilded heart
#

I completed the first

#

two

#

steps

weary drift
#

show your code

gilded heart
#

moving on what do I do?

#
a_member = input("Are you a member: ")
product_price = int(input("what is your product price? "))
weary drift
#

Are you sure you should be using int here?

gilded heart
#

Nah

#

I think it's float

weary drift
#

Yes exactly ๐Ÿ™‚

gilded heart
#

So mobing on

#

moving

weary drift
#

Do you know how you calculate a percentage of another number?

#

Not necessarily in python

#

but if you had a calculator?

gilded heart
#

I do

weary drift
#

Ok, so what are you unsure of?

gilded heart
#

divide by 10 if I am not mistaken

#

lets say my product is 65 dollars

#

then we divide it by 10%

#

65 divide by 10%

cyan mason
#

And then pithink

weary drift
#

Not quite. What if it was 20% off?

#

65 / 20 actually gives you 5% off

gilded heart
#

So what do you mean here

#

I don't understand discounts

cyan mason
weary drift
#

You should use multiplication here

weary drift
weary drift
weary drift
#

if the cost is 65

#

we could multiply it by 0.9

#

that's 90% of the original value

#

which is the same as 10% off

gilded heart
#

okay

cyan mason
weary drift
#

or, we can multiply by 0.1, and then subtract that from the original value

gilded heart
weary drift
#

product_price - (product_price * 0.1)

gilded heart
#

Can I do this?

#

This is similar

weary drift
#

your condition isn't related to the price. It's related to whether or not they're a member

#

If they're a member, give them a discount. Otherwise, they pay full price

gilded heart
weary drift
#

What do you think you need to be checking for?

#

This is the important part

#

If they say yes, give discount

gilded heart
#

There seems to be a problem

weary drift
#

I've given you the idea, not the literal code

#

How do you compare if two things are equal in python?

gilded heart
weary drift
#

Haven't you?

#

Make a habit of looking at old code to remember things

gilded heart
#

no haven't

#

WAIT

#

SO YOU ARE TELLING ME

weary drift
#

Yes you have. I linked a thread with your own code where you use a comparison

gilded heart
#

HALLELUJAH

#

Thank you

#

Now the next part

#

Like this?

weary drift
#

The if after the else is not necessary

gilded heart
#

I can use elif?

weary drift
#

We can just assume if they don't say "yes", then they aren't a member

#

We don't need to check specifically for "no"

gilded heart
#

Oh okay

weary drift
#

Otherwise you end up with 3 situations

#

"yes"
"no"
other

#

there's really no difference between "no" and other so we can just lump them together

next oceanBOT
#
Python help channel closed for inactivity

This help channel has been closed. 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.