Link to this page: bit.ly/db-spjh Go to the latest lesson. Previous Years: 22–23, 21–22, 20–21, 19–20, 18–19

Classroom Resources and Self-Directed Learning Time Activities

First Day, 2023-08-17

Welcome to Computer Science

Join Your Class in Google Classroom

Computing in the News

Cruise Driverless Taxis Shut Down, Block Traffic Due to Network Overload

What do you want to learn this trimester?

Self-Directed Learning Time Activities

See Resources at the top of this page.

Before You Leave

  • Log out
  • Straighten up

2023-08-22

Computing in the News

Meet ‘Pibot,’ the humanoid robot that can safely pilot an airplane better than a human

Python Lesson

  • Hello, world
  • 2 six-sided dice throw
  • 1–100 integer guessing game

2023-08-24

Computing in the News

Planning algorithm enables high-performance flight

Python Quiz

  • Hello, world
  • 2 six-sided dice throw

More Python

  • 1–100 integer guessing game

2023-08-29

Computing in the News

Meet Apollo, the ‘iPhone’ of humanoid robots

Python Quiz

  • Hello, world
  • 2 six-sided dice throw

More Python

  • List
    • A special type of object that stores multiple elements
teams = []  # Create an empty list and assign to teams
teams.append('Raiders')  # Add elements to the list
teams.append('Lions')
team = input('Team? ')   # Prompt for a team
teams.append(team)       # Add that team to the list

print(teams)
  • Operators
    • = assignment operator
    • == equality operator
  • Symbols
    • [] left and right square brackets, used with lists

Problems for more advanced students:

  • Write a program that takes two numbers via the input function and prints their sum
  • Write a program that determines whether a given number is even or odd
  • Write a program that checks if a given character is a vowel (consider only ‘a’, ‘e’, ‘i’, ‘o’, and ‘u’ as vowels).
  • Given a list of numbers, calculate and print the average.

2023-08-31

Computing in the News

The Top Programming Languages 2023

Python Quiz

See Google Classroom

More Symbols

Learn before our next class.

{} curly braces

[] square brackets

<> angle brackets

() parentheses

# hash, or pound sign

/ forward slash

\ backslash

! exclamation point

@ at sign

* asterisk

__ underscore

- hyphen

– en-dash

— em-dash

< less than, or open angle bracket

> greater than, or close angle bracket

; semicolon

: colon

' single quote or apostrophe

" double quote

2023-09-21

Computing in the News

UK’s controversial online safety bill set to become law

Python Review and Practice

Self-Directed Learning Time

See Resources at the top of this page.

2023-09-26

Computing in the News, Guest Speaker Mr. Dyer

What’s new in artificial intelligence

Python Review and Practice

  • Write a program that takes two numbers via the input function and prints their sum
    num1 = int(input('Number 1? '))
    num2 = int(input('Number 2? '))
    print(num1 + num2)
    
  • Write a program that determines whether a given number is even or odd
    num = int(input('Number? '))
    print(num % 2 == 0)
    
  • Write a program that checks if a given character is a vowel (consider only ‘a’, ‘e’, ‘i’, ‘o’, and ‘u’ as vowels).
    letter = input('Give me a letter ')
    print('vowel' if letter in 'aeiou' else 'consonant')
    

    A student found a bug in the above program. Can you find it?

  • Given a list of numbers, calculate and print the average.
    numbers = [1, 2, 3, 4, 5]
    print(sum(numbers) / len(numbers))
    

2023-09-28

Computing in the News: Elijah Horland Introduces Himself to His Computer Science Class

Python Review and Practice

Do as many of the following exercises (from ChatGPT) as you can, in any order you like. If you get stuck, move on to another exercise. It’s fine to do web searches (even using AI) for help.

input Exercises:

  1. Hello, Person!:
    • Ask the user for their name using input.
    • Print a greeting like “Hello, [name]!”.
  2. Age Calculator:
    • Ask the user for their birth year using input.
    • Calculate their age.
    • Display their age.
  3. Favorite Things:
    • Ask the user for their favorite color, food, and hobby using input.
    • Display a sentence using their responses.
  4. Temperature Converter:
    • Ask the user for a temperature in Fahrenheit using input.
    • Convert it to Celsius.
    • Display the Celsius value.
  5. Simple Calculator:
    • Ask the user for two numbers using input.
    • Ask the user for an operation (add, subtract, multiply, divide).
    • Perform the operation and display the result.

