Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
April 13th, 2012, 08:44 PM
 cydex222
Registered User

Join Date: Mar 2012
Posts: 8
Time spent in forums: 1 h 19 m 58 sec
Reputation Power: 0

Hello,I am reading Python book "Starting Out with Python(2009.)".I am on the part with the functions,just finished em and doing some
exercises given in book.I have a question about one thing.English is not my native language ,sry for any mistake.

This is the text of the exercise:
--------------------------------------------------------------
A country collects property taxes on the assessment value of property,which is 60 percent
of the property's 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 64c for each \$100 of the assessment
value.The tax of the acre assessed at \$6,000 will be \$38.40.Write a program that asks
for the actual value of a piece of property and displays the assessment value and property
tax.
--------------------------------------------------------------
I know how to do this without using functions,but that's not what I am aiming for.

This is my program:
--------------------------------------------------------------
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
>>> def main():
value_of_the_property=input("Enter actual value of the property:")
assessment_value(value_of_the_property)
property_tax()
print
print"PRESS ANY KEY TO CONTINUE..."
program_break=raw_input()

>>> def assessment_value(value_of_the_property):
assessment_value=value_of_the_property*0.6
print"Assessment value of the property is %.2f\$."%assessment_value

>>> def property_tax():
property_tax=(assessment_value/100.00)*0.64
print"Property tax is %.2f\$."%property_tax

>>> main()
--------------------------------------------------------------
Sry for showing u the code like this I don't know how to upload a pic. :P

This is the question:
--------------------------------------------------------------
Is there any way to load assessment_value from assessment_value(value_of_property) function
to property_tax() function cuz I need it to calculate property_tax.I know that these variables are local and can be
used only in function they are declared.Do u know any way to load that variable or any other way to write this prog but with
using functions only.
--------------------------------------------------------------

One more question:
I wanna know how to insert an image in the post.
I clicked on insert image and it says "Enter the text to be formatted",but that will only convert it to pic,I've seen ppl uploading pictures with source code in IDLE.
--------------------------------------------------------------

#2
April 13th, 2012, 09:24 PM
 b49P23TIvg
Contributing User

Join Date: Aug 2011
Posts: 4,174
Time spent in forums: 1 Month 3 Weeks 2 Days 11 h 48 m 49 sec
Reputation Power: 455
return statement

You need the return statement.

Also, we wouldn't want python code as a picture. The tools to translate picture to text aren't so hot. python code is still more useful as text. Instead, surround
[ c o d e ]
[ / c o d e ]
but without the space characters. Or follow the link at my signature for a different explanation.

Code:
```def main():
value_of_the_property = input("Enter actual value of the property:")
assessment = assessment_value(value_of_the_property)
print"Assessment value of the property is %.2f\$."%assessment
print"Property tax is %.2f\$."%property_tax(assessment)
print
print"PRESS <<<<ENTER>>>> TO CONTINUE..."
program_break=raw_input()

def assessment_value(value_of_the_property):
assessment = value_of_the_property*0.6
return assessment

def property_tax(assessment):
tax = (assessment/100.00)*0.64
return tax

if '__main__' == __name__:
main()```
__________________
[code]Code tags[/code] are essential for python code!

#3
April 14th, 2012, 04:58 AM
 cydex222
Registered User

Join Date: Mar 2012
Posts: 8
Time spent in forums: 1 h 19 m 58 sec
Reputation Power: 0
thanx a lot

 Viewing: Dev Shed Forums > Programming Languages > Python Programming > Newbie task