Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.

Slides:



Advertisements
Similar presentations
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming First Edition.
Advertisements

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Eight Sub and Function Procedures.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 1- 1.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 06.
© 2010 Pearson Education, Inc. All rights reserved.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Mathematical Operators  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to Computers and Programming in.
11.3 Function Prototypes A Function Prototype contains the function’s return type, name and parameter list Writing the function prototype is “declaring”
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Chapter 2: Input, Processing, and Output
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 3: Expressions and Interactivity.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 Part 1 Conditionals and Loops.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running o Stored in.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley This week: Whew!!! The last homework was tough! The homework for this week.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming First Edition.
Microsoft Visual Basic 2008: Reloaded Fourth Edition
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming First Edition.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 5 – Dental Payment Application: Introducing.
Chapter 2: Using Data.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Exam scores by range 3-1.
Variables & Random Number Generation.  A penguin is playing arctic basketball. The penguin has a basketball and will push the basketball toward.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 7 Files.
Introduction to Programming with RAPTOR
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2: Methods and Data Programming with Alice and Java First Edition.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running Types of data.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
CSC 1051 – Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Variables and Expressions Programming Right from the Start with Visual Basic.NET 1/e 7.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
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.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Third Edition by Tony Gaddis.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Third Edition by Tony Gaddis.
Chapter 6 JavaScript: Introduction to Scripting
Starting Out with Alice: A Visual Introduction to Programming
Chapter 2: Input, Processing, and Output
Chapter 3: Variables, Functions, Math, and Strings
Chapter 3: Variables, Functions, Math, and Strings
2.5 Another Java Application: Adding Integers
Introduction to C++ Programming
WEB PROGRAMMING JavaScript.
ICT Gaming Lesson 3.
Chapter 2: Input, Processing, and Output
Presentation transcript:

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition by Tony Gaddis Chapter 3: Variables, Functions, Math, and Strings

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 Objectives To understand: what the many variables are and when and how they are used what three things are specified when creating a variable how a function differs from a method where an object’s functions are listed what primitive functions are what operators are and how are they used how math expressions are used in programming what a collision is and ways to avoid them what a string and string concatenation are 3-2

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Today’s Agenda 1.Variables 2.Using Functions 3.Creating Math Expressions 4.Working with Strings and Text 3-3

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Variables Programs may need to store data when running and it stores that data in a variable A variable is a named storage location in the computer’s memory The following types of data (or variables) can be stored: –local variables –parameter variables –class-level variables –world-level variables

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Variable Types Local variables belongs to a specific method used only by the instructions that the variable belongs to when a method stops, the variables cease to exist Parameter variables used to hold an argument that is passed to a called method Class-level variables variable that belongs to a specific object World-level variables variable that belongs to the world

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Creating Local Variables Local variables belong to a specific method (such as world.my first method) Variables require 3 things: –name –type –initial value 3-6 name type value 3.1

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Names and Types and Initial Values Variable Names Must be unique within the method Should be meaningful and reflect the variable’s purpose Named using camelCase Variable Types Numbers, Boolean, Objects, Other (such as String, Color, or Sound) Initial Value Value initially stored in the variable

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Variables Tile appearance shows the type of variable Creating the tile is called variable declaration variable area

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Variable Assignment Variables have an initial value Initial value held until a different value is assigned New values can be assigned while the method is running –Set instructions can be created to store (or set) different values –Request to set a value occurs when variable tile dropped into Methods Editor

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Functions Each object has a set of primitive functions List of functions is categorized –Boolean logic –Math –Random –String –Ask user –Mouse –Time –Advanced math –Other

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Asking the User for Input World has three primitive functions that ask for user input Each function is displayed in a dialog box Is it Yes or is it No?

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Primitive Object Functions Each object has primitive functions different from the world’s primitive functions –Proximity –Size –Spatial relation –Point of view –Other

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Creating Math Expressions Math Operators are used to create math expressions Math expressions perform a calculation and return a value Operands appear to the right and left of an operand payRate * hoursWorked –“payRate” and “hoursWorked” are operands OperatorDescription +Addition -Subtraction *Multiplication /Division

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Working with Strings and Text A string is a sequence of characters Strings represent: –names –addresses –messages –etc

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Asking the User to Enter a String World’s primitive function can ask use to enter string (text) The function returns the text the user enters Joining separate sets of strings is called concatenation –“Hello” joins with the user’s name 3-15 What’s your name? Hello, Jo! 3.4

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Joining Strings String Concatenation –Joins string a with string b –Strings a and b are arguments –Does not change the values of strings a or b…but combines the two strings Strings are NOT just text… but any alphanumeric character Can convert numbers to a string for use as well

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Text can be added to Alice worlds 3D text option is available at the end of the local gallery