<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 24, 2015 at 2:45 PM,  <span dir="ltr"><<a href="mailto:codywcox@gmail.com" target="_blank">codywcox@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I seem to be having a problem understanding how arguments and parameters work, Most likely why my code will not run.<br>
Can anyone elaborate on what I am doing wrong?<br>
<br>
'''<br>
Cody Cox<br>
9/16/2015<br>
Programming Exercise 1 - Kilometer Converter<br>
Design a modular program that asks the user to enter a distance in kilometers and then convert it to miles<br>
Miles = Kilometers * 0.6214<br>
'''<br>
<br>
def main():<br>
   get_input()<br>
   </blockquote><div>Change the above call to:</div><div>      kilos = get_input()</div><div>This is because your function returns that value</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">   convert_kilo()<br></blockquote><div>This one you need to pass the kilos argument, and you don't need to pass the miles parameter (see below)</div><div>       convert_kilo(kilos) </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
 def get_input(kilo):<br></blockquote><div>You defined get_input with no parameters, so it gets no arguments when you call it:</div><div>    def get_input(): </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
   kilo = float(input('Enter Kilometers: '))<br>
   return kilo<br>
<br>
 def convert_kilo(kilo,miles):<br></blockquote><div>Make the above:</div><div>    def convert_kilo(kilo): </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
     miles = float(kilo * 0.6214)<br>
     print( kilo,' kilometers converts to ',miles,' miles')<br>
<br>
 main()<br></blockquote><div><br></div><div>When you define a function, the names between the parentheses are called parameters.  When you call the function, they are called arguments.  They need to match.  When you return a value from a function, you need to put a name to it, or it is lost. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888">--<br>
<a href="https://mail.python.org/mailman/listinfo/python-list" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Joel Goldstick<br></div><a href="http://joelgoldstick.com" target="_blank">http://joelgoldstick.com</a><br></div></div>
</div></div>