Brain DeCoded with CodeX - Mission 3, Objective 4: Your Brain on Sleep
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.
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
🐍
New Python Code
▾
dis_big = dis_big + 1
📐
Standards
▾
Health
- 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.
- 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
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?"
Students read the Hints and build sleep_stages.
- Students read and review the Hints on sleep. Cover N1, N2, N3 and REM before the code runs.
- Students work through the CodeTrek steps, adding code to sleep_stages.
-
Point out the new pieces: an empty list,
append(), the+=shorthand, and reading typed input withinput(). - Have students open the console and confirm they see the prompt before they try to run a scenario.
Students run the scenarios and record results on the Activity Guide.
- Students work through the five suggested scenarios, typing their hours into the console.
- Students record what each scenario does to brain function, and what the web looks like.
- Once the five are done, students invent their own scenarios and run those too.
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.