Lesson 11: Simulating Experiments


By running a simple simulation in Sprite Lab, students will experience how computing can be used to collect data that identify trends or patterns. After running the simulation multiple times, students will have an opportunity to make a prediction about how changing a variable in the simulation might impact the outcome, and then test that hypothesis.


Sciences in many disciplines use Computer Science to run models and simulations to run experiments, collect data, and analyze that data for insights. Though the simulation introduced in this lesson is quite simplistic, it can be used as a jumping off point for students to consider how more sophisticated computational models could be used to test hypotheses.


Warm Up (5 min)

Activity (35 min)

Wrap Up (5 min)

View on Code Studio


Students will be able to:

  • Use a computer simulation to collect data about a model
  • Create double line graph to compare data about two different sources
  • Make and test a prediction by modifying simulation variables


  • Determine whether students will run simulations on their own computer, or if you will be running them as a whole class
  • If necessary, prepare to project the two simulations in this lesson.


Heads Up! Please make a copy of any documents you plan to share with students.

For the Students


  • Models and Simulations - a program which replicates or mimics key features of a real world event in order to investigate its behavior without the cost, time, or danger of running an experiment in real life.


Report a Bug

Teaching Guide

Warm Up (5 min)

Why Simulate an Experiment

Prompt: If you were a scientist, when might you want to simulate an experiment on a computer instead of in real life? Encourage students to consider experiments that might be dangerous or difficult to reproduce in real life.

Say: Today we're going to run a simulation to gather data about an experiment, just like scientists do.

Activity (35 min)

Simulating Experiments

Distribute: Pass out the Running Simulations - Worksheet along with pencils and coloring instruments of some kind. Direct students to Code Studio or project the level on the board.

Running Simulations

Step 1 Gather Data: The first bubble is a simple simulation of an elephant and a hippo collecting apples. Students will run the simulation at least 5 times, recording the number of apples collected by each animal and the total time it took to run the simulation.

Step 2 Line Graph: Using the data collected in the previous step, students will plot a double line graph. Encourage students to share their graphs with neighbors and discuss the following questions:

  • Are the graphs the same or different? Why do you think that is?
  • Do you see any patterns?
  • What do you think you'd see if you ran this simulation 5 more times?

Step 3 Modify and Predict: In the second bubble students will be able to modify some of the variables that control this simulation. Each student will choose a variable to modify, predict how that change will impact the simulation. Potential variables to modify include:

  • Number of elephants
  • Number of hippos
  • Number of apples
  • Speed of elephants
  • Speed of hippos

Step 4 Collecting More Data: With the modifications students decided on in the last step, they'll run the simulation five more times and collect the data.

Step 5 Visualize Your Data: This step is purposefully left open to allow students to explore any visual representation of their data that they'd like. The goal of this visual should be to prove or disprove their prediction.

Share: After finishing, students can share their results with a neighbor. When the whole class is ready, bring everyone together.

Wrap Up (5 min)


Discussion Goal

This simulation used in this lesson is purposefully broad and kind of silly. Through this discussion, students should start to connect the predictions and variable changes with actual scientific hypotheses. From there you can encourage students to think about computational modeling or more authentic scenarios or experiments.

Discuss: Ask students to discuss how their modification and prediction came out, first with a neighbor and then as a whole class. Encourage students to consider why they made the modifications they did and how that change connected to their predictions.

Journal: What is one interesting thing that you might simulate using a computer? What kinds of variables would you want to control in that experiment?

  • Run a simulation
  • 1
  • (click tabs to see student view)
View on Code Studio

Student Instructions

Collecting Data

Run this simulation 5 times. Each time, use the Collecting Data activity guide to record: How many apples did the elephant collect? How many apples did the hippo collect? * How much time did it take for all of the apples to be collected?

  • Modify simulation variables
  • 2
  • (click tabs to see student view)
View on Code Studio

Student Instructions

Modify and Predict

Pick one of the variables that control this simulation to modify and predict how that will change the outcome.

After you have written down your prediction, run the simulation 5 times and write down your findings. Was your prediction accurate?

  • Levels
  • Extra
  • (click tabs to see student view)
View on Code Studio

Student Instructions

Create your own simulation!

Here is another version of the simulation. Try making some changes to the sprite costumes or the code below. Have fun customizing your own simulation!

Standards Alignment

View full course alignment

CSTA K-12 Computer Science Standards (2017)

DA - Data & Analysis
  • 1B-DA-06 - Organize and present collected data visually to highlight relationships and support a claim.
  • 1B-DA-07 - Use data to highlight or propose cause-and-effect relationships, predict outcomes, or communicate an idea.