LCC 6310 Computation as an Expressive Medium Lecture 2.

Slides:



Advertisements
Similar presentations
Control Structures.
Advertisements

AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
HST 952 Computing for Biomedical Scientists Lecture 3.
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
IAT 334 Java using Processing ______________________________________________________________________________________ SCHOOL OF INTERACTIVE ARTS + TECHNOLOGY.
Introduction to Programming with Java, for Beginners Primitive Types Expressions Statements Variables Strings.
©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
IAT 800 Foundations of Computational Art and Design Lecture 2.
Arrays Liang, Chpt 5. arrays Fintan Array of chars For example, a String variable contains an array of characters: An array is a data structure.
Introduction to Primitives. Overview Today we will discuss: –The eight primitive types, especially int and double –Declaring the types of variables –Operations.
ICM Week 2. Structure - statements and blocks of code Any single statement ends with semicolon ; When we want to bunch a few statements together we use.
Lecture 3 IAT 800. Sept 15, Fall 2006IAT 8002 Suggestions on learning to program  Spend a lot of time fiddling around with code –Programming is something.
CSci 142 Data and Expressions. 2  Topics  Strings  Primitive data types  Using variables and constants  Expressions and operator precedence  Data.
String Escape Sequences
The switch Statement, DecimalFormat, and Introduction to Looping
01- Intro-Java-part1 1 Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology June 2008.
CSCI 1100/1202 January 16, Why do we need variables? To store intermediate results in a long computation. To store a value that is used more than.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
Georgia Institute of Technology Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology Aug 2005.
Continuous February 16, Test Review What expression represents the zip car eligibility rules of at least 18 years old and no incidents?
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
CSE 131 Computer Science 1 Module 1: (basics of Java)
______________________________________________________________________________________ SCHOOL OF INTERACTIVE ARTS + TECHNOLOGY [SIAT] |
CPS120: Introduction to Computer Science Decision Making in Programs.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions.
Data Types and Operations On Data Objective To understand what data types are The need to study data types To differentiate between primitive types and.
Chapter 7 Selection Dept of Computer Engineering Khon Kaen University.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Variables Art &Technology, 3rd Semester Aalborg University Programming David Meredith
Lesson Two: Everything You Need to Know
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Often being different. Control flow By default Java (and therefore Processing) executes lines of a program one after the other –Doesn’t matter what happened.
Test Review. General Info. All tests will be comprehensive. You will be tested more on your understanding of code as opposed to your ability to write.
CS 106 Introduction to Computer Science I 09 / 10 / 2007 Instructor: Michael Eckmann.
Chapter 2: Fundamental Programming Structures in Java Adapted from MIT AITI Slides Control Structures.
Review Random numbers mouseX, mouseY setup() & draw() frameRate(), loop(), noLoop() Mouse and Keyboard interaction Arcs, curves, bézier curves, custom.
Chapter 2: Data and Expressions. Variable Declaration In Java when you declare a variable, you must also declare the type of information it will hold.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
CPSC 233 Tutorial January 21 st /22 nd, Linux Commands.
11 Making Decisions in a Program Session 2.3. Session Overview  Introduce the idea of an algorithm  Show how a program can make logical decisions based.
IAT 265 Multimedia Programming for Art and Design ______________________________________________________________________________________ SCHOOL OF INTERACTIVE.
Topics introduced today (these topics would be covered in more detail in later classes) – Primitive Data types Variables Methods “for” loop “if-else” statement.
Lecture 2 D&D Chapter 2 & Intro to Eclipse IDE Date.
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Chapter 2 Basic Computation
Introduction to Python
Variables and Primative Types
Primitive Data, Variables, Loops (Maybe)
Data types and variables
Type Conversion, Constants, and the String Object
Chapter 2 Basic Computation
Introduction to Java, and DrJava part 1
Variables Numbers can be stored and retrieved while a program is running if they are given a home. The way that integers and decimal numbers are stored.
Introduction to Primitive Data types
Introduction to Java, and DrJava
Lecture 5: Basic Java Syntax AP Computer Science Principles
Java Programming Review 1
LCC 6310 Computation as an Expressive Medium
LCC 6310 Computation as an Expressive Medium
Comparing Data & the ‘switch’ Statement
IAT 800 Foundations of Computational Art and Design
Introduction to Java, and DrJava part 1
Comparing Data & the ‘switch’ Statement
LCC 6310 Computation as an Expressive Medium
LCC 6310 Computation as an Expressive Medium
Introduction to Primitive Data types
Presentation transcript:

LCC 6310 Computation as an Expressive Medium Lecture 2

