Editor

Does the License Allow It?

Intermediate · Write the code · from Legal and Ethical Concerns: Copyright, Plagiarism and Open Licenses

From the lesson: Legal and Ethical Concerns: Copyright, Plagiarism and Open Licenses

Anything you make on a computer, from a song to a game level, belongs to someone, and computers make it possible to copy that work in seconds.

Read the lesson

Write can_use(license_name, commercial, changed) that returns True if a Creative Commons license allows the planned use and False otherwise.

  • commercial is True if the use is commercial. Licenses containing NC forbid that.
  • changed is True if you will share a changed version. Licenses containing ND forbid that.
  • Every other combination is allowed (credit and ShareAlike are conditions to follow, not reasons to refuse).
  • License names look like "CC BY", "CC BY-NC-SA" or "CC0".

    can_use("CC BY-NC", True, False)  ->  False
    def can_use(license_name, commercial, changed):
    parts = license_name.removeprefix("CC ").split("-")
    # parts for "CC BY-NC-SA" is ["BY", "NC", "SA"]
    return True

    What Check runs

    Your code runs first, then each of these lines, and 2 more that stay hidden. The output must match exactly.

    RunsExpected output
    print(can_use("CC BY", True, True))True
    print(can_use("CC BY-NC", True, False))False
    print(can_use("CC BY-ND", False, True))False

    More Computing Ethics exercises

    All Python exercises · 50 practice problems