In <7ad8941d-04aa-42c5-82e9-10cdf02ab...@googlegroups.com> codyw...@gmail.com 
writes:

> I seem to be having a problem understanding how arguments and parameters
> work, Most likely why my code will not run. Can anyone elaborate on what
> I am doing wrong?

>  def get_input(kilo):
>    kilo = float(input('Enter Kilometers: '))
>    return kilo

get_input() gets all its input from the keyboard.  It doesn't need any
arguments.

>  def convert_kilo(kilo,miles):
>      miles = float(kilo * 0.6214)
>      print( kilo,' kilometers converts to ',miles,' miles')

convert_kilo() calculates miles on its own, so you don't need to pass it
as an argument.

> def main():
>    get_input()
>    convert_kilo()
>
>  main()

When calling get_input, you need to save the return value in a variable,
and then pass that variable as an argument to convert_kilo.

The updated code would look like this:

def main():
    kilo = get_input()
    convert_kilo(kilo)

def get_input():
    kilo = float(input('Enter Kilometers: '))
    return kilo

def convert_kilo(kilo):
    miles = float(kilo * 0.6214)
    print( kilo,' kilometers converts to ',miles,' miles')

main()

-- 
John Gordon                   A is for Amy, who fell down the stairs
gor...@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to