randint Exercises (Remember to from random import randint):

  1. Guess the Number:
    • Generate a random number between 1 and 10 using randint.
    • Ask the user to guess the number.
    • Tell them if they are correct or not.
  2. Die Roller:
    • Simulate the roll of a die (1 to 6) using randint.
    • Display the outcome.
  3. Lottery Numbers:
    • Generate a set of 5 random numbers between 1 and 50 using randint.
    • Display the numbers.
  4. Random Arithmetic Quiz:
    • Generate two random numbers using randint.
    • Ask the user to add (or subtract, multiply, etc.) them.
    • Check if the user’s answer is correct.
  5. Coin Toss:
    • Simulate a coin toss using randint.
    • Ask the user to guess “heads” or “tails”.
    • Display the outcome and tell them if they guessed correctly.

for loops Exercises:

  1. Print 10 Times:
    • Ask the user for a word.
    • Print the word 10 times using a for loop.
  2. Number Pyramid:
    • Use a for loop to print the following pattern:
       1
       12
       123
       1234
       12345
      
  3. Multiplication Table:
    • Ask the user for a number.
    • Display the multiplication table for that number up to 10 using a for loop.
  4. Countdown:
    • Ask the user for a number.
    • Use a for loop to print a countdown from that number to 0.
  5. Sum of Numbers:
    • Ask the user for a series of numbers (for instance, 5 numbers).
    • Use a for loop to compute the sum of all those numbers and display the result.

2023-10-03

Computing in the News: Kids Online Safety Act

Python Practice

We’ll work through some of the problems from 2023-09-28.

2023-10-05

Computing in the News

Humanoid robot Apollo works in a factory alongside people

Bard vs. ChatGPT for one task

Practice Quiz on Symbols

Python Practice

We’ll work through more of the problems from 2023-09-28.

One student solved the Lottery Numbers problem with code similar to this:

from random import randint
numbers = []

while len(numbers) < 5:
    number = randint(1, 5)
    if number not in numbers:
        numbers.append(number)

print(numbers)

We can simplify it by using something other than a list to store the numbers.

2023-10-10

Computing in the News

Gamers at risk of gaming disorder and hallucinations, research shows

Quiz on Symbols

2023-10-12

Computing in the News

10 Breakthrough Technologies 2023

Python Practice

We’ll work through more of the problems from 2023-09-28.

2023-10-17

Computing in the News Followup

One of the breakthrough technologies from the last Computing in the News was about harvesting pig organs for use in humans. This led to a discussion about animal welfare. Some students expressed beliefs that cows do not have social and emotional needs. Here is some information from ChatGPT, that those students might consider.

Cows, like many animals, have emotions and social needs. Here’s a concise way to explain this:

  • Emotional Expressions: Cows have been observed to display a range of emotions, from fear and stress to contentment and excitement. For instance, they can become distressed when separated from their companions.
  • Social Bonds: Cows form strong social bonds with certain herd members and can become stressed when separated from their preferred companions. They also have best friends and can become upset when separated from them.
  • Learning & Problem Solving: Cows have shown the ability to learn and solve problems, which indicates cognitive processing. For example, they can learn to operate levers to obtain food or navigate mazes.
  • Communication: Cows use vocalizations, body language, and even facial expressions to communicate with each other. Different moos can signify various emotions or needs.
  • Pain & Stress Reactions: Cows react to pain and stressful situations by changing their behavior, vocalizations, and physiology. For instance, their heart rate might increase when they’re scared.
  • Playfulness: Young calves are known to be playful, engaging in activities like running, jumping, and play-fighting, which are indicators of positive emotions.
  • Mother-Calf Bond: The bond between a cow and her calf is strong. Mothers become extremely distressed if they are separated from their calves.

Understanding and acknowledging these aspects can lead to better welfare practices and more humane treatment of cows in various settings.

Quick Quiz on Symbols

Python Practice

We’ll work through more of the problems from 2023-09-28.

2023-10-19

Python Practice

We’ll work through more of the problems from 2023-09-28.

2023-10-24

Computing in the News

To find out how wildlife is doing, scientists try listening

Optional Questions

  • What is the primary objective of using artificial intelligence in the research conducted in Ecuador’s forest?
  • How did Jorg Muller and his team determine the biodiversity in the Choco region of Ecuador?
  • What are the limitations of the AI-assisted approach for gauging biodiversity as mentioned in the article?
  • Why does Muller believe that being able to directly quantify biodiversity is significant, especially in the context of “biodiversity credits”?

What is an f-string?

In Python, an f-string is a way to create a string that includes values from variables. Think of it as a way to put together a sentence where some parts of the sentence can change based on the information you have.

How does it work?

To create an f-string, you start with the letter f before the opening quote of the string. Inside the string, you can place any variable inside curly braces { } to include its value in the string.

For example:

