So below is my simple code for my simple program, now I have to "Use 2 functions for this program in addition to the main program. The first function should ask for the hours and returns them to the main program. The second function should receive the hours from the main program, calculate the minutes and display them.

I tried to def hours and just break up the code that way but it didn't work. This programing business is like a foreign language to me. I'm slowly catching on though.
Thanks in advance.

def main() :
            hours = input ("How many hours do you want to convert?")
            minutes = (hours * 60)
            print "There are", minutes , "minutes in that many hours."


main()

If you want to send data to external programs, your easiest method is using sys.argv.
After executing your first program, you'd need to execute the other program with your data in the argument within your code.

import os
def main() :
            hours = input ("How many hours do you want to convert?")
            minutes = (hours * 60)
            print "There are", minutes , "minutes in that many hours."
main()
os.system('yourotherscript.py %s' % minutes)

so in the other file, you'd need;

import sys
for data in sys.argv:
    minutes = data[1]
# rest of code

My book has something to this effect. I just don't know what I would define to input back into my main program for converting hours to minutes.

def happy():
    print "Happy Birthday to You!"
def singFred():
    happy()
    happy()
    print "Happy birthday, dear Fred."
    happy()
def singLucy():
    happy()
    happy()
    print "Happy birthday, dear Lucy."
    happy()
def main():
    singFred()
    print
    singLucy()
main()

Sounds like you want something lke this:

def ask_hours():
    return input ("How many hours do you want to convert? ")

def calc_minutes(hours):
    minutes = hours * 60
    print "There are", minutes, "minutes in", hours, "hours."

def main() :
    hours = ask_hours()
    calc_minutes(hours)


main()

You have ywo types of functions here, ask_hours() returns something and calc_minutes(hours) needs an argument (hours), but shows the result and does not return anything.

Thanks Sneekula, I think that is more along the lines of what I am supposed to do. This programming is sinking in, but slowly. It's not like anything I've ever done before. Hopefully it will all come together for me.

You are on the right track. Read your tutorial, do the code samples, and try to solve the problems. Python, being an interpreter, makes it easy to quickly test the code you write. As you get a little more experienced change the code and see how it behaves.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.