St. Perpetua 2024–25 Computer Science Elective Trimester 3
Go to the latest lesson. See all classes.
Classroom and Self-Directed Learning Resources
- Mr. Briccetti’s YouTube Channel with many programming lessons for you to explore on your own
- MakeCode
- Block-based Programming Environments
- MicroBlocks
- EduBlocks
- Blockly Games
- Snap!
- Run Snap!
- Snap! Reference Manual
- Snap! Crash Course
- “Why Do We Have to Learn This Baby Language?” from Brian Harvey, Teaching Professor Emeritus, University of California, Berkeley
- micro:bit Python editor
- Visualizing your Python program with Python Tutor Visualizer
- p5.js
- Tinkercad
- Beauty and Joy of Computing Curricula
- BJC Sparks for Middle School and Early High School
- BJC for High School (you are free to explore this if you run out of things to do in the middle school curriculum)
- code.org
- Zooniverse
- Teachable Machine
- Music
First Day, 2025-03-04
Welcome to Computer Science
Your Previous Computer Science Experience
Join Your Class in Google Classroom
Look at Earlier Trimesters to See What We May Cover
2024-25:
2023-24:
Python Text Adventure Game Programming with Edublocks
Create a new project in Edublocks and name it Adventure
. Choose text mode. Paste the following code into the editor:
from random import random
print("Welcome to Marvelous Adventure!")
while True:
print("Where to? 1) Field, 2) Barn, 0) Exit")
destination = int(input("==> "))
if destination == 1:
print("Welcome to the field!")
if random() < 0.5:
print("A rabbit runs across your path.")
elif destination == 2:
print("You’re in the barn.")
if random() < 0.8:
print("A cow moos.")
elif destination == 0:
break
We’ll discuss and build on this code using your ideas.
Self-Directed Learning
First Day, 2025-03-04
Critical Thinking
- Anchoring bias: The tendency to rely too heavily on the first piece of information encountered when making decisions.
- Strawman fallacy: Misrepresenting someone’s argument to make it easier to attack.
Python Basics with Edublocks
- print function
- numbers
- strings
- arithmetic expressions
- variables
- loops
micro:bits using MakeCode
Self-Directed Learning
2025-03-11
Python Programming with Edublocks
Turtle Graphics
Self-Directed Learning
2025-03-13
Mr. B. was out sick.
2025-03-18
Computing in the News
Tim Berners-Lee Wants to Know: ‘Who Does AI Work For?’
p5.js
let x = 0; // Initialize x position of the rectangle
function setup() {
createCanvas(500, 400); // Create a 500x400 pixel canvas
}
function draw() {
background('blue'); // Set the background color to blue
fill('yellow'); // Set the fill color to yellow for the rectangle
rect(x, 0, 60, 40); // Draw a rectangle at position (x, 0) with width 60 and height 40
x = (x + 5) % width; // Move the rectangle to the right and wrap around when it reaches the canvas edge
}
Self-Directed Learning
2025-03-20
Critical Thinking: Outcome Bias (as explained by ChatGPT)
Outcome bias is the tendency to judge a decision based on its outcome rather than on the quality of the decision at the time it was made. This can lead to unfair evaluations because a good decision can still lead to a bad outcome due to chance, and a bad decision can sometimes result in a good outcome by luck.
Examples of Outcome Bias
- Gambling: If someone makes a reckless bet and wins, others might see them as skilled rather than just lucky.
- Medical Decisions: A doctor who follows the best medical guidelines but has a patient with complications may be unfairly blamed, while a doctor who ignores guidelines but gets lucky with a successful treatment might be praised.
- Business: A risky investment that happens to pay off may be celebrated as a great decision, while a smart investment that fails due to external factors may be unfairly criticized.
Why It’s a Problem
- It discourages learning from mistakes and successes based on solid reasoning.
- It leads to poor decision-making in the future, as people might repeat bad decisions that happened to work out.
- It can unfairly reward or punish individuals based on luck rather than skill or judgment.
To avoid outcome bias, it’s important to evaluate decisions based on the process and information available at the time, rather than just the result.
Mr. B’s recent experience avoiding outcome bias
p5.js
Review of Tuesday’s code
Wrapping Around with Modulo (%
) (explained by ChatGPT)
We’re using the modulo operator (%
) to make the rectangle wrap around when it reaches the edge of the canvas.
Imagine This:
- You are running around a circular track.
- If the track is 500 meters long and you run 505 meters, you are actually back at 5 meters from the start.
- That’s because 505 % 500 = 5 (505 divided by 500 leaves a remainder of 5).
In the Code:
x = (x + 5) % width;
x + 5
moves the rectangle 5 pixels to the right every time.% width
makes surex
never gets bigger than the canvas width (500 pixels).- When
x
reaches 500, the modulo resets it to 0, making the rectangle start again from the left.
Why Does This Happen?
The modulo operator (%
) gives the remainder when dividing two numbers.
- If
x
becomes 500, then:500 % 500 = 0
So,
x
resets to 0, making the rectangle jump back to the left side. - If
x
is 505, then:505 % 500 = 5
Now,
x
is 5, meaning the rectangle appears near the left again.
A modification to move the rectangle smoothly right and left
function setup() {
createCanvas(500, 400);
rectMode(CENTER)
}
function draw() {
background('blue');
translate(width / 2, height / 2)
fill('yellow')
const x = sin(frameCount / 10) * width / 2
rect(x, 0, 60, 40)
}