Pellissippi HOME | Library Site A-Z

Programming & Plagiarism: How to Cite Your Work

A guide to computer programming ethics, plagiarism, and intellectual property.

When Should You Give Credit?

As a student, you should develop original code to prove that you understand the material. In more advanced programming assignments, however, you may need to perform research and incorporate another's work.

Always give credit:

  • When incorporating a function, algorithm, or any specific aspect of code that someone else has created.
  • When using another's idea or concept to create source code.
  • When changing variable names or any non-algorithm elements from another's code.

What Information Will You Need to Cite Your Sources?

For a detailed citation, you can include some, if not all, of the following information:
  • Author(s) name (individual(s) or corporation)
  • Publication date
  • Title of program or source code
  • Code version (ex. 2.0)
  • Type (ie. program or source code)
  • Availability (ie. publisher or URL)

There is no standard citation format like APA or MLA, but you should place each citation in comments as dictated by the programming language. 

Record the full citation in the header comments, which will function as your works cited list.

Additionally, give credit beside the particular function or passage of code, as if you are writing an in-text citation. This may be a simple acknowledgement that the work belongs to someone else.

Citing your sources will maintain honesty and integrity in your programming, but it will also make it easier to maintain your own code by noting where something came from and what it should do.

Examples of Citing within Code

Full Citation v.s. Simple Acknowledgement

Example #1

*    Title: GraphicsDrawer source code
*    Author: Smith, J
*    Date: 2011
*    Code version: 2.0
*    Availability:

In most cases your instructor will not ask for a formal bibliography. Just state the source and how it helped you with the assignment. Your source can be a website, a book, a piece of source code, or even a person. 

Example #2

I wrote this function after looking at the following page on Stack Overflow:

Header Comments

Any and all sources should be acknowledged in the header comments at the very top of your assignment. The specific format of your comments may be defined by the instructor.

Example #3

# Walker M. White (wmw2)
# September 1, 2013
# Some of my test cases were suggested by Lillian Lee (ljl2).

Example #4

<!-- Commenting on my citation -->

In-Text Citations

Just like citing your sources in a research paper, in-text citations (or comments) should be included for a particular function or passage of code. This is in addition to the comments in your header.

Example #5 (Function Specifications)

"""Returns: true if shapes shape1 and shape2 overlap.   

Acknowledgement: Uses the Gilbert-Johnson-Keerthi algorithm.

Precondition: shape1 and shape2 are both shape objects."""

Example #6 (Block Comments)

cornelltest.assert_equals(trim(' a'), 'a')
cornelltest.assert_equals(trim('b '), 'b')

# Lillian Lee (ljl2) suggested these additional test cases
cornelltest.assert_equals(trim(' '), '')
cornelltest.assert_equals(trim('a b'), 'a b')
# End of Lillian's suggestions

Gries, D., L. Lee, S. Marschner, and W. White (over the years). (Fall 2014). Academic Integrity, CS 1110: Introduction to Computing Using Python: Fall 2014. Retrieved from: