Have the students look at the editor on their computers. Refer to overhead projector as necessary.

Similar documents
Part II Composition of Functions

Intro. Scheme Basics. scm> 5 5. scm>

CS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

PAIRS AND LISTS 6. GEORGE WANG Department of Electrical Engineering and Computer Sciences University of California, Berkeley

Animations involving numbers

Shorthand for values: variables

Input, output, and sequence

RACKET BASICS, ORDER OF EVALUATION, RECURSION 1

Lab 1: Setup 12:00 PM, Sep 10, 2017

Sage CRM elearning Sales, Marketing, Customer Service modules for Sage BMS

1

OrbBasic Lesson 1 Goto and Variables: Student Guide

[Video] and so on... Problems that require a function definition can be phrased as a word problem such as the following:

Signed umbers. Sign/Magnitude otation

9. MATHEMATICIANS ARE FOND OF COLLECTIONS

Creating An Account With Outlook

OrbBasic 1: Student Guide

Lesson 13: The Graph of a Linear Equation in Two Variables

Variables, expressions and statements

Importing source database objects from a database

Properties and Definitions

Jerry Cain Handout #5 CS 106AJ September 30, Using JSKarel

The first program: Little Crab

Grade 6 Math Circles October 16 & Non-Euclidean Geometry and the Globe

Text Input and Conditionals

Midterm Exam, October 24th, 2000 Tuesday, October 24th, Human-Computer Interaction IT 113, 2 credits First trimester, both modules 2000/2001

Family of Functions Lesson

2.1 Transforming Linear Functions

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2013

Publications Database

Adding content to your Blackboard 9.1 class

CS Introduction to Data Structures How to Parse Arithmetic Expressions

2.1 Basics of Functions and Their Graphs

The Anglemaker Program

Trombone players produce different pitches partly by varying the length of a tube.

Project Collaboration

SCRATCH MODULE 3: NUMBER CONVERSIONS

Lecture 2 Finite Automata

Barchard Introduction to SPSS Marks

Authoring Numerical Problems in LON- CAPA: Step- by- Step

Math 395 Homework #1 Due Wednesday, April 12

Introduction to Programming

An Interesting Way to Combine Numbers

Intermediate Algebra. Gregg Waterman Oregon Institute of Technology

1 Shapes of Power Functions

[ the academy_of_code] Senior Beginners

Errors. Lecture 6. Hartmut Kaiser hkaiser/fall_2011/csc1254.html

Part I Introduction: Functions

5. Control Statements

Grade 6 Math Circles October 16 & Non-Euclidean Geometry and the Globe

Chapter 3: The IF Function and Table Lookup

(Provisional) Lecture 22: Rackette Overview, Binary Tree Analysis 10:00 AM, Oct 27, 2017

--- stands for the horizontal line.

HTML/CSS Lesson Plans

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Topic. Section 4.1 (3, 4)

Chapter 5 Errors. Bjarne Stroustrup

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

Chapter 2 The SAS Environment

Learning the Binary System

Keep Track of Your Passwords Easily

CS 3L (Clancy) Solutions and grading standards for exam 1

(2 1) What does evaluate to? What does evaluate to? What does evaluate to?

Commonly used keys to write text

VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.

(Refer Slide Time 3:31)

Lines of Symmetry. Grade 3. Amy Hahn. Education 334: MW 8 9:20 a.m.

Earthwork 3D for Dummies Doing a digitized dirt takeoff calculation the swift and easy way

CSC172 LAB. THE SCHEME OF THINGS (a bit of a racket)

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2010

Functional abstraction. What is abstraction? Eating apples. Readings: HtDP, sections Language level: Intermediate Student With Lambda

Functional abstraction

Compendium Basics Exercise

Two-Color Counters. Adding Integers, Part II. Key Term. Learning Goals. Essential Ideas. Common Core State Standards for Mathematics

Chapter 2.6: Testing and running a solution

Making ecards Can Be Fun!

Barchard Introduction to SPSS Marks

This document provides a concise, introductory lesson in HTML formatting.

Ph3 Mathematica Homework: Week 1

: Intro Programming for Scientists and Engineers Assignment 1: Turtle Graphics

Lesson 11 Skills Maintenance. Activity 1. Model. The addition problem is = 4. The subtraction problem is 5 9 = 4.

Smoother Graphics Taking Control of Painting the Screen

I put a shortcut onto your desktop, the screen that you look at after you log in.

Yup, left blank on purpose. You can use it to draw whatever you want :-)

Table of Laplace Transforms

CHAPTER 1 COPYRIGHTED MATERIAL. Finding Your Way in the Inventor Interface

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG

AO3. 1. Load Flash. 2. Under Create New click on Flash document a blank screen should appear:

If Statements, For Loops, Functions

Homework 6: Higher-Order Procedures Due: 10:00 PM, Oct 17, 2017

ASCII Art. Introduction: Python

Polygons and Angles: Student Guide

Adding and Subtracting Integers

Connecting SQL Data Sources to Excel Using Windward Studios Report Designer

Spreadsheet Functions

Polygons in the Coordinate Plane

Using the Zoo Workstations

What s the base case?

3 Nonlocal Exit. Quiz Program Revisited

Transcription:

