← VCE Applied Computing U1O2

Crediting code from other sources in comments

A comment placed above code you reused that names the source (such as a URL), the author and the licence, so the original work is credited and your own lines are clear.

Understanding Crediting code from other sources in comments in VCE Applied Computing U1O2

What it does: The comment sits directly above the reused function and names the source, author and licence, which is the core habit of crediting code. Start and end comments show exactly which lines were borrowed, so a reader can tell them apart from the lines you wrote yourself. Removing the source claims someone else's work as your own. Always record where the code came from. Comments are ignored by the computer. They are for people, to show clearly what is your work and what is credited to others. Anything after # on a line is a comment, so it does not affect the program. It only documents the source.

Common mistakes: The licence line has no # at the start, so Python reads it as code and gives a syntax error. It should be # Licence: MIT. The lines below were reused, so the comment must say they are not your own. It should be # Lines below are not my own.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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 89–124) and word search (Modules 8–124).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which comment correctly credits reused code?
# sorting code# Source: https://example.com/sort, Jo Lin, MIT licence
Matches
# Found this online total = sum(prices)
↓
The comment does not name the source, the author or the licence, so the original work is not properly credited.
Applying
Meanings
Term
# Source:
Meaning
A comment placed above code you reused that names the source (such as a URL), the author and the licence, so the original work is credited and your own lines are clear.
Practice
def clamp(n, low, high):
Testing
Gaps
Source: https://example.com/sort
Check Answer
Spots
2# Author: Sam Lee
3Licence: MIT

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Abyssal Dragon' badge — Deep Sea Legend, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which comment correctly credits reused code?
A. # Source: https://example.com/sort, Jo Lin, MIT licence ✓
B. # sorting code
A good credit comment names the source (URL), the author and the licence so the original creator is acknowledged.
2. Where should the # Source: comment go?
A. Hidden at the very end of the file
B. Directly above the reused code ✓
Placing it directly above the reused lines shows exactly which code came from someone else.
3. You copy a function from a tutorial website. What should you do?
A. Add a comment with the URL, author and licence ✓
B. Delete the URL so the code looks like yours
Removing the source claims someone else's work as your own. Always record where the code came from.
4. Which detail is MISSING from this comment? # Source: https://example.com/timer
A. The author and the licence ✓
B. The programming language
The comment gives a URL but does not name the author or the licence, so the credit is incomplete.
5. Why do you mark which lines are not your own?
A. So the computer runs the reused lines faster
B. So your teacher can see which code you wrote and which you reused ✓
Comments are ignored by the computer. They are for people, to show clearly what is your work and what is credited to others.

Match the Pairs

# Source: https://example.com/sort-tutorial → A comment that records the URL where the reused code was found, so the original source can be traced.
# Author: J. Chen | Licence: MIT → A comment that names the person who wrote the reused code and the licence that allows you to use it.
Credit reused code by placing a comment above it naming the source, author and licence → # Source: Real Python, author: A. Lee, licence: CC BY 4.0 def bubble_sort(items):
Mark which lines are not your own so your work is clearly separated from borrowed code → # --- Start of code reused from library docs --- # --- End of reused code ---
# Found this online total = sum(prices) → The comment does not name the source, the author or the licence, so the original work is not properly credited.
def area(r): return 3.14 * r * r # Source: https://example.com/area (Ms Wu, CC0) → The credit comment is placed below the reused code instead of above it, so it is easy to miss which lines it refers to.

Key Term

# Source:
A comment placed above code you reused that names the source (such as a URL), the author and the licence, so the original work is credited and your own lines are clear.

Fill in the Blanks

1. # Source: https://example.com/sort
Hint: Type the symbol that starts a Python comment line.
2. # Source: https://example.com/sort
Hint: Type the label word that says where the reused code came from.
3. # Source: https://example.com/sort # Author: Sam Lee # Licence: MIT
Hint: Type the label for the person who wrote the original code.
4. # Reused code: start total = sum(nums) # Reused code: end
Hint: Type the word that marks where the borrowed lines begin, so your own lines are clear.
5. # Source: https://example.com/sort # Author: Sam Lee # Licence: MIT
Hint: Type the label for the rules that say how the code may be reused.

Spot the Error

Question 1
A # Source: example.com/sort
B # Author: Sam Lee
C Licence: MIT
D def sort_list(items):
E return sorted(items)
Line C — The licence line has no # at the start, so Python reads it as code and gives a syntax error. It should be # Licence: MIT.
Question 2
A name = input('Name: ')
B # Source: github.com/ana/tools
C # Author: Ana Ruiz, MIT
D # Lines below are my own work
E print(name.title())
Line D — The lines below were reused, so the comment must say they are not your own. It should be # Lines below are not my own.
Question 3
A # Source: I wrote this
B # Author: Kim Tran, CC BY-SA
C total = sum(scores)
D print(total)
Line A — A Source comment must name where the code came from, such as a URL. Claiming you wrote it does not credit the original. It should be # Source: stackoverflow.com/1.
Question 4
A // Source: tutorials.com/loop
B # Author: Sara Kim
C # Licence: CC BY 4.0
D for i in range(5):
E print(i)
Line A — // does not start a comment in Python, so this line causes an error. Python comments start with #, so it should be # Source: tutorials.com/loop.
Question 5
A // Source: github.com/jo/utils
B // Author: Jo Park
C # Licence: MIT
D function double(n) {
E return n * 2;
F }
Line C — This program is JavaScript, where # does not start a comment. The licence line must use //, like the other credit lines: // Licence: MIT.

Student with a class code? Join your class →