AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Rounding and rolling

Week 12 · 1.6 Library programs · 3 lessons
3

Credit where it is due

Computing 8: Topic 1.6, pp. 125–149
GoalUse library functions and other people’s ideas honestly, and say where code came from.
New words
credit · saying who made an idea or a piece of codecomment · a line that starts with # and is ignored by Python; it explains the codeplagiarism · copying someone else’s work and saying it is yours
Explanation

Using a library is not cheating. Libraries are written to be used, and the import line shows where the tools come from. The problem starts when you take another person’s work and say it is yours. If a friend, a book or a teacher gives you an idea or a piece of code, ask permission first. Then write a comment that says where it came from and what you changed. Make sure you understand every line, because you may be asked to explain it. Testing it yourself shows that it really works. If you are not sure whether you may use something, ask a teacher or another trusted adult. Honest programmers share ideas, give credit and keep learning.

SituationHonest?
Using math.ceil after import mathyes, it is a library tool
Copying a friend’s whole program and handing it in as yoursno, this is plagiarism
Using a friend’s idea, asking first and writing a comment to say soyes
Changing only the name in a copied programno, it is still copied work
Worked examples
Python
1# Dice game idea shown by Ms Ito.
2# I changed it to use a die with 8 sides.
3import random
4roll = random.randint(1, 8)
5print("You rolled", roll)
A program that gives credit. The comments at the top say where the idea came from and what changed. Python ignores them, but people reading the code can see them.
What you doIs it honest?Why
Ask first, then use a friend’s method and name them in a commentyesyou have permission and you give credit
Copy a classmate’s file at night without askingnoit is not your work
Use random.randint and import randomyeslibraries are meant to be used
Copy a whole program from a book and say you wrote itnoyou say it is yours when it is not
Different situations compared. Giving credit costs nothing, and it shows respect for the person who had the idea.
Class activity

Credit cards (no computer). Write four small ideas on cards, such as “a program that picks a random seat number”, “a program that rounds up buses”, “a program that checks a password length” and “a program that picks a quiz number”. Pretend each one was given to you by a different person, and write that person’s name on the back. Now write the comment line you would put at the top of the program: who gave you the idea, and what you changed. Swap with a partner and check that every comment says who and what. If you have a computer or tablet, add a credit comment to a program you already wrote.

Practice
1
Is it honest to use math.floor in your program? Explain.
Python
1import math
2print(math.floor(2.7))
2
Write the first line (a comment) for a program that uses a method your friend Omar showed you, which you changed to work for 6 players.
3
A classmate sends you a finished program and says, “Hand this in as yours.” What should you do and why?
4
Why does a teacher ask you to explain your code line by line even when it works?