Thread: Newbie task

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    8
    Rep Power
    0

    Newbie task


    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
    Type "copyright", "credits" or "license()" for more information.
    >>> 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've seen ppl uploading images of their source codes.
    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.
    --------------------------------------------------------------

    PLZ reply
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481

    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 ]
    your program text with
    [ / 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 and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    8
    Rep Power
    0
    thanx a lot

IMN logo majestic logo threadwatch logo seochat tools logo