title: Driving costs - functions in python- EOFerror in if __name__ == '__main__':
body: <p>I am stuck with this question:</p>
  <p>Write a function driving_cost() with input parameters miles_per_gallon, dollars_per_gallon, and miles_driven, that returns the dollar cost to drive those miles. All items are of type float. The function called with arguments (20.0, 3.1599, 50.0) returns 7.89975.</p>
  <p>Define that function in a program whose inputs are the car's miles per gallon and the price of gas in dollars per gallon (both float). Output the gas cost for 10 miles, 50 miles, and 400 miles, by calling your driving_cost() function three times.</p>
  <p>Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
  print(f'{your_value:.2f}')</p>
  <p>Ex: If the input is:</p>
  <p>20.0
  3.1599
  the output is:</p>
  <p>1.58 7.90 63.20
  Your program must define and call a function:
  def driving_cost(miles_per_gallon, dollars_per_gallon, miles_driven)</p>
  <p>The question also gets evaluated using a direct call of the function like this: <code>driving_cost(20.0,3.1599, 50.0)</code> which is the part that is broken.</p>
  <p>Here is my code so far:</p>
  <pre><code>def driving_cost(miles_per_gallon, dollars_per_gallon, miles_driven):
      return dollars_per_gallon/miles_per_gallon*miles_driven
      
  miles_per_gallon=float(input())
  dollars_per_gallon=float(input())
  
  miles=[10, 50, 400]
  for i in miles:
      print(f'{driving_cost(miles_per_gallon, dollars_per_gallon, i):.2f}')
  
  if __name__ == '__main__':
      miles_driven=float(input());
      cost=driving_cost(miles_per_gallon, dollars_per_gallon, miles_driven);
      print(f'{cost:.2f}');
  </code></pre>
  <p>If I just input values, the top section executes but if I call the function like this <code>driving_cost(20.0,3.1599, 50.0)</code> I get:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;main.py&quot;, line 4, in &lt;module&gt;
      miles_per_gallon=float(input())
  ValueError: could not convert string to float: 'driving_cost(20.0, 3.1599, 50.0)' 
  </code></pre>
  <p>I don't completely grasp the <code>if __name__ == '__main__':</code> thing either but I really don't understand why this error is occurring. Even when I include the other inputs in the <code>if __name__ == '__main__':</code> part of the program, I get that error.  Help please?</p>