Learning Modules, Arguments, Parameters (imma noob)

Cody Cox codywcox at gmail.com
Fri Sep 25 15:03:43 EDT 2015


#Cody Cox
#9/16/2015
#Programming Exercise 1 - Kilometer Converter
#Design a modular program that asks the user to enter a distance in kilometers and then covert it to miles
# Miles = Kilometers * 0.6214


def main():
    #set the variable to 0.0, makes it a float and creates a place in memory for the variable.
    kilo = 0.0
    
'''
    this I am not sure about, I set Kilo=get_input(kilo), but why do I need the argument when
    I am going to pass it to convert_to_kilometers? but the program works so I am guessing that is where it is saving
     the variable in order to be passed? so it needs to be returned as an argument to be passed as an argument for
     the next call???
    
'''
    kilo = get_input(kilo)

    convert_to_kilometers(kilo)

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

def convert_to_kilometers(kilo):
    miles = kilo * .6214
    print(kilo,'Kilometers converts to: ',miles, ' Miles.')

main()

'''
This was a great learning experience trying to understand modules
and how parameters & arguments work together.
Thanks for helping me understand
'''



More information about the Python-list mailing list