Administrivia Books? Books? Processing installed? Processing installed? Lab times Lab times

Overview Discuss variables & if-then Discuss variables & if-then Discuss readings Discuss readings Look at assignment 1 Look at assignment 1

Drawing primitives revisited What are the different parts of a drawing primitive? What are the different parts of a drawing primitive? line(0, 0, 50, 50); method name parentheses contain arguments arguments

The drawing commands are methods Methods are reusable commands Methods are reusable commands Like a little machine that does work for you Let’s you reuse code without typing it over and over The arguments tell the method precisely what to do The arguments tell the method precisely what to do We’ll see later that you can define your own methods! We’ll see later that you can define your own methods!

Introduction to variables A variable is a named box for storing values A variable is a named box for storing values You can put values in a variable by using the assignment operator (aka “=“ ) You can put values in a variable by using the assignment operator (aka “=“ ) e.g. x = 1; To use the value stored in a variable, just use the variable’s name To use the value stored in a variable, just use the variable’s name e.g. line(x, 0, 50, 50);

Variables have a type You must tell Processing (Java) what kinds of values can go in the box You must tell Processing (Java) what kinds of values can go in the box You do this by giving a variable a type You do this by giving a variable a type int x; // variable x can hold integers (int) int y; // variable y can hold integers (int) x = 20; // store 20 in x y = 30; // store 30 in y point(x, y); // use the values of x and y to draw a point

Effect of creating an int variable // Single int int anInt; // Put a value in the int anInt = 3; // Type error! anInt = “hello”; CodeEffect Name: anInt, Type: int 3 “hello” Can’t shove “hello” into an int

Assigned values must match the type int x; // variable x can hold integers (int) int y; // variable y can hold integers (int) x = 1.5; // store 1.5 in x causes an error!!! y = 30; // store 30 in y point(x, y); // use the values of x and y to draw a point

The “primitive” types int – integers between 2,147,483,648 and 2,147,483,647 int – integers between 2,147,483,648 and 2,147,483,647 float – floating point numbers (e.g , -2.14) float – floating point numbers (e.g , -2.14) char – a single character (e.g. ‘c’) char – a single character (e.g. ‘c’) byte – integers between -128 and 127 byte – integers between -128 and 127 boolean – holds the values true or false boolean – holds the values true or false color – holds a color (red, green, blue, alpha) color – holds a color (red, green, blue, alpha)

Can combine declaring and assigning Declaring a variable means telling Processing it’s type Declaring a variable means telling Processing it’s type int x; Assigning a value to a variable means putting a value in the named box Assigning a value to a variable means putting a value in the named box x = 1; You can declare and assign at the same time You can declare and assign at the same time int x = 1; But only declare a variable once, otherwise you get an error But only declare a variable once, otherwise you get an error

Print and println When working with variables, it is often convenient to look at their values When working with variables, it is often convenient to look at their values print() and println() print to the bottom processing pane print() and println() print to the bottom processing pane They do the same thing, except println starts a new line after printing

Control flow By default Processing (Java) executes the lines of a method one after the other By default Processing (Java) executes the lines of a method one after the other Sequential control flow Unconditional – doesn’t matter what happens in the world Often we want which steps are executed to depend on what else has happened Often we want which steps are executed to depend on what else has happened That is, we want conditional control flow That is, we want conditional control flow This is necessary in order to make anything that is interactive

If If statements introduce conditional branches If statements introduce conditional branches If ( ){ // do this code } Boolean expressions have one of two values: true or false Boolean expressions have one of two values: true or false

Some boolean expressions anInteger == 1 true if variable anInteger is equal to 1 x > 20 true if variable x is greater than 20 1 == 2 true if 1 is equal to 2, it’s not so this is false ! is the not operator – reverses true and false so, ! 1 == 2 is true! This is not a boolean expression int anInteger = 1;

Example strokeWeight(2); // draw with heavier line stroke(200, 0, 0); // draw with redish line boolean drawRect = true; boolean drawAnX = true; if (drawRect) { fill(0, 200, 0); // fill with green rect(30, 30, 40, 40); } if (drawAnX) { line(0, 0, 100, 100); line(100, 0, 0, 100); } Try changing the values of drawRect and drawAnX

What do you think of this? “Which means that those computer scientists who invented these technologies … are the important artists of our time, maybe the only artists who are truly important and who will be remembered from this historical period.” Lev Manovich

NMR Introductions Relationship between art and CS Relationship between art and CS Should new media artists program? Why? What about collaboration? Computation as a medium Computation as a medium