name = 'Alice'
greeting = f'Hello, {name}!'
print(greeting)

When you run this code, it will print: Hello, Alice!

In this example, the variable name has the value “Alice”. The f-string f"Hello, {name}!" uses the value of name to create the full greeting.

Python Program Solutions

Run some of these in replit or the Python Tutor Visualizer and see if you can understand them. Replit’s built-in AI can explain code to you.

Hello, Person!

name = input('What is your name? ')  # Get the user's name and save the string in the variable `name`
print('Hello, ' + name + '!')        # Print using concatenation (the `+` operator)
print(f'Hello, {name}!')             # Print using an f-string

Age Calculator

birth_year = int(input('Enter your birth year: '))  # Use int to extract an integer from the string returned by input
current_year = 2023
age = current_year - birth_year
print(f'You are {age} years old.')

Favorite Things

favorite_color = input('What is your favorite color? ')
favorite_food = input('What is your favorite food? ')
favorite_hobby = input('What is your favorite hobby? ')
print(f'Your favorite color is {favorite_color}, you love to eat {favorite_food}, and you enjoy {favorite_hobby}.')

Temperature Converter

fahrenheit = int(input('Enter a temperature in Fahrenheit: '))
celsius = (fahrenheit - 32) * 5 / 9
print(f'{fahrenheit}°F is {celsius}°C.')

Simple Calculator

num1 = int(input('Enter a number: '))
num2 = int(input('Enter another number: '))
operation = input('Enter an operation (add, subtract, multiply, divide): ')
if operation == 'add':
    print(f'{num1} + {num2} = {num1 + num2}')
elif operation == 'subtract':
    print(f'{num1} - {num2} = {num1 - num2}')
elif operation == 'multiply':
    print(f'{num1} * {num2} = {num1 * num2}')
elif operation == 'divide':
    print(f'{num1} / {num2} = {num1 / num2}')
else:
    print(f'Unknown operation: {operation}')

Guess the Number

from random import randint
number = randint(1, 10)
guess = int(input('Guess a number between 1 and 10: '))
if guess == number:
    print('You guessed correctly!')
else:
    print(f'You guessed {guess}, but the number was {number}.')

Die Roller

from random import randint
number = randint(1, 6)
print(f'You rolled a {number}.')

Lottery Numbers

from random import randint
numbers = set()
while len(numbers) < 5:
    numbers.add(randint(1, 50))
print(numbers)

Random Arithmetic Quiz

from random import randint
num1 = randint(1, 10)
num2 = randint(1, 10)
operation = randint(1, 4)
if operation == 1:
    answer = num1 + num2
    operator = '+'
elif operation == 2:
    answer = num1 - num2
    operator = '-'
elif operation == 3:
    answer = num1 * num2
    operator = '*'
elif operation == 4:
    answer = num1 / num2
    operator = '/'
guess = int(input(f'What is {num1} {operator} {num2}? '))
if guess == answer:
    print('You guessed correctly!')
else:
    print(f'You guessed {guess}, but the answer was {answer}.')

Coin Toss

from random import choice
coin = choice(['heads', 'tails'])
guess = input('heads or tails? ')
if guess == coin:
    print('You guessed correctly!')
else:
    print(f'You guessed {guess}, but the coin was {coin}.')
word = input('Enter a word: ')
for i in range(10):
    print(word)

Number Pyramid

for i in range(1, 6):
    for j in range(1, i + 1):
        print(j, end='')
    print()

Multiplication Table

num = int(input('Enter a number: '))
for i in range(1, 11):
    print(f'{num} x {i} = {num * i}')

Countdown

num = int(input('Enter a number: '))
for i in range(num, -1, -1):
    print(i)

Sum of Numbers

numbers = []
for i in range(5):
    numbers.append(int(input('Enter a number: ')))
print(sum(numbers))

2023-10-26

Computing in the News

Mr. Briccetti makes more progress on the new RoomHelper 3001

Python Practice

2023-11-02

8th graders are away.

Computing in the News

How GoGuardian Invades Student Privacy, a Report from the Electronic Frontier Foundation

Grading Rubric

Grading Rubric

Python Practice Quiz

On your own, or with others, take this practice, “open-book” quiz. You may use any resources you like, including the Internet, books, and other people. Your goal is to understand Python well enough to answer the questions without any help.

Start the Quiz

2023-11-07

Computing in the News

As a Teen, She Loved Video Games. Now She’s Using A.I. to Try to Quash Malaria.

Python Practice Quiz

8th Graders, and any 7th graders who want to: take the Python practice quiz.

Self-Directed Learning Time

Practice Python, or see Resources at the top of this page.