You are viewing our Forum Archives. To view or take place in current topics click here.
Can someone help me with my coding program?! HELP
Posted:

Can someone help me with my coding program?! HELPPosted:

OG_NickB
  • V5 Launch
Status: Offline
Joined: Mar 22, 201410Year Member
Posts: 166
Reputation Power: 6
Status: Offline
Joined: Mar 22, 201410Year Member
Posts: 166
Reputation Power: 6
Hey guys, I have a program I need to run for one of my classes and I cannot figure out the error when I run it through Python (That's the OS for my class). I'll post the script below and was wondering where you guys could help me fix the error. I would greatly appreciate it! Thanks.

Instructions: A county collects property taxes on the assessment value of property,
which is 60 percent (0.6) of the propertys actual value. For example, if an acre of land
is valued at $10,000, its assessment value is $6,000. The property tax is then 72 for
each $100 (0.0072) of the assessment value. The tax for the acre assessed at $6,000
will be $43.20. Write a program that asks for the actual value of a piece of property and
to display the assessment value and property tax.

def askForActualValueOfProperty() :
actualValueOfProperty = float( input( "What's the actual value" + \
" of the property: " ) )
return actualValueOfProperty

def calculateAssessmentValue ( actualValueOfProperty ) :
assesmentValueOfProperty = ( 60 / 100 ) * actualValueOfProperty
return assessmentValueOfProperty

def calculatePropertyTax ( assessmentValue ) :
propertyTax = ( assesmmentValue / 100 ) * 0.72
return propertyTax

def printDetails ( userActualValueOfProperty, assessmentValueOfProperty,\
propertyTax ) :

print( "Actual Value of Property: $" + \
format( userActualValueOfProperty, ",.2f" ) + "\nAssessment" + \
(" Value of Property: $") + \
format( assessmentValueOfProperty, ",.2f" ) + "\nProperty tax: $" + \
format( propertyTax, ",.2f" ) )

def main() :
userActualValueOfProperty = askForActualValueOfProperty()
assesmentValueOfProperty = calculateAssesmentValue( userActualValueOfProperty )
propertyTax = calculatePropertyTax( assessmentValueOfProperty )
printDetails( userActualValueOfProperty, assessmentValueOfProperty, \
propertyTax )
main()
#2. Posted:
tortuga
  • TTG Addict
Status: Offline
Joined: Dec 25, 200914Year Member
Posts: 2,314
Reputation Power: 1686
Status: Offline
Joined: Dec 25, 200914Year Member
Posts: 2,314
Reputation Power: 1686
A few things first.

Please put your code inside of a code block. You should do that for any code you post, but Python is a white-space sensitive language, so formatting is especially important in its case. Do you really expect me to add proper white-space to your code just so I can run it through the interpreter?

You should also always include the error you receive when running your program. Don't make us run the code just to get your error.

Also Python is not an OS. The abbreviation OS stands for operating system. Python is a language.

Your code looks fine, except for the way you're formatting strings. You should Google how to format strings in Python and modify your code appropriately. It's not too different than what you have now. Lettuce know how that goes. That's interesting, I never knew you could format strings like you're doing in Python. I thought you had to call #format on the string!


Last edited by tortuga ; edited 1 time in total
#3. Posted:
Clydey
  • TTG Senior
Status: Offline
Joined: Aug 03, 201013Year Member
Posts: 1,484
Reputation Power: 62
Status: Offline
Joined: Aug 03, 201013Year Member
Posts: 1,484
Reputation Power: 62
The code was fine, you just had a hard time deciding what way to spell 'assessment' haha.

Here is the fixed code:

'''
Instructions: A county collects property taxes on the assessment value of property,
which is 60 percent (0.6) of the propertys actual value. For example, if an acre of land
is valued at $10,000, its assessment value is $6,000. The property tax is then 72 for
each $100 (0.0072) of the assessment value. The tax for the acre assessed at $6,000
will be $43.20. Write a program that asks for the actual value of a piece of property and
to display the assessment value and property tax.

'''

def askForActualValueOfProperty() :
   actualValueOfProperty = float( input( "What's the actual value" + " of the property: " ) )
   return actualValueOfProperty

def calculateAssessmentValue ( actualValueOfProperty ) :
   assessmentValueOfProperty = ( 60 / 100 ) * actualValueOfProperty
   return assessmentValueOfProperty

def calculatePropertyTax ( assessmentValue ) :
   propertyTax = ( assessmentValue / 100 ) * 0.72
   return propertyTax

def printDetails ( userActualValueOfProperty, assessmentValueOfProperty, propertyTax ) :
   print( "Actual Value of Property: $" + format( userActualValueOfProperty, ",.2f" ) + "\nAssessment" + (" Value of Property: $") + format( assessmentValueOfProperty, ",.2f" ) + "\nProperty tax: $" + format( propertyTax, ",.2f" ) )

def main() :
   userActualValueOfProperty = askForActualValueOfProperty()
   assessmentValueOfProperty = calculateAssessmentValue( userActualValueOfProperty )
   propertyTax = calculatePropertyTax( assessmentValueOfProperty )
   printDetails( userActualValueOfProperty, assessmentValueOfProperty, propertyTax )
main()
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.