Chapter 3 Notebooks in teaching and learning
Jupyter notebooks are a valuable tool for teachers, but their value can only be leveraged if you apply them correctly within the context of your course. In this chapter, you will learn how teachers can initially structure the design of their course and then determine when and how notebooks can be used to achieve their goals.
3.1 Oh the places your notebooks will go!
In Chapter 4 you will learn about the many creative ways that notebooks can be used within the design of your course. Many times notebooks can be adapted into course activities that you are already doing, and other times notebooks will give you opportunities to extend what you have done in past to increase the engagement, participation, understanding, and performance of your students. Jupyter notebooks can be a valuable member of your existing instruction toolkit, useful at every point in the learning environment. New adopters of Jupyter can start small, incorporating notebooks into single modules, assignments, or classroom activities. This is an excellent approach to see how your learning audience interacts with the notebook environment and explore notebook hosting systems in a low cost/risk way.
Instructors adopt Jupyter within their classrooms at a variety of levels, each making use of the strong features of the environment. Transitioning an existing course to any new platform seems daunting, but Jupyter notebooks are modular and ideal for an iterative development approach of adoption. Some may find themselves inheriting a course already built in Jupyter, while others will choose to build new courses entirely within Jupyter.
This section seeks to inspire you about the many uses of Jupyter within classroom content and presentation design, and preview how other elements of the Jupyter ecosystem can be integrated into that use. Some of these uses are quick to spin up as experiments to test the waters.
3.1.2 Jupyter notebooks as textbooks
Instructors often write Jupyter notebooks as linear narrative documents. These notebooks are to be read by students and learners, perhaps worked through, marked up and are a relatively one sided information consumption experience.
Most often these notebooks exist as the readings a learner is required to do before class, as reference material (e.g., to review for future assessments), or something that a learner works through on their own as a part of self study. Jupyter notebooks can be constructed of completely static text, which can serve as a starting point for transitioning existing material into the notebook environment.
This traditional static textbook chapter or section can be extended into an active space by changing inline code text to executable code cells that support modification and experimentation. Adding prompts with suggestions for interrogating the code and examples further extend active learning opportunities without rewriting the original content. Interactive sliders, user input sources, and manipulable visualizations are examples of how other widgets and plugins can open up more possibilities.
As you’ll see in later chapters, many authors are using Jupyter notebooks as their primary authoring and publishing platforms. These materials are published on paper and online, meaning that the interactive portions of the learning experience are first class elements within the resource.
3.1.3 Notebooks as workbooks/primer
Workbooks engage students in the notebook environment by including active elements where they are asked to manipulate or create new content. This moves students from a passive or static learning environment like a book into an active learning experience where they can engage with and critically think about the content.
You can include many pedagogical patterns (discussed in the next chapter) within a workbook, crafting a completely custom learning experience. These workbooks can be assigned as independent student learning (for example, pre-work for flipped classroom), or as part of an in class activity for individuals or small groups.
When teaching in the technical space, the exploration of concepts in their context is an ideal environment for showcasing an authentic experience to students. Studying a concept in isolation may reduce the complexity of the problem to be more accessible, but this removes it from the context for why it exists and may make it harder for students to put all the pieces together and synthesize it into their larger problem solving repertoire.
Retention of this context adds the complexity of expository text, technical reference in disconnected documents, or some boilerplate code. Providing this in a large script or lengthy lists of direction can be overwhelming for students to work with. Jupyter notebooks are excellent tools for teaching these complex workflows, because instead of a script with lengthy code comments or having disconnected documentation, this guiding text can be embedded exactly where it is needed where the coding is happening. This guidance material can also be formatted as markdown cells, which are visually distinct from code, making it easier to visually scan and opens the possibility to add helpful formatting.
A variety of activities can be supported with the executable code cells so learners can explore the space in an interactive and iterative environment. They can see and inspect portions of the surrounding code, but aren’t required to touch it, maintaining appropriate granularity for assignments and challenges. Using markdown formatting separating sections helps scaffold larger problems and help them really experience a real world workflow rather than statically read about it.
3.1.4 Notebooks as worksheets/drill sets
Many programming and domain tasks have specific syntaxes to be learned and effectively memorized before they can be internalized. Akin to math homework sheets, short worksheets where learners focus on highly granular or decontextualized problem sets lets them practice the complex syntax and procedures in an isolated and highly focused way. A set of small targeted tasks where these complexities can be practiced without the worry of additional syntax errors or other problem solving requirements can reduce the cognitive overhead a student might be overwhelmed by.
The cell based nature of the Jupyter notebook makes interactive code-based worksheets a clean experience for students to run. Each problem prompt can be written in a markdown cell, perhaps referencing an object or data file established in an initial cell. For example, a list or other data structure would be defined at the top and the exercises below are focused on the relevant methods and usage syntax. Each answer would then be completed by the student in a single code cell just below that markdown cell. This means that outputs and errors stay with the code producing them, so successes or bugs are easily traceable to the source.
Usages of autograding tools or unit tests, as discussed in later chapters, can be added to give students instant feedback about their work. Example or desired outputs could also be reproduced in markdown cells with the question for further guidance.
3.1.5 Notebooks as notepaper or course packets
The ability for a notebook to represent a linear experience with human prose and working code means that these can be used a student’s notepaper in class. They can capture the linear narrative structure of a lesson or lecture, and actually run the code they are taking note of. This ensures that what they have written down actually works, and makes for a strongly reusable document for them moving forward with homework.
Encouraging students to use Jupyter notebooks for taking class notes opens up further opportunities to provide scaffolding and support within the classroom. Providing notebooks with outlines of lecture content or other materials covered in class can become an useful active learning and engagement strategy. You might provide a mostly blank notebook with just topic headings, and ask them to take notes in their own style within those spaces. Or you could choose to embed reference notes, examples, and even small activities within the notebook, asking them to both take notes and work through examples with you.
Caution should be taken to encourage students to carefully maintain a linear order of their code in the notebooks. A later chapter has more information on Jupyter specific caveats that students should remain aware of.
3.1.6 Notebooks as an app
Notebooks even have a place in non-coding classroom content or activity. Interactive user inputs like mouse or touchscreen controlled sliders, buttons, highlighting, etc. allow a notebook user to manipulate input parameters for a visualization, tool, or model without directly editing any of the code within the notebook. These strategies support interactive computational exploration, or transform the notebook into an advanced calculator tool for students to use within their homework. These notebooks are then treated as applications that are distributed or made available for students to use during class or explore on their own.
This allows you to make an existing research workflow accessible to novice students as part of a computational module of a foundational class, or mock up content from a static textbook or reading into something for an active learning activity. The adaptability and reuse aspects of Jupyter notebooks also create opportunities for students to take this code further and adapt it for assignments or other research.
3.1.7 Notebooks as lab reports or assignments
There are a variety of assignment deliverables that programming and technical courses may require. Students may be asked to produce essays, presentations, working code, analytics, and even art or music. Many of these deliverables are directly supported within the notebook environment. Any written work could be completed within the notebook environment with markdown, which is ideal for communication content that is driven by data or incorporating code content. For example, a student could write a computational essay within a notebook, and use one of the presentation tools to present a report out in class, all using the same notebook.
Coding assignments can be submitted to a Jupyter supported learning management system and be autograded (discussed in later chapters), providing instant feedback and automating the grading process. This opens up self paced and highly scaled options for many courses, particularly open access MOOCs or large sections. Meanwhile, the inline visualization options mean that an assignment with graphical output can be self contained without trying to embed images within a word processing document or attaching a collection of images along with a script.
The multiple conversion and hosting options available to notebooks means that they can be shared or submitted across many formats. For example, conversion to HTML means that there is zero overhead for viewing the content, and support for markdown and PDF opens up accessibility and other publishing platforms.
3.1.8 Notebooks as interactive multimedia platforms
A variety of media formats can be embedded within a notebook, and other tools more offer platforms to more directly connect notebooks with multimedia content. Instruction content might be split up between short videos (often for flipped classrooms) or a variety of static images might be important for an assignment. The markdown cells within the Jupyter notebook provide several ways to place hyperlinks and embed a variety of media.
Several widgets are also available for embedding playable audio and video content (including from streaming video services) directly within the notebook. This creates a cohesive platform experience for the student, so they don’t have to exit out or change screens to work on their assignment and reference that content.
Other tools are available for more directly connecting the notebook content to a video guide. Video lectures or content in your courses can get lengthy in running time and associated notebooks are often just as long. Tools like Oriole provide a platform where you can integrate video timestamps into notebooks to create interactive video experiences. You can include, for example, Youtube videos within notebooks, with text and/or coding opportunities before/after the video. Using timecodes, you can also guide students through the videos in tandem with the notebook text. This further extends the ability to create a single cohesive interactive experience without the need for students to go back and forth between materials.
3.1.9 Notebooks as a demonstration platform
Eventually you will have to display a notebook in class. This may be as a demonstration of how to use a notebook, presenting more a traditional style lecture, creating and editing code, or using an interactive feature to explore an experiment. Normal standards for font sizes, organization, and accessibility stand for these cases.
Displaying actual notebook within your presentation is a natural starting point. This content may include text from markdown and LaTeX, code, and independent figures and sketches. For instance the lecturer could display the notebook, slowly scrolling through the material and interacting with cells containing code while also making use of either a digital or analog (e.g. chalkboard) sketching device. Custom styling plugins are available to change the background color, font, and other viewing aspects of the notebook for better presentation quality and accessibility.
Several slide show tools are available, which allow you to markup notebook cell content for a more traditional slideshow presentation mode without having to exit from your standard notebook. These slides can be scattered across notebook content into specific cells that will correspond to individual slides, with the other content ignored from the presentation. This then can be shown alongside the usual notebook interface and can be flipped between the other forms of content.
It is natural for students to read and interact with notebooks in their standard form, using either Jupyter Notebook or JupyterLab, and this can also be used for presentation. Jupyter Lab offers the convenience and uniformity of being able to open and edit source files (
.py, etc.) within the same environment and without OS- or browser-specific clutter. Full screening the browser is recommended if presenting using this mode. Presentation styles vary widely and span a spectrum from full-prepared notebooks to blank-slate live coding.
Many find it useful to incorporate an alternate modality such as a physical or digital “board” for free-form diagramming, working through a mathematical derivation, or other written procedural task. Notebooks can be a portion of these presentations or the complete environment, depending on your personal instruction style and content needs.
Care should be taken about how the notebook is presented and demonstrated. Doing a live demo gives you a few options. You might choose to:
- Scroll through a notebook
- Step through a notebook by executing the cells in order
- Fill out details or values into a mostly complete notebook
- Tweak or flesh out a notebook with some content
- Add content to a completely blank notebook
Each of these strategies have a place within a classroom, and their use should be informed by audience needs and learning goals. For example, having a notebook with prepared challenges for the end of each module or section, but with blank cells for the content gives you the opportunity to develop code live within class, but within a structure that keeps your workflow organized, and your formative assessments coded directly into your presentation. Incorporating reference information can make these documents more complete for students and answer common questions. There are many possibilities about what you can put in. Keep in mind that students will often ask for you to share copies of these notebooks after the class session is completed.
How much you focus on live coding will likely be determined by the domain content of the class. Programming courses would clearly have a priority for students to have more thorough practice with writing and typing in the code. However, a conceptual class looking at computational models may interactively tweak parameters for a model and discuss only what is happening within that mathematical model. No code is written or directly changed in the process.
3.1.10 Notebooks as a live coding environment
Live coding, as the name implies, involves the active writing of code within the instruction process. This might be part of a recorded screencast or an in person classroom. The process of live coding has several benefits for the student and instructor.
Showing the process of building up code examples showcases the natural non-linear process of how code is crafted, but walking through the logic of a code example slows instruction down and highlights the reason for inclusion of each element within the code.
Introduction of bugs (either purposeful or accidental) to the code has the added benefit of giving the presenter an opportunity to work through the debugging process and demonstrating that perfect code is never created on the first go.
Live-coding can also be an opportunity to provide an active learning experience by providing notebooks with code that has not been completed before the lecture and having students attempt to fill in the missing lines before doing the live-coding demonstration. Feedback on where students are in this process can be a useful way to also judge what students are retaining and are struggling with leading to just-in-time teaching opportunities.
Formative assessment and prediction prompts can also be incorporated either directly into the notebook or as part of the narration of the lecture. Creating live-coding opportunities can be done anytime where a block of code exists but picking out particularly illustrative examples or key points and appropriately scaffolding the example can be critical. For example, if the critical concept is inside of a for loop then only coding the inner part of the for loop can be helpful and not overwhelm the presentation with scaffolding such as the setup. The reverse can also be true however. If too much complexity or scaffolding is displayed learners may struggle to understand the scaffolding rather than concentrating on the key concept.
Many instructors utilizing live coding will choose to have students code along with them. This allows them to practice what they are learning, see it in the natural context of their environment, make all the normal mistakes and typos, and all within an environment where they can ask questions (or pause a video). Actively coding along with the instructor also includes a requirement that they are actively listening to the instructor and engaged with the content.
Presentation styles of scrolling or shift + enter are not live coding, but live demonstrations. While these limit or negate the benefits of the live coding environment, the benefits of speeding up the presentation or running through code that’s irrelevant to the learning goals may be more important. Removing the student’s active engagement with the content may eventually lead to their disengagement with the lesson, or missing large chunks of information. Instructors should balance their inclusion of live coding and live demonstration to ensure that students are active and engaged with the most important aspects of the lesson.
Information bandwidth in the classroom during a live coding session needs to be carefully managed, particularly when students are trying follow along. The rhythm of live coding roughly has three stages: preparation, typing, and explanation. These three follow quickly in succession but are independent phases. Preparation is the first, where you stop and explain what you are about to do. Typing is the next phase where you should speak as you type but only say what you are typing. This ensures that what the learners are seeing on the screen and hearing from you match. They will likely be looking back and forth between their screen and yours that they often won’t be able to stop and follow what you are saying while they are typing. The final stage is to stop and explain what you have typed and what has or will happen when you run the code. You may choose to execute the code and explain the results or include a formative assessment or prediction question before running the code. Pausing to explain the code you just wrote and walk through the results gives students time to catch up to your typing, time to consider what has happened, and a natural place to ask (and for you to as for) questions about what has happened.
Live coding does take practice to get used to, but can be extremely powerful for you to restrain your pace to your learners and to retain engagement with your students.
3.1.11 Conclusion about places
As you have just seen, notebooks provide a flexible tool that can be used in numerous ways to achieve your course goals. Notebooks are flexible enough that you can use them from relatively passive to very active student learning, you can use them in your lecture or in a flipped-classroom environment. There is no single best way to use notebooks in your courses, and you explore the various options you will want to start filling your use of notebooks with a variety of the pedagogical patterns described in the next chapter.
3.2 Before You Begin…
This chapter focuses on course considerations when incorporating notebooks into a class. Experienced instructors may choose to skim parts of this chapter and focus specifically on how Jupyter notebooks would change their current teaching style.
Before you begin adding Jupyter notebooks to your course, take some time to:
- Identify your teaching goals
- Understand your students
- Develop your content strategy
- Consider the context of the learning environment
The Jupyter notebook is a tool; its use in this context is subject to the expectations of the instruction. Setting expectations for learning depends on your goals, your students, the content, the learning environment context, and you.
3.2.1 Identify Your Teaching Goals
As with the creation of a building or robot or book, it is important to begin the process with a clear goal of what you are trying to create and why. The “and why” could be the most important decision you make in the whole process and it will (or at least it should) guide all the decisions that follow. The why here is not about why to use Jupyter notebooks, but the why is the goal you have for your students.
Is the goal to teach them critical thinking skills, or how to execute a specific set of functions to solve a problem? Is the goal that they will be able to translate mathematical concepts into real world application, or is the goal to teach them how to code? Be specific and clear, and then let the answers guide your decisions.
3.2.2 Understand Your Students
Your students are central to decisions about when and how to use notebooks alongside other tools in your instruction. An obvious illustration of these decisions would be selections made if you compare teaching 5th graders in relation to teaching graduate students. Yet, there are more subtle differences that you will also want to be aware of and monitor. For example, within a classroom, you will have variation among the backgrounds and skill levels of the students. Depending on the domain, some students may have extensive experience with coding in multiple languages while others may be doing their first computational explorations. Keeping students of all different experience levels engaged and excited is challenging.
188.8.131.52 Learn About Your Students
In many circumstances you will have little background information on your students prior to the first day of a class or workshop. You will have to learn quickly and be prepared to adjust the instruction to fit the students in attendance—not the students you wish you had or anticipated having. Some key considerations to learn about your students:
- Motivation: Why are your students participating? What are their goals beyond the workshop or class? Will they be applying what they learn soon, or not for months or potentially years?
- Entry skills: What skills are students coming to the instruction with, both technical (e.g., basic computer, coding, computational) and psycho-social (collaboration, presenting, asking questions)?
- Prior topic knowledge: Specific to the content of the instruction, what do they already know coming in?
- **Attitudes toward content:** Are they excited to learn, or nervous about the content? How confident are they about their success in the class?
- Attitudes about the delivery format: Do they have attitudes, positive or negative, about the delivery format (e.g., lecture, flipped classroom, lab) and/or technologies (e.g., learning management systems)
- Learning preferences: Are learners comfortable in active learning experiences? (e.g., working with teams, interacting with the instructor, using technology while learning, etc.)
- Group characteristics: Looking at these considerations, how diverse is the group? Have they been together for instruction before? Do you have a small class or a very large class?
A simple online survey ahead of class can be very helpful in gaining an understanding of your audience.
3.2.3 Cultivate Student Study Skills and Learning Strategies
Do not assume that your students will have acquired the necessary study skills to effectively and efficiently learn from your course. From note-taking skills (i.e., finding patterns, discerning what is worth writing down, linking to readings, etc.) to multitasking (i.e., knowing when it is ok to keep their email open while studying and when they really have to focus) are skills that often have to be developed during learning experiences.
For most students learning through hands on tools, such as notebooks, will be quite different than their previous learning experiences—especially coming out of traditional high school or large-lecture undergraduate course. Interacting actively with technologies for the express purpose of learning (i.e., not just socializing with friends) is valuable—and yet not common.
Take time to work with your students to help them build the foundations for how they can most benefit from the experiences you are creating. Talk with them early in the instruction about how notebooks will be used and how they will have to adapt their study strategies (where, when, and how they study) to best learn the content and achieve the goals of the instruction.
3.2.4 Develop Your Content Strategy
The content of the instruction should support the instructional goal(s) you have identified for the course. Sometimes the goal(s) and the content are synonymous, but other times they are not. For example, if your goal is for students to be able to calculate conjoint probabilities, then your content will be synonymous and be on calculating conjoint probabilities. Whereas in other contexts, your goal may be to develop critical thinking skills in relation to logical fallacies, and the content you use to achieve this is the analysis of political discourse, which is not necessarily synonymous.
In both cases, the content guides why, when, and how notebooks can be used to achieve the goals. Remember that notebooks are solutions we can use to achieve our goals; they should not be confused with the goals themselves, even then they are closely related.
The content of your instruction is not limited to what you want to teach; it involves activities, exercises, feedback opportunities, and assessments. Each of these supports your goal(s) for instruction and benefits from the use of different tools within and outside of Jupyter notebooks. For example, if your content goals suggest that students require some specific knowledge (such as, what is a logic fallacy) before they are prepared to move on to another content topic, then you should assess that knowledge before you select which tools (e.g., a fill-in-the-blank item in a notebook, or a verbal question to the students in a classroom, or a self-reflection) is most appropriate for that step in your instruction.
Having a comprehensive outline of the goals and related content for the instruction is key to making good decisions about how, when, where, and why to use notebooks in your instruction.
3.2.5 Consider the Context of the Learning Environment
Instruction happens in many interesting contexts—but learning is not restricted to the instructional texts that we construct. Students learn before, during, and after instruction, and notebooks may be a integrated components for students in all those contexts (see below).
Within our instructional contexts, those times when we likely have the most influence on student learning, we also have lots of options for how we deliver learning experiences. As an instructor you can, for example, assign notebooks as pre-work for a flipped classroom approaches; use notebooks during an in-person or online class to demo or offer student practice; and/or use notebooks for homework, assessments, and resources that students can use later long after your instruction. All of these create different contexts for your use of notebooks.
Other aspects of context that you should consider when determining your use of notebooks including both those of the instructional environment and then the later performance environment of the learners.
184.108.40.206 Instructional Environment
Today the instructional environment can be quite complex and involve multiple aspects. For instance, the instruction may include online videos, short lecture in a classroom, and then group activities in a lab. Each of these are unique environments and their characteristics may influence how, when, where, and why you use notebooks.
- Classroom: How will students be engaged with the content? Given the layout of the room (e.g., small tables, lecture hall) are there opportunities for peer engagement?
- Lab: How does the physical structure of the lab environment offer opportunities for peer learning and sharing? What are the hardware and software tools available to students?
- Flipped classroom: What are required knowledge and skills that students must gain from pre-activities? What is the role of video in the flipped classroom? Are students prepared with the study skills and strategies for learning independently in the flipped classroom approach? Will all students have access to the materials (potentially in a notebook) prior to the class? Do students have access to computers outside of the classroom? How will pre-reading/pre-watching be incentivized and assessed in the course?
- Online classroom: Are students prepared with the study skills and strategies for learning independently in the online classroom?
220.127.116.11 Performance Environment
After the instruction your students will, hopefully, apply what you have taught them, and the environment in which they apply your instruction can vary greatly. You will want to consider how any differences between the instructional environment and the performance environment might impact on the ability of students to apply what they have learned.
- Organizational/Managerial Support: Will students be supported in their use of the instruction and tools that you are using?
- Social Support: If they learn through group projects, will they also be able to apply the instruction when working on their own?
- Physical Aspects: Will they have access to the same, or similar, tools and resources they have access to during the instruction? For example, if students only learn in notebooks, will they also be able apply the learning in an IDE that is used by their employer?
3.2.6 Crafting an experience: choose the right tool and approach for the task
As an instructor, you create many types of learning objects for your classroom. Jupyter notebooks can be used to present many types of information, from slideshows to book chapters to homework. You can imagine the large differences you might have with the information you present within a slideshow, a book chapter, a homework assignment, and a worksheet for an in class activity. Jupyter notebooks can be used for all these activities, yet this is all within the same type of document platform.
This freedom of expression available within the Jupyter notebook environment can add a lot of pressure and decision fatigue to the design process. A blank notebook you intend to make a lecture document within and a blank notebook for an in class activity each look the same when first created.
Content and design decisions should be driven by the purpose of the lesson and the needs of the audience. How many times have you asked someone a question and had them answer it in a completely unhelpful way? Perhaps you asked about how to implement something but they answered it conceptually, or you asked for reasoning about why something existed but they gave you a syntax information.
Learning goals and pedagogic practice are complex and often domain and skill specific, but decisions about them come back to the essential question: what are you trying to do here? As an instructor, you not only need to select the right technology for the learning experience, but the right activities to fulfill the learning mission of the day and the course.
Students are given a variety of experiences to aid in the learning process. Some topics are conceptual that students need time to experiment with and build intuition over; others are purely syntax that requires reference and practice to build their internalize knowledge over usage, and some fall in between.
The rhythm of the learning process sees students working independently, working together, reading, producing, listening, problem solving, and struggling. Each activity should serve a purpose as part of a larger experience. The same way that restaurant or business owners craft an experience for their customer, you are crafting an experience for your students.
This design of this experience is not a simple process, and something driven by your expertise of your audience, domain, and your own ability to instruct. Through it all, your core perspective should be to incorporate elements that harmonize together to make an experience leading to your desired learning goal.
Perhaps for the section above add a block diagram or word cloud visual of the major decision considerations.
3.2.7 Transitioning to and from Jupyter
Although this book focuses on using Jupyter notebooks in education, we recognize that students have different backgrounds and familiarity with coding. Not all students are ready to jump right into notebooks from a traditional lecture-based classroom; while, other students may have significant programming experience and may be closer to being ready to transition to IDEs.
Based on your analysis of the goals and context you will want consider the appropriate instruction points for introducing and exiting from notebooks as a tool for achieving your goals. As your students gain experience with programming, they may be more interested in using an IDE. Likewise, you may choose to introduce a more traditional IDE first and introduce Jupyter notebooks later. Exercises that can support this transition include assignments where they do the same task in 3 or 4 different IDEs and then reflect on those experiences as they make decisions about which environments best supports their ambitions at the time.
3.2.8 Conclusion about teaching practices
In this chapter we have attempted to place the use of Jupyter notebooks into the process of good course design. Notebooks are a tool that many teachers can use to increase student engagement, participation, understanding, and performance—but that is not to say that every course and every lesson should use notebooks. Let the goals of your course define when and how to best use notebooks to achieve those goals.