-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpredict.py
More file actions
33 lines (22 loc) · 707 Bytes
/
predict.py
File metadata and controls
33 lines (22 loc) · 707 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
27
28
29
30
31
32
33
# estimatePrice(mileage) = θ0 + (θ1 ∗ mileage)
import sys
def get_parameters():
try:
file = open('output.txt')
content = file.readlines()
theta0 = content[0].strip()
theta1 = content[1].strip()
except:
theta0, theta1 = 0, 0
return theta0, theta1
def estimatePrice(theta0, theta1, milage):
return theta0 + (theta1 * milage)
if __name__ == "__main__":
if len(sys.argv) != 2:
sys.exit("Write your milage as a argument!")
try:
float(sys.argv[1])
except:
sys.exit("Write only float")
theta0, theta1 = get_parameters()
print(estimatePrice(float(theta0), float(theta1), float(sys.argv[1])))