#๐Ÿ”’ Homework assignment chapter 5

87 messages ยท Page 1 of 1 (latest)

sand wave
silver ferryBOT
#

@sand wave

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.

sand wave
#

need some help rewriting it

humble zinc
#

or do u mean refactoring it so stuff is in functions like it asked ?

sand wave
#

thats what i meant

sand wave
sand wave
#

@humble zinc you able to help?

humble zinc
sand wave
#

would it be one of the tax types?

humble zinc
sand wave
#

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"))

silver ferryBOT
#

Hey @sand wave!

Please edit your message to use a code block

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
sand wave
#

thats my original code

humble zinc
#

so what kind of taxes we got here

sand wave
#

state tax

#

total tax

humble zinc
#

so those are our subtasks

#

one calculates county tax

#

one calculats state tax

#

one calculates total tax

sand wave
#

yep.

humble zinc
#

so make 3 functions to start off, 1 for each of those subtasks pithink

sand wave
#

ok bett

humble zinc
#

yes

sand wave
#

so

#

ughh

#

im confused on how to use it

#

def

humble zinc
sand wave
humble zinc
#
def function_name(function_paramaters):
    # function code goes here
    # do note the indent
    # these comments are inside function
# this one is not
sand wave
#

ok

#

so i remove the def amount spent

#

right?

humble zinc
sand wave
#

what else would i do

#

from here

humble zinc
#

look at how i wrote it pithink

sand wave
#

so lik this?

humble zinc
#

u missing 3 key details, the () the : and the indents

humble zinc
#

yup those bottom 2 look good

sand wave
#

i think I might have mixed it up

#

ok

#

uhhh

#

is there anything else i have to do now

#

to complete the question

humble zinc
#

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 ? pithink

sand wave
#

fixed

humble zinc
# sand wave

now what about calculate_state_tax, thats one of the subtasks we need as function

sand wave
#

what do i change about it?

humble zinc
#

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

sand wave
#

I would do

#

state_tax = amount*Statetaxrate

humble zinc
#

i got no clue of specifics

sand wave
#

I think i added it

sand wave
#

@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

wheat apex
#

hellooooo how can I help

red otter
#

you still need help ??

sweet hull
#

Your calculation of tax is the same in all cases. Might just want to have a single tax-calculating function.

silver ferryBOT
#
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.