Brain DeCoded with CodeX - Mission 3, Objective 4: Your Brain on Sleep

Mission 3 · Objective 4 Lesson Plan

Your Brain on Sleep

Students code a simulation of the four sleep stages, then type in their own sleep scenarios and watch what full nights and interrupted ones do to brain function.

⏱ 45-70 min 🎯 Grades 8-12+ 💻 CodeSpace 🎮 CodeX 😴 Sleep Cycles
View Lesson Outline
📋

Overview

Students build sleep_stages, a simulation of the four stages of sleep: N1, N2, N3 and REM. The program draws each night as a "web" of lines, so a full uninterrupted night and a broken one look visibly different on the CodeX screen.

The input here is typed, not sensed. Students open the console in CodeSpace and enter the hours for each scenario, which makes this the first objective in the mission where the simulation runs on numbers students choose deliberately. Five scenarios are suggested on the Activity Guide, and students can invent their own after that.

The Hints in this objective carry a lot of background on sleep. They are worth real reading time, not a skim.

🎯 Project Goal: Students add code to a program that simulates the effects of sleep on the brain.

🎯

Learning Targets

  • I can explain the sleep cycles.
  • I can code and run a sleep simulation.
  • I can observe and record the results of sleep on brain function.
💡

Key Concepts

  • Sleep cycles are N1, N2, N3 and REM.
  • Uninterrupted sleep cycles have a positive effect on brain function.
  • Not enough sleep, or interruptions during sleep, can negatively affect brain function.
✅

Assessment Opportunities

  • Turn in the Activity Guide.
  • Complete the program sleep_stages.
☑

Success Criteria

  • Complete the CodeTrek steps
  • Program runs correctly without errors
  • Activity Guide is completed
📂

Digital Resources

🧰

Classroom Materials

  • ▸CodeX device and USB cable, one per student
  • ▸Laptop/computer with Chrome browser
🚀

Extensions & Cross-Curricular

ExtensionStudents with experience in math and programming can look over the two lists and two functions that draw the webs, then adjust the values to create their own.
MathThe program uses a series of lines to form "webs." Research envelopes in math, then have students do the math themselves, or use it to create their own webs with envelopes.
MathGraph the data from the simulations. Make predictions. Develop an equation that explains the pattern.
Lang ArtsStudents write about sleep cycles, or about how sleep affects brain function.
🐍

New Python Code

▾
small = []Define an empty list
small.append("H"+str(hour))Add an item to the end of the list
dis_big += 1Another way to increment a variable, the same as dis_big = dis_big + 1
hours = int(input('enter hours'))Type input on the console, convert it to an integer, and assign it to a variable
📐

Standards

▾

Health

1.1P 2.7P
📝
Preparing for the Lesson
  • Read the Hints before class. There is a lot of sleep background in them, and it is the content students are meant to absorb, not optional extra reading.
  • Run sleep_stages yourself and try a couple of scenarios, including one interrupted night, so you know what the webs look like when a night goes badly.
  • Practice opening the console. It is the icon just below the Toolbox, and you should see the prompt with a blinking cursor. Students have not typed input into the console before this objective.
  • Decide how students get the Activity Guide. You can print a copy for each student or assign it digitally. Five scenarios are listed on it.
  • Be ready for the topic to get personal. Students comparing their own sleep to the simulation is the point, but keep the conversation general rather than asking anyone to report their hours.

🧑‍🏫
Teacher Notes
  • The Hints include a lot of additional information about sleep that students should read and review.
  • The simulation uses the console for typing input. Students open the console by clicking the icon just below the Toolbox. They should see the prompt and a blinking cursor.
  • Students should follow the instructions on the Activity Guide to conduct the simulation. Five different scenarios are suggested, and students can also try their own.
  • Extensions and cross-curricular projects are included to enhance the concepts in the objective. You can use the extensions to extend students' learning.
🗺️

Lesson Outline

🗣️Warm-up / Hook

Open with the gap between hours slept and sleep quality.

  • Ask: "Is eight hours of broken sleep the same as eight hours of solid sleep? Why or why not?"
  • Ask: "What do you think your brain is actually doing while you are asleep?"
Teaching tip: Most students will say broken sleep is worse but cannot say why. Park that on the board. The Hints answer it, and the simulation shows it.
📖Sleep Stages & Build

Students read the Hints and build sleep_stages.

  1. Students read and review the Hints on sleep. Cover N1, N2, N3 and REM before the code runs.
  2. Students work through the CodeTrek steps, adding code to sleep_stages.
  3. Point out the new pieces: an empty list, append(), the += shorthand, and reading typed input with input().
  4. Have students open the console and confirm they see the prompt before they try to run a scenario.
Teaching tip: The console is where this lesson stalls. Walk the room during this step and check screens rather than waiting for hands, since a student who cannot find the console cannot start.
🔬Run & Record

Students run the scenarios and record results on the Activity Guide.

  1. Students work through the five suggested scenarios, typing their hours into the console.
  2. Students record what each scenario does to brain function, and what the web looks like.
  3. Once the five are done, students invent their own scenarios and run those too.
Teaching tip: Encourage a deliberately terrible night as one of the student-invented scenarios. The extreme case makes the pattern obvious, and students enjoy breaking things on purpose.
✏️Wrap-up & Review

Turn the webs back into the science.

  • Compare scenarios across the room. What separated the good nights from the bad ones, total hours or something else?
  • Go back to the warm-up question about broken sleep. Can students answer it now?
  • Ask: "Which stage would you least want to lose, and why?"
  • Collect the Activity Guides.
Teaching tip: If you are using the language arts extension, this discussion is the outline for it. Students who argue a position out loud have most of the writing done already.