#๐ Homework assignment chapter 5
87 messages ยท Page 1 of 1 (latest)
@sand wave
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.
need some help rewriting it
why rewrite it
or do u mean refactoring it so stuff is in functions like it asked ?
yeah
thats what i meant
what would be a good start
@humble zinc you able to help?
well first of all, what are all the subtasks
thats an amazing question actually
would it be one of the tax types?
i suppose so in this case 
Amountspent = float(input("Enter Amount: "))
Statetaxrate = 0.05
print(f"State sales tax: {Statetaxrate:.1%}")
Countytaxrate = 0.025
Statetax = Amountspent * Statetaxrate
Countytax = Amountspent * Countytaxrate
print(f"County sales tax: {Countytaxrate:.1%}")
Totaltax = Statetax + Countytax
Totalsale = Amountspent + Totaltax
print("State sales tax: $", format(Statetax, ",.2f"))
print("County sales tax: $", format(Countytax, ",.2f"))
print("Total sales tax: $", format(Totaltax, ",.2f"))
print("Total sale: $", format(Totalsale, ",.2f"))
Hey @sand wave!
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
thats my original code
so what kind of taxes we got here
so those are our subtasks
one calculates county tax
one calculats state tax
one calculates total tax
yep.
so make 3 functions to start off, 1 for each of those subtasks 
ok bett
i'd use def
right?
yes
its very simple actually
def function_name(function_paramaters):
# function code goes here
# do note the indent
# these comments are inside function
# this one is not
ye
.
u missing 3 key details, the () the : and the indents
yup those bottom 2 look good
i think I might have mixed it up
ok
uhhh
is there anything else i have to do now
to complete the question
well u have to make the code work just like before now
first of all, calculate_state_tax, is the code inside that function calculating state tax ? 
now what about calculate_state_tax, thats one of the subtasks we need as function
how would i
what do i change about it?
well first of all, make the def syntax like the others so its valid syntax
second of all, make the code inside the actual state tax calculation
how would i go about that
I would do
state_tax = amount*Statetaxrate
calculating state tax should have been exercise #6 in chapter 2
i got no clue of specifics
I think i added it
this shoudl work hopefully
@humble zinc ok so
i tried reworking it
and NOTHING WORKED
at all
so i reverted back to what i originally had
Whats the best way to go about this
hellooooo how can I help
you still need help ??
Your calculation of tax is the same in all cases. Might just want to have a single tax-calculating function.
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.