Intro to Programming (Time 15 minutes) Open the programming tool of your choice: If you ve installed, DrRacket, double-click the application to launch it. If you are using the online-tool, click here to log in: http://www.wescheme.org/. Enter your username and password to log in, then click "Start a New Program". Have the students look at the editor on their computers. Refer to overhead projector as necessary. This screen is called the editor, and it looks something like the diagram you see here. There are a few buttons at the top, but most of the screen is taken up by two large boxes: the Definitions area on the left and the Interactions area on the right. The Definitions area is where programmers define values and functions in their program, while the Interactions area allows them to experiment with those values and functions. This is analogous to writing a series of function definitions on a blackboard, and having student evaluate expressions using those function on scrap paper. As students are not yet defining values of their own, it is not important that students understand this distinction right now. For now, we will work only with the Interactions area. A program is a legal expression that, when evaluated, produces a value. You ve been writing programs using mathematical expressions since you first learned how to add! Just as in English, there are rules that determine whether a sentence makes sense. Programs have rules too! A program can be very complicated, but it doesn t have to be: the simplest programs of all are just Numbers. Draw students attention to the Language Table (see Lesson Overview for Unit 1), which currently sits empty. Add "Numbers" to the Types section of the language table. Page 16 of 21

Code Rule 1: All values are legal expressions. What do you think 4 will evaluate to? Click here to test it out.: http://www.wescheme.org/openeditor?interactionstext=4& Enter 4 in the Interactions area and hit "Return". You will see the value 4 appear on the next line in the Interactions area. Type 10 in the Interactions area and hit "Return". Now the value 10 appears in the Interactions area. Try evaluating numbers, like 10345017, or negative numbers, like -2. Is there a limit to how big a number can be? What happens if you write a decimal? What happens when you click on a decimal, like 0.75? You get a new type of number, a fraction, like 3/4. The editing environment evaluates all fractions and returns them as decimals by default. This can be surprising to students at first, so you may want to take a moment to explain what s going on, and show them that these decimals can be converted back to fractions just by clicking on them. The environment uses standard annotations for repeating, non-terminating decimal expressions and properly handles expressions like ( 1). If you want to work with those kinds of numbers in your class, enter them to get familiar with how they appear in the Interactions area. The computer obviously knows about Numbers, but what happens if you type in something that it doesn t know about? Will it complain? Crash? Guess? Try asking the computer: http://www.wescheme.org/openeditor?interactionstext=dog& to evaluate dog in the Interactions area. The error message uses the term "variable". Don t worry if your students don t already know this term; we will teach it to them shortly. For now, students just need to get used to error messages and the kinds of problems that they catch in programs. These error messages are really useful for programmers. Rather than saying "this program doesn t work", the computer does the best it can to tell you what went wrong, and to give you as much information as possible to help you fix the problem. Make sure you always read these messages carefully! Page 17 of 21

The Circles of Evaluation are also easy to convert into computer programs. To translate a Circle of Evaluation into a program, begin with an open parenthesis (, and then the function written at the top of the circle. Then translate the inputs from left to right in the same way, adding a closing parenthesis ) when you re done. This process gives us the second rule for expressions: Code Rule 2: Each open parenthesis is followed by one function, then by one or more legal expressions, and finally by a closing parenthesis. Here is the code for this Circle of Evaluation: (- 4 5) Go to the editor: http://www.wescheme.org/openeditor? interactionstext=(- 4 5)&, and type (- 4 5) in the Interactions Area. Press the Return key to evaluate the program. You should see -1 as an answer. Have students practice converting simple Circles of Evaluation into code. If you want to help students understand when to use the parentheses, here are two explanations that we find useful. First, the parens look like the Circle, and the Circle encloses the function name and its inputs. Second, we use a more visual description of an ant eating its way through the expression. The ant eats into the Circle (an open paren), then goes to the function at the top, then to the arguments from left to right, then finally out of the Circle (a close paren). If the ant encounters another Circle while writing down the arguments, it needs another open paren, etc. When a Circle of Evaluation has other circles inside of it, the translation still follows the same rules: each Circle requires a new set of parentheses: (* 6 (+ 4 5)) Try entering this code into the Interactions area. What should the program evaluate to when you hit Return? Practice converting other Circles of Evaluation you ve drawn into code. [Video on Roles in Pair Programming.] Scaffolding for Pair Programming: Talk to students about the roles of Driver and Navigator. The Driver is the student with their hands on the keyboard - they re in charge of typing, using the mouse, etc. The Navigator should be telling the Driver what to type, and pointing out mistakes or suggesting things. It s important to clarify what these roles are (perhaps reinforcing them with a visual), to ensure that both partners are active and talking to one another about the task at hand. The linked video does a great job discussing these roles. Page 18 of 21

All of the expressions that follow the function name are called arguments to the function. The following diagram summarizes the shape of an expression that uses a function. For practice, turn to Page 5 in your workbook. For each mathematical expression, draw the Circle of Evaluation, then convert that Circle into Racket code. Page 19 of 21

When expressions don t follow the code rules, the computer will tell you that it found a problem. The computer also gives you information to help you fix the problem. This information is called an error message. We ll talk more about error messages later. For now, we just want you to see a couple of error messages so that you ll know what they are if you run into one while programming. Enter each of the following illegal expressions in the Interactions area and look at the error message or behavior that the computer gives you. (5 * 6) [puts the function in the middle, instead of at the front] (*5 6) [missing a space after the function] * 5 6) [forgets the open parenthesis] (* 5 6 [forgets the close parenthesis] At this point, the goal is simply to have students see error messages. Students are not expected to be experts at reading error messages this early (you will drill this later). NOTE: When a close parenthesis is missing, hitting return will do nothing, because the computer is waiting for the parenthesis. When an open parenthesis is missing, WeScheme does nothing and waits for the programmer to add the parens. If students hit enter and "nothing happens", they should check their parentheses. Also note that if you do this sequence of exercises with + instead of *, the error appears differently, because +5 is a perfectly valid number (just like -5). Page 20 of 21