Python Forum
Value Estimator Calculator getting a TypeError
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Value Estimator Calculator getting a TypeError
#1
Greetings. I am working on creating a calculator in python. My objective is to create a basic calculator to return the repair value and estimated profit. I keep getting error messages. Here is my code below along with the error message.

 print("Welcome to Value Estimator") Value_1 = int(input("Please enter the value of target home:")) a1 = int(input("Please enter the value of the sales price of home #1:")) a2 = int(input("Please enter the sales price of home #2:")) a3 = int(input("Please enter the sales price of home #3:")) a4 = int(input("Please enter the sales price of home #4:")) a5 = int(input("Please enter the sales price of home #5:")) avg_sales_price = (a1 + a2 + a3 + a4 + a5)/ 5 print("Average sales price for homes in area is", avg_sales_price) ARV = str(avg_sales_price) print("The ARV for this home:" + ARV) def repair_cost(): if Value_1 <= 30000: repair_cost = (60000) - (Value_1) elif Value_1 >= 30000: repair_cost = (Value_1) + 17000 repair_cost(Value_1) profit = str(avg_sales_price) - str(Value_1) - str(repair_cost)
Error:
Traceback (most recent call last): File "C:/Users/Cupid/AppData/Local/Programs/Python/Python37/spreadsheet.py", line 33, in <module> repair_cost(Value_1) TypeError: repair_cost() takes 0 positional arguments but 1 was given
Reply
#2
repair_cost(Value_1) has been passed a variable but the function def repair_cost(): does not except one.

Also further issues
repair_cost has been used as a function name and a variable name
values are turned into strings to do calculations.

Change
def repair_cost():
to
def calc_repair_cost(Value_1):
Add return repair_cost to the end of function calc_repair_cost

Change
repair_cost(Value_1)
to
repair_cost = calc_repair_cost(Value_1)
Remove the string conversions from
profit = str(avg_sales_price) - str(Value_1) - str(repair_cost)
Reply
#3
Thank you for your help, i am trying to add an additional function onto the end that tells me whether a home is a good investment or not, but I am not getting the result that i am looking for. Here is my code

print("Welcome to Value Estimator") Value_1 = int(input("Please enter the value of target home:")) a1 = int(input("Please enter the value of the sales price of home #1:")) a2 = int(input("Please enter the sales price of home #2:")) a3 = int(input("Please enter the sales price of home #3:")) a4 = int(input("Please enter the sales price of home #4:")) a5 = int(input("Please enter the sales price of home #5:")) avg_sales_price = (a1 + a2 + a3 + a4 + a5)/ 5 print("Average sales price for homes in area is", avg_sales_price) ARV = str(avg_sales_price) print("The ARV for this home:" + ARV) def calc_repair_cost(Value_1): if Value_1 <= 30000: repair_cost = (60000) - (Value_1) elif Value_1 >= 30000: repair_cost = 20000 return repair_cost repair_cost = calc_repair_cost(Value_1) print("The repair cost for the home is:", + repair_cost) total_investment = Value_1 + repair_cost def home_rating(Value_1): if total_investment >= 60000: home_rating = False elif total_investment <= 60000: home_rating = True return home_rating worthy_investment = home_rating(Value_1) if home_rating == True: print("This home is worth a look") elif home_rating == False: print("This is not a good home") 
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using ID3 Estimator for Decision Trees student6306 2 2,113 Jun-13-2023, 07:39 PM
Last Post: student6306
  Value Estimator Calculator jaycuff13 1 2,783 Apr-03-2019, 12:52 PM
Last Post: j.crater

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.