Variables & Datatypes CSE 120 Winter 2019

Slides:



Advertisements
Similar presentations
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.
Advertisements

Variables Conditionals Boolean Expressions Conditional Statements How a program produces different results based on varying circumstances if, else if,
Variables and Operators
 Variables  What are they?  Declaring and initializing variables  Common uses for variables  Variables you get “for free” in Processing ▪ Aka: Built-in.
Data: Programming Design and Modularization IS 101Y/CMSC 101 Computational Thinking and Design Thursday, September 26, 2013 Marie desJardins University.
IAT 334 Java using Processing ______________________________________________________________________________________ SCHOOL OF INTERACTIVE ARTS + TECHNOLOGY.
Computer Science 1620 Loops.
IAT 800 Foundations of Computational Art and Design Lecture 2.
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.
Recognizing Patterns Counting: continually updating a value by a fixed amount Counting raindrops int dropCount = 0; //Raindrop counter while (dropCount.
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.
Review Blocks of code {.. A bunch of ‘statements’; } Structured programming Learning Processing: Slides by Don Smith 1.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
Continuous February 16, Test Review What expression represents the zip car eligibility rules of at least 18 years old and no incidents?
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
______________________________________________________________________________________ SCHOOL OF INTERACTIVE ARTS + TECHNOLOGY [SIAT] |
Lecture 4 Looping. Building on the foundation Now that we know a little about  cout  cin  math operators  boolean operators  making decisions using.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
B. RAMAMURTHY Simulating Motion and Implementing Animation.
Loops (cont.). Loop Statements  while statement  do statement  for statement while ( condition ) statement; do { statement list; } while ( condition.
CIS 3.5 Lecture 2.2 More programming with "Processing"
CHAPTER # 2 Part 2 PROGRAMS AND DATA 1 st semster King Saud University College of Applied studies and Community Service CSC1101 By: Asma Alosaimi.
Variables Art &Technology, 3rd Semester Aalborg University Programming David Meredith
Lesson Two: Everything You Need to Know
C++ Basics. Compilation What does compilation do? g++ hello.cpp g++ -o hello.cpp hello.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
LCC 6310 Computation as an Expressive Medium Lecture 2.
Continuous. Flow of Control Programs can broadly be classified as being –Procedural Programs are executed once in the order specified by the code varied.
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.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
 2003 Prentice Hall, Inc. All rights reserved. 1 Basic C++ Programming.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Programming in Processing Taught by Ms. Madsen Assistants: Ms. Fischer and Ms. Yen Winsor School, 2/20/08.
Variables. Something to mention… void setup(){ size(200, 200); background(255); smooth(); } void draw() { stroke(0); strokeWeight(abs(mouseX-pmouseX));
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004.
Nested Loops & Arrays CSE 120 Spring 2017
Chapter # 2 Part 2 Programs And data
Expressions & Control Flow CSE 120 Spring 2017
User-Written Functions
Basic Input and Output CSE 120 Spring 2017
Memory, Data, & Addressing II CSE 351 Autumn 2017
Introduction to Computer Science / Procedural – 67130
Functions in Processing CSE 120 Spring 2017
Functions in Processing CSE 120 Winter 2018
Basic Input and Output CSE 120 Winter 2018
Variables & Datatypes CSE 120 Winter 2018
Structures Lesson xx In this module, we’ll introduce you to structures.
Processing and Drawing CSE 120 Winter 2018
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Expressions & Control Flow CSE 120 Winter 2018
Introduction to C++ Programming
Variables & Datatypes CSE 120 Spring 2017
T. Jumana Abu Shmais – AOU - Riyadh
Nested Loops, Arrays CSE 120 Winter 2018
Announcements Mid-Term Exam!! Quiz 5 Again + Quiz 6 Exercise 5
More programming with "Processing"
Chapter # 2 Part 2 Programs And data
Functions in Processing CSE 120 Winter 2019
Basic Input and Output CSE 120 Winter 2019
Arrays CSE 120 Winter 2019 Instructor: Teaching Assistants:
Processing and Drawing CSE 120 Winter 2019
Variables Lesson Outline
LCC 6310 Computation as an Expressive Medium
Loops & Nested Loops CSE 120 Winter 2019
Buttons & Boards CSE 120 Winter 2019
IAT 800 Foundations of Computational Art and Design
Variables in C Topics Naming Variables Declaring Variables
Continuous & Random September 21, 2009.
LCC 6310 Computation as an Expressive Medium
Expressions & Conditionals CSE 120 Winter 2019
Presentation transcript:

Variables & Datatypes CSE 120 Winter 2019 Instructor: Teaching Assistants: Justin Hsia Ann Shan, Eunia Lee, Pei Lee Yap, Sam Wolfson, Travis McGaha Feds Can't Force You To Unlock Your iPhone With Finger Or Face, Judge Rules “Judge Westmore declared that the government did not have the right, even with a warrant, to force suspects to incriminate themselves by unlocking their devices with their biological features. Previously, courts had decided biometric features, unlike passcodes, were not ‘testimonial.’ That was because a suspect would have to willingly and verbally give up a passcode, which is not the case with biometrics. “The magistrate judge decision could, of course, be overturned by a district court judge, as happened in Illinois in 2017 with a similar ruling.” https://www.forbes.com/sites/thomasbrewster/2019/01/14/ feds-cant-force-you-to-unlock-your-iphone-with-finger-or-face- judge-rules/

Administrivia Assignments: Taijitu [checkoff] due Thursday (1/17) Reading Check 2 due Thursday by 3:30 pm (1/17) Logo Design due Friday (1/18)

Homework: Logo Design

Homework: Logo Design

Drawing a House One solution from worksheet: triangle(7,1, 3,5, 11,5); rect(3, 5, 8, 8); rect(8, 9, 2, 4); What if we wanted to move the house?

Variables Piece of your program that holds the value of something Every variable must be given a name and a data type The values of these variables can change (i.e. vary) during the execution of your program Warning: Not like a variable in Algebra (i.e. an unknown) Assignment/Write: give a variable a specific value e.g. x = 12;

Variables Piece of your program that holds the value of something Every variable must be given a name and a data type The values of these variables can change (i.e. vary) during the execution of your program Warning: Not like a variable in Algebra (i.e. an unknown) Read: use the current value of a variable e.g. ellipse(x+1, 50, 20, 20);

Datatypes int integers (e.g. 12 or -3) float decimal/real numbers (e.g. 3.14) color RGB (e.g. color(0)) char characters (e.g. 'J') boolean true or false (e.g. true) Many more exist and can be found in the Processing Reference:

Declarations We declare a variable by telling Processing the variable’s datatype, followed by the variable’s name: You can also give a variable a starting value (initialization) in the same line as the declaration:

Variable Manipulation Executed sequentially, just like other statements For variable assignments, compute right-hand side first, then store result in variable Example: int x = 4; x = x + 1; Read the current value of x (4) for the right-hand side Add 1 to the current value of x Store the result (5) back into x

Drawing a House with Variables Initial solution: triangle(7,1, 3,5, 11,5); rect(3, 5, 8, 8); rect(8, 9, 2, 4); What properties might be useful to store in variables?

Variable Rules & Guidelines Variable naming rules: Variables are case-sensitive (e.g. myx vs. myX) Numbers allowed, but not at beginning (e.g. k9 vs. 9k) Generally avoid symbols other than underscore (e.g. my_x) Variable names are meaningless to computers, but meaningful to humans Choosing informative names improves readability and reduces confusion In this class, most of our variables will be declared and initialized at the very top of our programs

Variable Worksheet New functions: print(), println()

System Variables Special variables that hold values related to the state of the program, often related to user input You don’t need to declare these variables These variables will update automatically as the program runs Colored pink/magenta-ish in the Processing environment Examples: width and height hold the value of the width and height of the drawing canvas, respectively size(300,500); println(width); println(height);

Active Mode in Processing We enter active mode by creating the functions setup() and draw() in our program setup() automatically executes once at the start draw() executes infinitely afterwards Each time draw() executes, it is called a new frame

Drawing and Frames System variable frameCount returns the number of frames since the start of the program Starts at 0 in setup() frameRate() changes the desired number of frame updates there are per second Larger argument is faster Default is frameRate(60) noLoop() stops draw() from being continuously executed Can restart using loop()

Motion with Variables Create your drawing Introduce a variable Substitute values in your drawing with expressions that use the new variable Change the variable value in-between frames Use background() to cover old frames

TMNT: Donatello

Donatello with a Variable

x_pos = min(x_pos + 1, width-40); Stopping Motion Stop Donatello from running off the right side of the screen: x_pos = min(x_pos + 1, width-40); Stop Donatello from running off the left side of the screen: x_pos = max(x_pos - 1, 0); In draw(), change x_pos: x_pos = min(x_pos + 1, 460); In draw(), change x_pos: x_pos = min(x_pos - 1, 0);

Falling Into Place Introduce variables for each body segment: Update each variable at different speeds:

Falling Into Place Update y-positions of drawing based on new variables:

Summary Variables are named quantities that can vary during the execution of a program Datatypes specific different forms of data e.g. int, float, color, Boolean Variable declarations specify a variable datatype and name to the program Generally occur at top of program Active mode uses setup() and draw() Motion can be introduced by changing the values of variables used in drawing commands in-between frames min() and max() functions can be used to limit or stop change in a variable value