Program structure with a main() function
Defines a function called main that holds the main steps of your program. You call main() once at the end of the file, after the other functions are defined, to start the program.
Understanding Program structure with a main() function in VCE Software Development U3O1
What it does: greet is defined before main, so main can call it. Functions above main are ready to use. The call main() sits at the bottom with no indent. It runs the function once and starts the program. A def line must end with a colon. Without the colon you get a syntax error. The main function holds the main steps, such as asking for input, calling other functions and printing results. Defining main() only saves the steps. You must call main() to run them. The second option never calls it, so nothing prints. Indentation shows which lines are inside the function. Lines that are not indented are outside main.
Common mistakes: The first line of a function definition must end with a colon. It should be def main():. Python is case-sensitive, so Print is not the same as print. The step inside main() should be print('Start').
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 72–96) and word search (Modules 72–113).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
def main():Fill in the Blanks
Spot the Error
Student with a class code? Join your class →