Learning Resource Type

Classroom Resource

Computer Science Principles Unit 5 Chapter 2 Lesson 12: Loops and Simulations

Subject Area

Digital Literacy and Computer Science

Grade(s)

9, 10, 11, 12

Overview

In this lesson, students gain more practice using while loops as they develop a simulation that repeatedly flips coins until certain conditions are met. The lesson begins with an unplugged activity in which students flip a coin until they get five heads in total, and then again until they get three heads in a row. They will then compete to predict the highest outcome in the class for each statistic. This activity motivates the programming component of the lesson in which students develop a program that allows them to simulate this experiment for higher numbers of heads and longer streaks.

Students will be able to:
- use a while loop in a program to repeatedly call a block of code.
- use variables, iteration, and conditional logic within a loop to record the results of a repeated process.
- identify instances where a simulation might be useful to learn more about real-world phenomena.
- develop a simulation of a simple real-world phenomenon.

Note: You will need to create a free account on code.org before you can view this resource.

    Digital Literacy and Computer Science (2018) Grade(s): 09-12

    DLCS18.HS.9

    Demonstrate the ability to verify the correctness of a program.

    Unpacked Content

    UP:DLCS18.HS.9

    Vocabulary

    • compile
    • program
    • syntax

    Knowledge

    Students know:
    • proper syntax and formatting for a coding language.
    • how to identify coding errors in a programming language.
    a.
    • programs must be tested to verify that the desired task is executed properly.
    • testing a program requires a scenario where you can easily verify that the result of the program is correct/accurate.
    b.
    • a program can contain one of the following properties, but not be an appropriate program: correctness, efficiency, scalability and readability
    • it is important to have others review your code.
    • that to be a quality program, code must be correct, efficient, scalable and readable.

    Skills

    Students are able to:
    • analyze code for proper syntax and formatting.
    a.
    • create a test case with verifiable results.
    • execute a program with the created test case to verify program performance.
    • locate errors in programming by executing test cases.
    b.
    • work with others to review their code for correctness, efficiency, scalability and readability.

    Understanding

    Students understand that:
    • programming languages each have their own required formatting which must be adhered to for a program to run correctly.
    • errors in programming languages prevent the program from executing its task.
    • each language has its own syntax and method for identifying potential errors.
    a.
    • code can be formatted correctly and a program can still produce unintended results.
    • a test case is vital to verifying that a program is executing a task as intended.
    b.
    • to be a quality program, code must be correct, efficient, scalable and readable.
    • it is important to have others proofread your code.
    Digital Literacy and Computer Science (2018) Grade(s): 09-12

    DLCS18.HS.10

    Resolve or debug errors encountered during testing using iterative design process.

    Unpacked Content

    UP:DLCS18.HS.10

    Vocabulary

    • debug

    Knowledge

    Students know:
    • steps of the problem solving process.
    • how to identify errors in an iterative design process.

    Skills

    Students are able to:
    • review a process and identify errors in procedure.
    • rectify errors found in a process.
    • test resolution to verify that the process now runs as intended.

    Understanding

    Students understand that:
    • errors in a process can prevent a solution.
    • resolving an error will allow the process to function as intended.
    Digital Literacy and Computer Science (2018) Grade(s): 09-12

    DLCS18.HS.37

    Evaluate the ability of models and simulations to test and support the refinement of hypotheses.

    Unpacked Content

    UP:DLCS18.HS.37

    Vocabulary

    • model
    • simulations
    • hypotheses
    • phenomena
    • target system

    Knowledge

    Students know:
    • how to explain the use of models and simulations to generate new knowledge and understanding related to the phenomena or target system that is being studied.
    • how to explain the ability of models and simulations to test and support the refinement of hypotheses related to phenomena under consideration.
    a.
    • that modeling and simulations are way to extrapolate and interpolate unrest situation and scenarios to help formulate, test and refine hypotheses.
    b.
    • how to form a hypothesis.
    • how to test a hypothesis.
    • how to create a model or simulation.
    c.
    • that simulations or models can be created to test a hypothesis but not provide the information expected or intended.
    • that it is vital to verify the data being generated by a model or simulation.

    Skills

    Students are able to:
    • use a diagram or program to represent a model to express key properties of a phenomena or target system.
    • research existing models and simulations and how they are used to test and refine hypotheses.
    • explain how existing models and simulations are used to test and support the refinement of hypotheses.
    a.
    • create a model or simulation to formulate, test, and refine a hypothesis.
    • utilize a model or simulation to formulate, test, and refine a hypothesis.
    b.
    • form a model of a hypothesis.
    • test the hypothesis by collecting and analyzing data from a simulation.
    c.
    • examine a model or simulation to determine the correctness of the generated data.
    • examine a flawed model or simulation and identify areas in which it is providing incorrect data.

    Understanding

    Students understand that:
    • a simulation is based on a model and enables observation of the system as key properties change.
    • the accuracy of models and simulations are limited by the level of detail and quality of information used and the software and hardware used.
    • models and simulations are an effective and cost efficient way to understand phenomena and test and refine hypotheses.
    a.
    • models and simulations are way to extrapolate and interpolate unrest situation and scenarios to help formulate, test and refine hypotheses.
    • models and simulations can be the only cost- ot time-effective way to test a hypothesis.
    b.
    • Models and simulations can save money, are safer, usually requires less time, and do not have the environmental impact that a full experiment or operational test may induce.
    c.
    • while a process may operate without errors, that does not guarantee that the process is providing accurate data to meet your needs.
    Link to Resource

    CR Resource Type

    Lesson/Unit Plan

    Resource Provider

    Code.org
    Accessibility
    License

    License Type

    Custom
    ALSDE LOGO