Pick a number. Conditionals. Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary. CS Conditionals 1
|
|
- Gervase Walters
- 5 years ago
- Views:
Transcription
1 Conditionals Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary CS Conditionals 1 Pick a number CS Conditionals 2
2 Boolean Expressions An expression that evaluates to true or false. Relational boolean expressions: - is your number greater than 50? - is your number less than 40? - is your number equal to 73? - is your number greater than or equal to 75? - is your number less than or equal to 37? - is your number not equal to 99? CS Conditionals 3 Relational Operators is your number greater than 50? number > 50 is your number less than 40? number < 40 is your number equal to 73? number == 50 is your number greater than or equal to 75? number >= 75 is your number less than or equal to 37? number <= 37 is your number not equal to 99? number!= 99 CS Conditionals 4
3 (demo) // my number to guess int number = 73; // a relational expression used to guess my number println(number > 50); CS Conditionals 5 True or False? int a = 8; int b = 5; 6 < a a / 2 > 6 a * 5 == 8 * b b!= 5 A. true B. false C. neither true or false CS Conditionals 6
4 Conditional Statement if a boolean expression is true, then execute a block of code boolean expression code block to execute if true coding CS Conditionals 7 animation using a conditional statement instead of modulo to a number in range CS105 03b Variables 8
5 conditional_dot (if) // conditional dot void draw() { background(255); println(mousex, mousex > width / 2); // the conditional statement if (mousex > width / 2) { fill(#ff0000); // red ellipse(0.75 * width, 50, 30, 30); line(width / 2, 0, width / 2, height); CS Conditionals 9 Nested Code Blocks CS Conditionals 10
6 see 04 Conditionals (trace) CS Conditionals 11 Rest Stop Analogy A single if statement is like deciding to stop at a rest stop on a highway CS Conditionals 12
7 conditional_dot (if else) // the conditional statement if (mousex > width / 2) { fill(#ff0000); // red ellipse(0.75 * width, 50, 30, 30); else { fill(#0000ff); // blue ellipse(0.25 * width, 50, 30, 30); CS Conditionals 13 Detour Analogy if else is like having to take a detour ( the if) or taking the original road (the else) CS Conditionals 14
8 What can this code draw? void draw() { background(200); A B if (mousey > 50) { fill(0); // black else { fill(255); // white ellipse(mousex, mousey, 20, 20); C D A, B, and C are all possible CS Conditionals 15 conditional_dot (if else if) // the conditional statement if (mousex > width / 2) { fill(#ff0000); // red ellipse(0.75 * width, 50, 30, 30); else if (mousex < width / 2) { fill(#0000ff); // blue ellipse(0.25 * width, 50, 30, 30); else { background(random(255)); CS Conditionals 16
9 Two Common Logic Errors with if statements Adding semicolon after the boolean expression means no code block. A code block with no "if" means always execute. // the conditional statement if (mousex > 50); { fill(#ff0000); // red ellipse(0.75 * width, 50, 30, 30); The if statement does nothing, and the code block will always draw the red ellipse. Fix this by removing the semicolon after the boolean expression. Missing "else" makes two if statements. // the conditional statement if (mousex > 50) { fill(#ff0000); // red ellipse(0.75 * width, 50, 30, 30); if (mousex < 50) { fill(#0000ff); // blue ellipse(0.25 * width, 50, 30, 30); else { background(random(255)); If mousex is greater than 50, the red ellipse is drawn. But then the second if statement tests if mousex is less than 50. It isn't, so the else code block is executed which covers the red ellipse with a random background. Fix this by added "else" before the second if statement. CS Conditionals 17 coding shaper checking what key was pressed if (key == 'c') { shape = 1; else if (key == 'r') { shape = 2; else if (key == 't') { using a variable to save 'state': if (shape == 1) { ellipse( ); else if (shape == 2) { rect( ); else if (shape == 3) { triangle( ); CS Conditionals 18
10 Equality vs. Assignment Operators == Equality Operator - is the left value equal to the right value? - e.g. state == 1 means "is state equal to 1?" - left and right can be anything that reduces to a single value (a variable, a function that returns a value, a number, an expression) = Assignment Operator - assign the right value to the left variable - e.g. state = 1 means assign 1 to state - left must be a variable, right can be anything that reduces to a single value (a variable, a function that returns a value, a number, an expression) CS Conditionals 19 Numerical Representation: Integers Binary Numbers: 1 and 0 Bits and Bytes Integer Representation: - Fixed size - How to Handle Negative Numbers? CS Conditionals 20
11 What is this binary number in decimal? 0101 A: 101 B: 8 C: 5 D: 4 E: 3 CS Conditionals 21 overflow // almost largest integer int a = ; void setup() { framerate(2); void draw() { a = a + 1; // watch the output! println(a); CS Conditionals 22
12 What does this code draw after 10 frames? int a = 0; void draw() { background(200); A B if (a < 5) { ellipse(50, 50, 50, 50); else { line(0, 0, 99, 99); a = a + 1; C D CS Conditionals 23 What does this code draw after 10 frames? int a = 0; void draw() { background(200); A B if (a < 5) { ellipse(50, 50, 50, 50); else if (a > 5) { line(0, 0, 99, 99); else { a = a + 1; C D CS Conditionals 24
13 Numerical Representation: Float A civil engineer doesn't care about the difference between 10 meters and meters meters is a huge difference for a microchip designer, but all measurements will be less than about 0.1 meters A physicist needs to use the speed of light (about ) and Newton's gravitational constant ( ) in the same equation CS Conditionals 25 Numerical Precision How many numbers are there between 0 and 1? How many decimal points in one-third (1/3)? Computers can not always do exact math println( * 0.01); println( * 0.01); This has implications for equality testing CS Conditionals 26
14 precision float a = 0; void setup() { framerate(2); void draw() { a = a + 1; if (a == 5) { background(255, 0, 0); // watch the console output! println(a); CS Conditionals 27 Guessing Game CS Conditionals 28
15 Boolean Expressions An expression that evaluates to true or false. boolean expressions with logical operators: - is your number greater than 50 and less than 60? - is your number less than 40 or greater than 80? - is your number not less than 32? CS Conditionals 29 Logical Operators is your number greater than 50 and less than 60? number > 50 && number < 60 is your number less than 40 or greater than 80? number < 40 number > 80 is your number not less than 32?! (number < 32) analogy CS Conditionals 30
16 Logical Operators && means "and" means "or"! means "not" CS Conditionals 31 Logical Operators CS Conditionals 32
17 Order of Operations first last CS Conditionals 33 Logical Operator Examples int a = 15; int b = 5; (a > 10 && b < 10) (a < b b < a) (a == 10 && a < 20 && b > 0) (a < > b * 2) (a + b > 16 b a > 0) (a > 10 && a < 12 b > 3 && b < 7)!(a > 10) coding CS Conditionals 34
18 logical_dot if (mousex > width / 2 && mousey < height / 2) { fill(#ff0000); // red ellipse(0.75 * width, 50, 30, 30); if (mousex > width / 2 mousey < height / 2) { fill(#ff0000); // red ellipse(0.75 * width, 50, 30, 30); CS Conditionals 35 (demo) extend shaper to work with CAPS LOCK on if (key == 'c' key == 'C') { shape = 1; CS Conditionals 36
19 What is drawn on the 6 th frame? int a = 0; int b = 0; A B void draw() { background(255); if (a < 10 b > 0) { ellipse(25, 25, 30, 30); else { rect(60, 60, 30, 30); a = a + 1; C D void mousepressed() { b = 100; CS Conditionals 37 What is drawn on the 50 th frame? int a = 0; int b = 0; A B void draw() { background(255); if (a < 10 b > 0) { ellipse(25, 25, 30, 30); else { rect(60, 60, 30, 30); a = a + 1; C D void mousepressed() { b = 100; CS Conditionals 38
20 What is drawn after the mouse is pressed? int a = 0; int b = 0; A B void draw() { background(255); if (a < 10 b > 0) { ellipse(25, 25, 30, 30); else { rect(60, 60, 30, 30); a = a + 1; C D void mousepressed() { b = 100; CS Conditionals 39 rect_hittest (roll over) // the hit test if (mousex >= x && mousex <= x + w && mousey >= y && mousey <= y + h) { fill(#ff0000); // red else { fill(255);... CS Conditionals 40
21 Boolean Variables The result of a relational expression is either true or false Boolean variables store true or false boolean a = 9 < 10; println(a); // prints true CS Conditionals 41 toggle boolean on = true; void draw() { if (on) { background(255); // white fill(255); else { background(30); // almost black fill(100); // navy ellipse(mousex, mousey, 30, 30); void mousepressed() { on =!on; CS Conditionals 42
22 mousepressed, mousepressed() mousepressed() is an event function - it's called once when the mouse button is pressed mousepressed is a built-in boolean variable - it's true when the mouse button is pressed, false otherwise Same for keypressed and keypressed() CS Conditionals 43 draw (extra demo) mousepressed pmousex pmousey keypressed keypressed() CS Conditionals 44
23 What is drawn on the 2 nd frame? boolean b = false; void draw() { background(200); A B if (b) { ellipse(50, 50, 50, 50); else { line(0, 0, 99, 99); b =!b; C D CS Conditionals 45
A B C D CS105 03a Interaction
Interaction Function Definition Events Built-in Variables CS105 03a Interaction 1 Which image is drawn by this code? strokeweight(10); stroke(0, 255, 0); // green line(99, 0, 0, 99); stroke(200, 0, 200);
More informationBits and Bytes. How do computers compute?
Bits and Bytes How do computers compute? Representing Data All data can be represented with: 1s and 0s on/of true/false Numbers? Five volunteers... Binary Numbers Positional Notation Binary numbers use
More informationLoops. Variable Scope Remapping Nested Loops. Donald Judd. CS Loops 1. CS Loops 2
Loops Variable Scope Remapping Nested Loops CS105 05 Loops 1 Donald Judd CS105 05 Loops 2 judd while (expression) { statements CS105 05 Loops 3 Four Loop Questions 1. What do I want to repeat? - a rect
More informationif / if else statements
if / if else statements December 1 2 3 4 5 Go over if notes and samples 8 9 10 11 12 Conditionals Quiz Conditionals TEST 15 16 17 18 19 1 7:30 8:21 2 8:27 9:18 3 9:24 10:14 1 CLASS 7:30 8:18 1 FINAL 8:24
More informationIntroduction to Processing. Sally Kong
Introduction to Processing Sally Kong - Open Source Platform - Geared toward creating visual, interactive media - Created by Ben Fry and Casey Reas Basic Setup void setup() { size(800, 600); background(255);
More informationBasic Computer Programming (Processing)
Contents 1. Basic Concepts (Page 2) 2. Processing (Page 2) 3. Statements and Comments (Page 6) 4. Variables (Page 7) 5. Setup and Draw (Page 8) 6. Data Types (Page 9) 7. Mouse Function (Page 10) 8. Keyboard
More informationWatch the following for more announcements
Review "plain text file" loadstrings() split() splittokens() selectinput() println(), float(), int(), can take an array argument, will return an array easy way to convert an array of Strings to an array
More informationmith College Computer Science CSC103 How Computers Work Week 7 Fall 2017 Dominique Thiébaut
mith College Computer Science CSC103 How Computers Work Week 7 Fall 2017 Dominique Thiébaut dthiebaut@smith.edu Important Review Does the animation leave a trace? Are the moving objects move without a
More informationConditional Events. Mouse events and Operators. Dr. Siobhán Drohan Mairead Meagher. Produced by:
Conditional Events Mouse events and Operators Produced by: Dr. Siobhán Drohan Mairead Meagher Department of Computing and Mathematics http://www.wit.ie/ Topics list Mouse Events Recap: Arithmetic Operators
More informationWhat is a variable? a named location in the computer s memory. mousex mousey. width height. fontcolor. username
What is a variable? a named location in the computer s memory mousex mousey width height fontcolor username Variables store/remember values can be changed must be declared to store a particular kind of
More informationWhat can we do with Processing? Let s check. Natural Language and Dialogue Systems Lab Guest Image. Remember how colors work.
MIDTERM REVIEW: THURSDAY I KNOW WHAT I WANT TO REVIEW. BUT ALSO I WOULD LIKE YOU TO TELL ME WHAT YOU MOST NEED TO GO OVER FOR MIDTERM. BY EMAIL AFTER TODAY S CLASS. What can we do with Processing? Let
More informationFunctions. Functions. nofill(); point(20, 30); float angle = map(i, 0, 10, -2, 2); parameters return values
Functions parameters return values 06 Functions 1 Functions Code that is packaged so it can be run by name Often has parameters to change how the function works (but not always) Often performs some computation
More informationCISC 1600 Lecture 2.2 Interactivity&animation in Processing
CISC 1600 Lecture 2.2 Interactivity&animation in Processing Topics: Interactivity: keyboard and mouse variables Interactivity: keyboard and mouse listeners Animation: vector graphics Animation: bitmap
More information[ the academy_of_code] Senior Beginners
[ the academy_of_code] Senior Beginners 1 Drawing Circles First step open Processing Open Processing by clicking on the Processing icon (that s the white P on the blue background your teacher will tell
More informationKimberly Nguyen Professor Oliehoek Introduction to Programming 8 September 2013
1. A first program // Create 200x200 canvas // Print favorite quote size(200, 200); println("it is what it is"); // Draw rectangle and a line rect(100,100,50,50); line(0,0,50,50); // Save as.pde. Can be
More information+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.
+ Inheritance + Inheritance Classes that we design in Java can be used to model some concept in our program. For example: Pokemon a = new Pokemon(); Pokemon b = new Pokemon() Sometimes we need to create
More informationUsing Methods. Methods that handle events. Mairead Meagher Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics
Using Methods Methods that handle events Produced by: Mairead Meagher Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Caveat The term function is used in Processing e.g. line(),
More informationCISC 1600 Lecture 3.1 Introduction to Processing
CISC 1600 Lecture 3.1 Introduction to Processing Topics: Example sketches Drawing functions in Processing Colors in Processing General Processing syntax Processing is for sketching Designed to allow artists
More informationWe will start our journey into Processing with creating static images using commands available in Processing:
Processing Notes Chapter 1: Starting Out We will start our journey into Processing with creating static images using commands available in Processing: rect( ) line ( ) ellipse() triangle() NOTE: to find
More informationExploring Processing
Exploring Processing What is Processing? Easy-to-use programming environment Let s you edit, run, save, share all in one application Designed to support interactive, visual applications Something we ve
More informationWhat is a variable? A named locajon in the computer s memory. A variable stores values
Chapter 4 Summary/review coordinate system basic drawing commands and their parameters (rect, line, ellipse,background, stroke, fill) color model - RGB + alpha Processing IDE - entering/saving/running
More informationComputer Graphics. Interaction
Computer Graphics Interaction Jordi Linares i Pellicer Escola Politècnica Superior d Alcoi Dep. de Sistemes Informàtics i Computació jlinares@dsic.upv.es http://www.dsic.upv.es/~jlinares processing allows
More informationVariables and Control Structures. CS 110 Eric Eaton
Variables and Control Structures CS 110 Eric Eaton Review Random numbers mousex, mousey setup() & draw() framerate(), loop(), noloop() Mouse and Keyboard interaccon Arcs, curves, bézier curves, custom
More informationCOMP Summer 2015 (A01) Jim (James) Young jimyoung.ca
COMP 1010- Summer 2015 (A01) Jim (James) Young young@cs.umanitoba.ca jimyoung.ca final float MAX_SPEED = 10; final float BALL_SIZE = 5; void setup() { size(500, 500); void draw() { stroke(255); fill(255);
More informationCS110 Introduction to Computing Fall 2016 Practice Exam 1 -- Solutions
CS110 Introduction to Computing Fall 2016 Practice Exam 1 -- Solutions The exam will be closed-note and closed-book; please consider this fact before using your notes on this practice version. Please see
More informationQuestion 1 (10 points) Write the correct answer in each of the following: a) Write a Processing command to create a canvas of 400x300 pixels:
Question 1 (10 points) Write the correct answer in each of the following: a) Write a Processing command to create a canvas of 400x300 pixels: size(400, 300); b) After the above command is carried out,
More informationIntroduction to Processing
Processing Introduction to Processing Processing is a programming environment that makes writing programs easier. It contains libraries and functions that make interacting with the program simple. The
More informationCMPT-166: Sample Midterm
CMPT 166, Fall 2016, Surrey Sample Midterm 1 Page 1 of 11 CMPT-166: Sample Midterm Last name exactly as it appears on your student card First name exactly as it appears on your student card Student Number
More informationCST112 Variables Page 1
CST112 Variables Page 1 1 3 4 5 6 7 8 Processing: Variables, Declarations and Types CST112 The Integer Types A whole positive or negative number with no decimal positions May include a sign, e.g. 10, 125,
More informationINTRODUCTION TO PROCESSING. Alark Joshi, Amit Jain, Jyh-haw Yeh and Tim Andersen
INTRODUCTION TO PROCESSING Alark Joshi, Amit Jain, Jyh-haw Yeh and Tim Andersen What is Processing? Processing is a programming language designed to make programming easier Developers were frustrated with
More information5.1. Examples: Going beyond Sequence
Chapter 5. Selection In Chapter 1 we saw that algorithms deploy sequence, selection and repetition statements in combination to specify computations. Since that time, however, the computations that we
More informationVariables. location where in memory is the information stored type what sort of information is stored in that memory
Variables Processing, like many programming languages, uses variables to store information Variables are stored in computer memory with certain attributes location where in memory is the information stored
More informationModule 01 Processing Recap. CS 106 Winter 2018
Module 01 Processing Recap CS 106 Winter 2018 Processing is a language a library an environment Variables A variable is a named value. It has a type (which can t change) and a current value (which can
More informationFinal Exam Winter 2013
Final Exam Winter 2013 1. Which modification to the following program makes it so that the display shows just a single circle at the location of the mouse. The circle should move to follow the mouse but
More informationRecall that creating or declaring a variable can be done as follows:
Lesson 2: & Conditionals Recall that creating or declaring a variable can be done as follows:! float radius = 20;! int counter = 5;! string name = Mr. Nickel ;! boolean ispressed = true;! char grade =
More informationCISC 1600 Lecture 2.2 Interactivity&animation in Processing
CISC 1600 Lecture 2.2 Interactivity&animation in Processing Topics: Interactivity: keyboard and mouse variables Interactivity: keyboard and mouse listeners Animation: vector graphics Animation: bitmap
More informationCISC 1600, Lab 2.1: Processing
CISC 1600, Lab 2.1: Processing Prof Michael Mandel 1 Getting set up For this lab, we will be using Sketchpad, a site for building processing sketches online using processing.js. 1.1. Go to http://cisc1600.sketchpad.cc
More informationInteraction Design A.A. 2017/2018
Corso di Laurea Magistrale in Design, Comunicazione Visiva e Multimediale - Sapienza Università di Roma Interaction Design A.A. 2017/2018 5 Basics of Processing Francesco Leotta, Andrea Marrella Last update
More informationmith College Computer Science CSC103 How Computers Work Week 6 Fall 2017 Dominique Thiébaut
mith College Computer Science CSC103 How Computers Work Week 6 Fall 2017 Dominique Thiébaut dthiebaut@smith.edu Ben Fry on Processing... http://www.youtube.com/watch?&v=z-g-cwdnudu An Example Mouse 2D
More informationModule 05 User Interfaces. CS 106 Winter 2018
Module 05 User Interfaces CS 106 Winter 2018 UI is a big topic GBDA 103: User Experience Design UI is a big topic GBDA 103: User Experience Design CS 349: User Interfaces CS 449: Human-Computer Interaction
More informationCS110 Introduction to Computing Fall 2016 Practice Exam 1
CS110 Introduction to Computing Fall 2016 Practice Exam 1 The exam will be closed-note and closed-book; please consider this fact before using your notes on this practice version. Please see the abbreviated
More informationCISC 1600, Lab 3.1: Processing
CISC 1600, Lab 3.1: Processing Prof Michael Mandel 1 Getting set up For this lab, we will be using OpenProcessing, a site for building processing sketches online using processing.js. 1.1. Go to https://www.openprocessing.org/class/57767/
More informationCISC 1600, Lab 2.2: Interactivity in Processing
CISC 1600, Lab 2.2: Interactivity in Processing Prof Michael Mandel 1 Getting set up For this lab, we will again be using Sketchpad, a site for building processing sketches online using processing.js.
More informationEvaluating Logical Expressions
Review Hue-Saturation-Brightness vs. Red-Green-Blue color Decimal, Hex, Binary numbers and colors Variables and Data Types Other "things," including Strings and Images Operators: Mathematical, Relational
More information(Inter)Ac*ve Scripts. Sta*c Program Structure 1/26/15. Crea+ve Coding & Genera+ve Art in Processing 2 Ira Greenberg, Dianna Xu, Deepak Kumar
(Inter)Ac*ve Scripts Crea+ve Coding & Genera+ve Art in Processing 2 Ira Greenberg, Dianna Xu, Deepak Kumar Slides revised by Michael Goldwasser Sta*c Program Structure // Create and set canvas size(width,
More informationBasic Input and Output
Basic Input and Output CSE 120 Spring 2017 Instructor: Justin Hsia Teaching Assistants: Anupam Gupta, Braydon Hall, Eugene Oh, Savanna Yee Administrivia Assignments: Animal Functions due today (4/12) Reading
More informationvoid mouseclicked() { // Called when the mouse is pressed and released // at the same mouse position }
Review Commenting your code Random numbers and printing messages mousex, mousey void setup() & void draw() framerate(), loop(), noloop() Arcs, curves, bézier curves, beginshape/endshape Example Sketches
More informationCOMP Summer 2015 (A01) Jim (James) Young jimyoung.ca
COMP 1010- Summer 2015 (A01) Jim (James) Young young@cs.umanitoba.ca jimyoung.ca order of operations with the explicit cast! int integervariable = (int)0.5*3.0; Casts happen first! the cast converts the
More informationCISC 1600, Lab 3.2: Interactivity in Processing
CISC 1600, Lab 3.2: Interactivity in Processing Prof Michael Mandel 1 Getting set up For this lab, we will be using OpenProcessing, a site for building processing sketches online using processing.js. 1.1.
More informationThe Processing language
The Processing language Developed by Ben Fry and Casey Reas at MIT in 2001 Related to the languages Logo and Java Free, open-source software processing.org contains many programming resources www.openprocessing.org
More informationChapter 5. Condi.onals
Chapter 5 Condi.onals Making Decisions If you wish to defrost, press the defrost bu=on; otherwise press the full power bu=on. Let the dough rise in a warm place un.l it has doubled in size. If the ball
More informationCSE120 Wi18 Final Review
CSE120 Wi18 Final Review Practice Question Solutions 1. True or false? Looping is necessary for complex programs. Briefly explain. False. Many loops can be explicitly written out as individual statements
More informationProcessing Assignment Write- Ups
Processing Assignment Write- Ups Exercise 1-1 Processing is not an elaborate series of points like connect the dots or is it? Can t be cause I got it all wrong when I mapped out each and every point that
More informationInteraction Design A.A. 2017/2018
Corso di Laurea Magistrale in Design, Comunicazione Visiva e Multimediale - Sapienza Università di Roma Interaction Design A.A. 2017/2018 7 Conditionals in Processing Francesco Leotta, Andrea Marrella
More informationEP486 Microcontroller Applications
EP486 Microcontroller Applications Topic 2 Processing Department of Engineering Physics University of Gaziantep Sep 2013 Sayfa 1 Processing is a programming language, development environment, and online
More informationBasic Input and Output
Basic Input and Output CSE 120 Winter 2019 Instructor: Teaching Assistants: Justin Hsia Ann Shan, Eunia Lee, Pei Lee Yap, Sam Wolfson, Travis McGaha Facebook to integrate WhatsApp, Instagram and Messenger
More informationUniversity of Cincinnati. P5.JS: Getting Started. p5.js
p5.js P5.JS: Getting Started Matthew Wizinsky University of Cincinnati School of Design HTML + CSS + P5.js File Handling & Management Environment Canvas Coordinates Syntax Drawing Variables Mouse Position
More informationClass Notes CN19 Class PImage Page
1 Images and the Graphics Window Prior to beginning the work with different parts of the libraries, we spent time with classes. One reason for that was to provide some background when we started this part
More informationCMPT-166: Sample Final Exam Answer Key
CMPT 166, Summer 2012, Surrey Sample Final Exam Answer Key Page 1 of 9 CMPT-166: Sample Final Exam Answer Key Last name exactly as it appears on your student card First name exactly as it appears on your
More informationVariables One More (but not the last) Time with feeling
1 One More (but not the last) Time with feeling All variables have the following in common: a name a type ( int, float, ) a value an owner We can describe variables in terms of: who owns them ( Processing
More information1 Getting started with Processing
cis3.5, spring 2009, lab II.1 / prof sklar. 1 Getting started with Processing Processing is a sketch programming tool designed for use by non-technical people (e.g., artists, designers, musicians). For
More informationBasic Input and Output
Basic Input and Output CSE 120 Spring 2017 Instructor: Justin Hsia Teaching Assistants: Anupam Gupta, Braydon Hall, Eugene Oh, Savanna Yee How airlines like United choose who to kick off a flight On Sunday
More informationBasic Input and Output
Basic Input and Output CSE 120 Winter 2018 Instructor: Teaching Assistants: Justin Hsia Anupam Gupta, Cheng Ni, Eugene Oh, Sam Wolfson, Sophie Tian, Teagan Horkan How the Facebook algorithm update will
More informationModule 01 Processing Recap
Module 01 Processing Recap Processing is a language a library an environment Variables A variable is a named value. It has a type (which can t change) and a current value (which can change). Variables
More information1. Complete these exercises to practice creating user functions in small sketches.
Lab 6 Due: Fri, Nov 4, 9 AM Consult the Standard Lab Instructions on LEARN for explanations of Lab Days ( D1, D2, D3 ), the Processing Language and IDE, and Saving and Submitting. Rules: Do not use the
More informationThe way I feel about music is that there is no right and wrong. Only true and false. Fiona Apple. true false false
5 Conditionals Conditionals 59 That language is an instrument of human reason, and not merely a medium for the expression of thought, is a truth generally admitted. George Boole The way I feel about music
More information1 Getting started with Processing
cisc3665, fall 2011, lab I.1 / prof sklar. 1 Getting started with Processing Processing is a sketch programming tool designed for use by non-technical people (e.g., artists, designers, musicians). For
More informationMiscellaneous Stuff That Might Be Important.
1 Miscellaneous Stuff That Might Be Important. Variable mousepressed VS function mousepressed( ) For much of the work in this class, it is usually safer to use the function form of mousepressed( ) instead
More informationGRAPHICS PROGRAMMING. LAB #3 Starting a Simple Vector Animation
GRAPHICS PROGRAMMING LAB #3 Starting a Simple Vector Animation Introduction: In previous classes we have talked about the difference between vector and bitmap images and vector and bitmap animations. In
More informationGRAPHICS & INTERACTIVE PROGRAMMING. Lecture 1 Introduction to Processing
BRIDGES TO COMPUTING General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. This work is licensed under the Creative Commons Attribution-ShareAlike
More informationThe Junior Woodchuck Manuel of Processing Programming for Android Devices
Page1of15 TheJuniorWoodchuck Manuel of ProcessingProgramming for AndroidDevices TheImage JuniorWoodchuckManuelforProcessingProgramming Version1 CopyrightDavidNassarandJimRoberts,December2011,PittsburghPA
More informationCS 106 Winter Lab 03: Input and Output
CS 106 Winter 2019 Lab 03: Input and Output Due: Wednesday, January 23th, 11:59pm Summary This lab will allow you to practice input and output. Each question is on a separate page. SAVE each sketch as
More informationCPSC Fall L01 Final Exam
CPSC 601.36 - Fall 2009 - L01 Final Exam Copyright Jeffrey Boyd 2009 December 12, 2009 Time: 120 minutes General instructions: 1. This exam is open-book. You may use any reference material you require,
More informationMethods (cont.) Chapter 7
Methods (cont.) Chapter 7 Defining Simple Methods ReturnType Iden&fier ( ParameterList ) { Body ReturnType is the type of value returned from the method/funcbon. IdenBfier is the name of the method/funcbon.
More informationRepetition is the reality and the seriousness of life. Soren Kierkegaard
6 Loops Loops 81 Repetition is the reality and the seriousness of life. Soren Kierkegaard What s the key to comedy? Repetition. What s the key to comedy? Repetition. Anonymous In this chapter: The concept
More informationKhan Academy JavaScript Study Guide
Khan Academy JavaScript Study Guide Contents 1. Canvas graphics commands with processing.js 2. Coloring 3. Variables data types, assignments, increments 4. Animation with draw loop 5. Math expressions
More informationCOMP Summer 2015 (A01) Jim (James) Young jimyoung.ca
COMP 1010- Summer 2015 (A01) Jim (James) Young young@cs.umanitoba.ca jimyoung.ca Don t use == for floats!! Floating point numbers are approximations. How they are stored inside the computer means that
More informationArrays. circleracers (one racer) Object Creation and "dot syntax" Array Operation Idiom. // the x-position of the racer float x = 0;
Arrays Object Creation and "dot syntax" Array Operation Idiom CS 105 08 Arrays 1 circleracers (one racer) // the x-position of the racer float x = 0; void draw() { background(245); // white drawracer(x,
More informationAppendix: Common Errors
Appendix: Common Errors Appendix 439 This appendix offers a brief overview of common errors that occur in Processing, what those errors mean and why they occur. The language of error messages can often
More informationClass #1. introduction, functions, variables, conditionals
Class #1 introduction, functions, variables, conditionals what is processing hello world tour of the grounds functions,expressions, statements console/debugging drawing data types and variables decisions
More informationCS 100 Spring Lecture Notes 3/8/05 Review for Exam 2
CS 100 Spring 2005 Lecture Notes 3/8/05 Review for Exam 2 The second exam is Thursday, March 10. It will cover topics from Homework 2 through Homework 4, including anything pertaining to binary representation.
More informationCSC 220 Object-Oriented Multimedia Programming, Spring 2017
CSC 220 Object-Oriented Multimedia Programming, Spring 2017 Dr. Dale E. Parson, Assignment 2, Working with 3D shapes and geometric transforms. This assignment is due via D2L Dropbox Assignment 2 ShapePaint3DIntro
More informationCS 101 Functions. Lecture 15
CS 101 Functions Lecture 15 1 Key Processing language features so-far Basic color/shapes drawing Variables For-loops If-statements 2 Functions In the next few days, we ll be talking about Functions A Function
More informationSolution Notes. COMP 151: Terms Test
Family Name:.............................. Other Names:............................. ID Number:............................... Signature.................................. Solution Notes COMP 151: Terms
More informationUsing Methods. Writing your own methods. Dr. Siobhán Drohan Mairead Meagher. Produced by: Department of Computing and Mathematics
Using Methods Writing your own methods Produced by: Dr. Siobhán Drohan Mairead Meagher Department of Computing and Mathematics http://www.wit.ie/ Topics list Recap of method terminology: Return type Method
More informationfor(int i = 0; i < numbers.length; i++) {
Computation as an Expressive Medium Lab 3: Shapes, Rockets, Mice, Cookies and Random Stuff Joshua Cuneo Agenda Time Project 1 Array Loops, PImage, Fonts Drawing polygons Trigonometry review random() Methods
More informationSten-SLATE ESP. Graphical Interface
Sten-SLATE ESP Graphical Interface Stensat Group LLC, Copyright 2016 1 References www.arduino.cc http://esp8266.github.io/arduino/versions/2.1.0/doc/reference.html 2 Graphical Interface In this section,
More informationPractice exam for CMSC131-04, Fall 2017
Practice exam for CMSC131-04, Fall 2017 Q1 makepalindrome - Relevant topics: arrays, loops Write a method makepalidrome that takes an int array, return a new int array that contains the values from the
More informationToday in CS161. Week #3. Learn about. Writing our First Program. See example demo programs. Data types (char, int, float) Input and Output (cin, cout)
Today in CS161 Week #3 Learn about Data types (char, int, float) Input and Output (cin, cout) Writing our First Program Write the Inches to MM Program See example demo programs CS161 Week #3 1 Data Types
More informationModel Solutions. COMP 102: Test 1. 6 April, 2016
Family Name:.............................. Other Names:............................. ID Number:............................... Signature.................................. Model Solutions COMP 102: Test
More informationPROGRAMMING. We create identity
1 PROGRAMMING We create identity INTRODUCTION The course Lecture Tuesdays 10:45 to 12:30 Tutorial Thursday 8:45 to 12:30 or Fridays 12:45 to 17:30 Blackboard Textbook: Learning Processing, by Daniel Shiffman
More informationAssignment 2.4: Loops
Writing Programs that Use the Terminal 0. Writing to the Terminal Assignment 2.4: Loops In this project, we will be sending our answers to the terminal for the user to see. To write numbers and text to
More informationCST112 Looping Statements Page 1
CST112 Looping Statements Page 1 1 2 3 4 5 Processing: Looping Statements CST112 Algorithms Procedure for solving problem: 1. Actions to be executed 2. Order in which actions are executed order of elements
More informationEXAMINATIONS 2017 TRIMESTER 2
EXAMINATIONS 2017 TRIMESTER 2 CGRA 151 INTRODUCTION TO COMPUTER GRAPHICS Time Allowed: TWO HOURS CLOSED BOOK Permitted materials: Silent non-programmable calculators or silent programmable calculators
More informationCS106A Review Session
CS106A Review Session Nick Troccoli This document is copyright (C) Stanford Computer Science and Marty Stepp, licensed under Creative Commons Attribution 2.5 License. All rights reserved. Based on slides
More informationSFPL Reference Manual
1 SFPL Reference Manual By: Huang-Hsu Chen (hc2237) Xiao Song Lu(xl2144) Natasha Nezhdanova(nin2001) Ling Zhu(lz2153) 2 1. Lexical Conventions 1.1 Tokens There are six classes of tokes: identifiers, keywords,
More informationProgramming Language. Functions. Eng. Anis Nazer First Semester
Programming Language Functions Eng. Anis Nazer First Semester 2016-2017 Definitions Function : a set of statements that are written once, and can be executed upon request Functions are separate entities
More informationThe Processing language. Arduino and Processing.
IAT267 Introduc/on to Technological Systems Lecture 8 The Processing language. Arduino and Processing. 1 Course Project All teams submibed very interes/ng proposals One requirement for the project is to
More informationArrays. Array an ordered collec3on of similar items. An array can be thought of as a type of container.
Chapter 9 Arrays Arrays Array an ordered collec3on of similar items Student test scores Mail boxes at your college A collec3on of books on a shelf Pixels in an image the posi3ons for many stars in a night
More informationmith College Computer Science Week 10 CSC111 Spring 2015 Dominique Thiébaut
mith College Computer Science Week 10 CSC111 Spring 2015 Dominique Thiébaut dthiebaut@smith.edu Next Few Lectures Image Processing with Nested For-Loops Lists can be Used to Solve Many Problems (Chap.
More information