擅长:python、mysql、java
<p>我理解你的问题,我会给你上课的样子</p>
<pre><code>class Quote:
def __init__(self, car_make, car_model, car_type, engine_size, years_claim_free, starting_rate):
self.car_make = car_make
self.car_model = car_model
.....
#you get the idea
def engine_size_impact_on_quote(self):
#Your Code here and return something
def carType(self):
#Evaluate car type
def calculate_insurance(self):
#calculate insurance
return self.starting_rate
#Create instance of the class
johns_quote = Quote(car_make, car_model...........)
johns_insurance = johns_quote.calculate_insurance()
print(f"John's Car insurance is {johns_insurance}"
</code></pre>
<p>在处理许多参数时,请查看<a href="http://book.pythontips.com/en/latest/args_and_kwargs.html" rel="nofollow noreferrer">kwargs or args</a>。你知道吗</p>
<p>Python类可能有点混乱,我花了一段时间才真正理解它们,有大量的Python OOP教程</p>