#๐ In need of help figuring this out
23 messages ยท Page 1 of 1 (latest)
@blazing wedge
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.
Goal: Learn to use control flows to obtain conditional results.
Assignment: Assume the variable x has been assigned a float. Write code that assigns the absolute value of x to the variable value without using the built-in abs function.
Note: The absolute value of a number is the number without the sign. For example:
if x is -3, your code will assign 3 to value
if x = 99, your code will assign 99 to value
Do you know how to write an if statement?
It's a lot to remember but is it if x > y ?
That's not a complete statement. Let's start with this: goto you book, notes, whatever and find a complete example of an if / else statement and paste it here
Then we'll modify it to do what you want
if sales > 50000:
โ bonus = 500.0
โ commission_rate = 0.12
โ print('You met your sales quota!')
this is from the Python textbook
Is it the final number?
absolute value is a math term. Are you not familiar with what it means?
it's been a minute and I don't remember
Ah. Absolute value means: if it's negative, make it positive
So, absolute value of -10 is 10
Absolute value of 10 is also 10
would it be vice-versa or does it always make the numbers into positives
Always positive
ok
They say that 'x' is a float (a number), and you need to make 'value' equal to the absolute value of x
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.