Click here to Skip to main content
14,173,165 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
import house
def main():
    determine_house()
    determine_phone()
    determine_car()
    def determine_house(repeat):
        house_price=float(input('Enter the price of the house you were going to pay'))
        num_beds=int(input('Enter the number of bedrooms'))
        house=house.house(house_price,num_beds)
        foo=house.get_average_price()
        woo=house.get_bedrooms()
        if foo==218000:
            if woo==2:
                return ' You are paying average price for your house '
            elif woo==1:
                return ' You are being overpriced for this house relative to bedrooms '
                determine_house(repeat-1)
            else:
                return ' you are getting a good deal for your house '
        elif foo>218000:
            return ' You are paying too much for a house in general '
        else:
            return ' You are getting a good price for this house in genereal  '
    def determine_phone(repeat):
        phone_price=float(input(' Enter the price of the phone you were going to pay '))
        type_phone=input(' Enter the type of phone ')
        phone=phone.house(phone_price,type_phone)
        voo=phone.get_average_price()
        coo=phone.get_type_of_phone()
        if coo==' Android ':
            if voo==254:
                return ' you are paying average price '
            elif voo>254:
                return ' you are being overpriced '
                determine_phone(repeat-1)
            else:
                return ' you are getting a good deal for this phone '
        elif coo==' iphone ':
            if voo==687:
                return ' you are paying average price for this phone '
            elif voo>687:
                return ' you are being overpiced for this phone '
                determine_phone(repeat-1)
            else:
                return ' you are getting a good deal for this phone '
        else:
            print('this type of phone is not supported by the engine')
    def determine_car(repeat):
        car_price=float(input(' Enter the price of the car you were going to pay '))
        model=input('Enter the model of the car youre thinking of buying')
        car=car.house(car_price,model)
        boo=car.get_average_price()
        loo=car.get_model()
        if loo==' toyota camry ':
            if boo==23947:
                return ' you are paying average price for this car '
            elif boo>23947:
                return 'you are being overpriced for this car'
                determine_car(repeat-1)
            else:
                return 'you are getting a good deal for this car'
        elif loo==' Honda Accord ':
            if boo==23720:
                return ' you are paying average price for this car '
            elif boo>23720:
                return ' you are being overpiced for this car '
                determine_car(repeat-1)
            else:
                return ' you are not getting a good deal for this house '
        else:
            return ' this model of car is not supported by the engine '

main()


What I have tried:

ive tried putting the function calls at the bottom and top

line 4, in main
    determine_house()
UnboundLocalError: local variable 'determine_house' referenced before assignment
Posted
Updated 15-May-19 6:58am
v2
Comments
Patrice T 15-May-19 12:48pm
   
Give exact error message and position.
Use Improve question to update your question.
James Rich443 15-May-19 12:50pm
   
line 4, in main
determine_house()
UnboundLocalError: local variable 'determine_house' referenced before assignment
James Rich443 15-May-19 13:19pm
   
now its telling me

determine_house()
TypeError: determine_house() missing 1 required positional argument: 'repeat' and its saying its expecting an indented block where each function is defined

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Quote:
It keeps saying my functions referenced before assignment.

In Python, indentation is the structure of your program. defining a function start with no indentation.
This should be better:
import house
def main():
    determine_house()
    determine_phone()
    determine_car()
def determine_house(repeat):
    house_price=float(input('Enter the price of the house you were going to pay'))
    num_beds=int(input('Enter the number of bedrooms'))
    house=house.house(house_price,num_beds)
    foo=house.get_average_price()
    woo=house.get_bedrooms()
    if foo==218000:
        if woo==2:
            return ' You are paying average price for your house '
        elif woo==1:
            return ' You are being overpriced for this house relative to bedrooms '
            determine_house(repeat-1)
        else:
            return ' you are getting a good deal for your house '
    elif foo>218000:
        return ' You are paying too much for a house in general '
    else:
        return ' You are getting a good price for this house in genereal  '
def determine_phone(repeat):
    phone_price=float(input(' Enter the price of the phone you were going to pay '))
    type_phone=input(' Enter the type of phone ')
    phone=phone.house(phone_price,type_phone)
    voo=phone.get_average_price()
    coo=phone.get_type_of_phone()
    if coo==' Android ':
        if voo==254:
            return ' you are paying average price '
        elif voo>254:
            return ' you are being overpriced '
            determine_phone(repeat-1)
        else:
            return ' you are getting a good deal for this phone '
    elif coo==' iphone ':
        if voo==687:
            return ' you are paying average price for this phone '
        elif voo>687:
            return ' you are being overpiced for this phone '
            determine_phone(repeat-1)
        else:
            return ' you are getting a good deal for this phone '
    else:
        print('this type of phone is not supported by the engine')
def determine_car(repeat):
    car_price=float(input(' Enter the price of the car you were going to pay '))
    model=input('Enter the model of the car youre thinking of buying')
    car=car.house(car_price,model)
    boo=car.get_average_price()
    loo=car.get_model()
    if loo==' toyota camry ':
        if boo==23947:
            return ' you are paying average price for this car '
        elif boo>23947:
            return 'you are being overpriced for this car'
            determine_car(repeat-1)
        else:
            return 'you are getting a good deal for this car'
    elif loo==' Honda Accord ':
        if boo==23720:
            return ' you are paying average price for this car '
        elif boo>23720:
            return ' you are being overpiced for this car '
            determine_car(repeat-1)
        else:
            return ' you are not getting a good deal for this house '
    else:
        return ' this model of car is not supported by the engine '

main()

Quote:
now its telling me

determine_house()
TypeError: determine_house() missing 1 required positional argument: 'repeat' and its saying its expecting an indented block where each function is defined

import house
def main():
    determine_house() # it says there is a parameter missing between parenthesis
    determine_phone()
    determine_car()
def determine_house(repeat): # because here you say a parameter is requested

So a solution is:
import house
def main():
    determine_house(1) # it says there is a parameter missing between parenthesis
    determine_phone()
    determine_car()
def determine_house(repeat): # because here you say a parameter is requested

But the same message will pop for determine_phone() for exact same reason, and once you solved it, you will have the same on determine_car().

But the whole problem is that in your case, recursion is not what you need.
looks like you barely understand how the language works and large rewrite is in order for your code.
Advice: follow some tutorial to get familiar with usual aspects of the language like parameters of functions and behavior of return.
   
v2
Comments
James Rich443 15-May-19 13:14pm
   
now its telling me

determine_house()
TypeError: determine_house() missing 1 required positional argument: 'repeat' and its saying its expecting an indented block where each function is defined

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web01 | 2.8.190524.3 | Last Updated 15 May 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100