-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathestimate.py
More file actions
26 lines (24 loc) · 847 Bytes
/
estimate.py
File metadata and controls
26 lines (24 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import pandas as pd
class Estimate:
def __init__(self, thetas_path="thetas.csv"):
self.path = thetas_path
self.theta0 = 0
self.theta1 = 0
self.get_thetas()
def get_thetas(self):
try:
with open(self.path, 'r') as file:
self.data = pd.read_csv(file)
self.theta0 = self.data["theta0"].iloc[0]
self.theta1 = self.data["theta1"].iloc[0]
except:
print("! Warning, no data has been found")
def estimate_price(self, mileage):
return self.theta0 + (self.theta1 * mileage)
estimate = Estimate()
try:
input = int(input("Please enter the mileage of your car: "))
except:
print("! Wrongs args format")
else:
print("The estimated price for a", input, "kilometers car is :", estimate.estimate_price(input))