DoAssignment study guide

C2.1 · Organize programs and files logically

Learn to organize programs and files logically through clear examples and targeted practice.

Ontario Grade 11 Computer Science

Computer Environments and Systems

A practical approach to keeping a computer science project clear and easy to work with

A computer project can contain more than one program file, along with materials such as instructions or sample data. If everything is placed together with unclear names, it can be hard to find the part you need. Organizing programs and files logically means arranging related materials in a way that makes their purpose and relationship understandable. This lesson focuses on that practical skill. The 2008 Ontario ICS3U expectation C2.1 is the guide: the examples below are approaches for meeting it, not additional official rules. Python 3 appears in one example; classrooms may use other languages.

What you will learn

  • Explain what it means to organize a program and its files logically.
  • Group related files and use clear, consistent names.
  • Describe how a simple Python 3 program can use a function stored in another file.
  • Check whether a project’s organization makes its contents easy to locate and understand.

1. Start with purpose and relationships

Before choosing where files belong, identify the purpose of the project and what materials it needs. For a classroom project that calculates a club’s meeting costs, the program might include the part that asks for information and displays a result. A separate file might hold a small calculation that is reused by the main program. An instruction file could explain how to provide the information.
The organizing question is simple: would someone opening the project be able to tell what each file is for and find related files without guessing? Put materials with related purposes together, and give files names that describe their contents. For example, meeting_costs.py is more informative than newfile.py. The exact naming style is a choice; the important point is that it is clear and used consistently.
A folder can group the files belonging to one project so they are not mixed with unrelated work. If a project needs different kinds of materials, separate folders can make those groups clearer. Do not add folders just to make the project look complicated: each group should have a recognizable purpose.
  • Identify the project’s purpose before arranging its files.
  • Keep related materials together and distinguish unrelated work.
  • Choose names that help a reader recognize a file’s purpose.
  • Use folders when they clarify groups of project materials.

2. Make the structure understandable

A logical arrangement communicates how the pieces fit together. In a small program, one file may contain the main interaction while another contains a related calculation. A reader should be able to connect those roles from the file names and, where useful, from the program’s use of them. Keep the arrangement as simple as the project allows.
A consistent naming style helps people compare and locate files. Avoid names that differ only by an unclear number or vague word, such as final.py, final2.py, and newest.py. If a project needs more than one version, use names that explain the difference in a way the class can understand. Do not rely on a name alone to explain the entire project; instructions can clarify how the files relate.
A useful review is to imagine handing the project to a classmate. Can they identify the main program? Can they locate related files? Can they tell which materials belong to this project rather than another one? If not, revise the names or grouping. These are practical checks, not a required folder layout imposed on every project.
  • Use names that distinguish files meaningfully.
  • Let grouping and names work together to show purpose.
  • Keep the structure appropriate to the project’s size.
  • Review the arrangement from another reader’s point of view.

3. Connect organization to a small program

The next example shows one possible relationship between two Python 3 files. The main file asks for a number and presents a result; a second file contains a related calculation. In Python, an import can refer to another file whose name ends in .py. This is a Python-specific example of how a clear file arrangement can match the parts of a program. Other classroom languages may organize program parts differently.
Inputs are the number entered by the user and the program files in the project. The process is to import the calculation function, read the number, calculate the cost, and display it. For an input of 4, the helper function multiplies 4 by 3, producing 12; the main file then displays the result. This is a trace of the shown code, not a claim that it was run.
The file names help explain the relationship: club_cost.py contains the calculation, and main.py contains the interaction. The function name cost_for_members also describes its task. A small project might keep the calculation in the main file instead; splitting files is useful only when the separation makes the project clearer.
  • A file’s name and contents should have a recognizable purpose.
  • In Python 3, import can connect a program file to another Python file.
  • For the example input 4, the displayed result is 12.
  • Use multiple files when the grouping makes the program easier to understand.

4. Review and improve the arrangement

Check the project as a whole, not only the line of code you are currently writing. Confirm that the files for the project are together, that each name helps identify its contents, and that any instructions or sample materials are easy to distinguish from program files. Remove confusion by improving a name or grouping rather than adding structure without a purpose.
A trace can also check that a proposed file split still makes sense. For the Python example, the input value is 4; the helper calculation changes it to 12; the main program displays 12. If a reader cannot tell which file supplies that calculation, the file relationship needs clearer names or explanation.
Practice on a small project: list its files, write a brief purpose for each, and group related items. Then ask a partner to locate the main program and a named supporting file. If they need to guess, revise the arrangement. This practice directly supports the expectation to organize programs and files logically.
  • Review names, grouping, and the relationship between program files.
  • Use a trace to explain what happens across the example’s files.
  • Revise unclear organization so another person can locate project parts.

Trace of the two-file Python example

Point in the traceValue or action
User inputmembers = 4
Calculation in club_cost.py4 multiplied by 3 gives 12
Value returned to main.pytotal = 12
Displayed outputTotal: 12

Worked example

Plan a small project’s files

