[Tutor] Program Control

kubota2550 at gmail.com kubota2550 at gmail.com
Thu Feb 8 12:28:57 CET 2007


I am learning Python and have written several small programs of increasing
complexity but so far they are all "linear" programs meaning that they are
meant to do one thing.  I have yet to fully understand program control in
order to go to and return form modules (I think this is the correct term).
In other words, I have a menu which offers several options, I would like to
be able to combine several of my programs into seperate modules and put in
one larger program.  Then the user could select a menu item, be sent to a
module and return to the menu for another selection.  Can someone show me
how to do module or program control to accomplish the basic example below:

Main Menu
Select 1 for subtraction
Select 2 for addition
Select 3 to quit

***********************************
Subtraction module:
Enter a number
Enter a second number
Answer =Number1-Number2

Menu:

Select 1 to return to main menu
Select 2 to subract again

************************************
Addition module:
Enter a number
Enter a second number
Answer = Number1+Number2

Menu

Select 1 to return to main menu
Select 2 to add again
********************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070208/550d7c2a/attachment.htm 


More information about the Tutor mailing list