A student is preparing a program that asks for a club member count and calculates a meeting cost. The project also needs brief instructions for a classmate. Suggest a clear grouping and file names.
  1. Identify the project materials
    The project has program code and instructions. Keep both with the project so a classmate can find the materials needed to understand it.
  2. Name files by purpose
    Use names such as main.py for the program’s interaction and instructions.txt for the brief directions. These are proposed descriptive names, not mandatory names.
  3. Check the result
    A reader should be able to identify the program and its instructions from the names. If the project later gains another related program file, keep it with this project and name it for its role.
Answer: Keep the project materials together, for example in a folder named club_meeting_cost. Use main.py for the interaction and instructions.txt for directions. The names tell a reader what to look for.
Check: The folder name identifies the project, and the file names distinguish program code from instructions.

Worked example

Connect two Python 3 files

A club meeting-cost program uses a cost of 3 units per member. Organize the calculation separately from the interaction and trace the result when the user enters 4.

Python 3

# club_cost.py
def cost_for_members(members):
    return members * 3

# main.py
from club_cost import cost_for_members
members = int(input("Members: "))
total = cost_for_members(members)
print("Total:", total)
  1. Give each file a role
    Place the calculation in club_cost.py and the interaction in main.py. In this Python 3 example, the main file imports a function from the other file.
  2. Trace the input
    The input is the integer 4. The function receives 4 as members and returns members multiplied by 3, so its result is 12.
  3. Derive the displayed result
    The main file stores the returned value in total and prints it with a label. The resulting output line is Total: 12. This result follows by tracing the code; it was not produced by executing it.
Answer: With input 4, the helper calculation returns 12, and main.py displays Total: 12.
Check: The file names reflect their roles, and the traced result matches the calculation.

Worked example

Improve unclear project names

A project folder contains new.py, new2.py, stuff.txt, and notes.txt. The student knows one program asks for a member count, one program calculates a cost, and one text file explains how to use the project. Propose clearer names and explain how you would check them.
  1. Match each file to its purpose
    Rename the files using the known roles: member_input.py for the member-count interaction, meeting_cost.py for the cost calculation, and instructions.txt for the usage directions. Keep a name such as notes.txt only if its purpose is clear; otherwise revise it or remove it if it is not needed.
  2. Keep related project materials together
    The programs and instructions belong with this project. A project folder with a descriptive name makes them easier to distinguish from unrelated work.
  3. Test the names with a reader
    Ask someone to identify the cost calculation and instructions from the names alone. If the names do not help them find those files, make the names more specific.
Answer: Use names such as member_input.py, meeting_cost.py, and instructions.txt, and keep the project files together. Check whether another reader can locate each file by its name.
Check: The revised names communicate more than vague labels such as new.py or stuff.txt.

Common mistakes and how to avoid them

Giving files vague names such as new.py or stuff.txt.
Correction: Choose names that help a reader recognize the file’s purpose, such as meeting_cost.py or instructions.txt.
Putting unrelated project files together without a clear reason.
Correction: Keep materials for a project together and use groups that reflect their purposes.
Adding many folders even when they do not make the project easier to understand.
Correction: Use the simplest arrangement that makes related files easy to find.
Assuming a clear file name explains every relationship in the project.
Correction: Use names to identify contents and brief instructions when readers also need to understand how the pieces fit together.

Lesson summary

  • Logical organization makes program files and related materials easier to locate and understand.
  • Group files by project and purpose; choose clear, consistent names.
  • Use multiple files when the separation clarifies the parts of the program.
  • Review the arrangement from the perspective of someone who did not create it.

Check your understanding

Question 1

Which name most clearly suggests that a file contains directions for using a project?
  1. stuff.txt
  2. instructions.txt
  3. new2.txt
  4. file.txt
Show answer and explanation
instructions.txt
instructions.txt communicates the file’s purpose more clearly than the vague alternatives.

Question 2

In the Python 3 example, what result does cost_for_members return when the input is 4?
  1. 4
  2. 7
  3. 12
  4. 34
Show answer and explanation
12
The function returns members multiplied by 3. For 4 members, that gives 12.

Question 3

A project has a main program and a related calculation file. What is the best reason to keep them together?
  1. Related project files are easier to find and understand together.
  2. Every program must contain exactly two files.
  3. File names do not matter when files are in one folder.
  4. A project should use as many folders as possible.
Show answer and explanation
Related project files are easier to find and understand together.
Keeping related materials together helps a reader locate and understand the project. The number of files and folders depends on what makes the project clear.

Key terms

File
A named item stored on a computer, such as a program or a set of instructions.
Folder
A place used to group files and, when appropriate, other folders.
Import
In Python, a way for one program file to use a named item from another file.
Trace
A step-by-step account of how input and program instructions lead to a value or output.

Continue through ICS3U

View the complete ICS3U Ontario Grade 11 Computer Science curriculum and lessons

About this lesson and its review

Published by DoAssignment. This reviewed lesson follows Ontario Grade 11 Computer Science (ICS3U), expectation C2.1. It is a study resource, not an official curriculum publication.

Before publication, content is checked for structure, mathematical or chemical notation, calculations, course boundaries, and readability. Errors can still occur, so corrections are welcomed.

Official curriculum reference

Report a correction or ask a question