code grammar. syntax a set of rules that defines the combination of symbols and expressions
TRANSCRIPT
![Page 1: Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions](https://reader034.vdocument.in/reader034/viewer/2022051620/56649f145503460f94c29a8e/html5/thumbnails/1.jpg)
Code Grammar
![Page 2: Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions](https://reader034.vdocument.in/reader034/viewer/2022051620/56649f145503460f94c29a8e/html5/thumbnails/2.jpg)
Syntax
• A set of rules that defines the combination of symbols and expressions
![Page 3: Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions](https://reader034.vdocument.in/reader034/viewer/2022051620/56649f145503460f94c29a8e/html5/thumbnails/3.jpg)
Curly Braces
• Always work in balanced pairs (an open and closed pair)
• Used to structure code blocks
![Page 4: Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions](https://reader034.vdocument.in/reader034/viewer/2022051620/56649f145503460f94c29a8e/html5/thumbnails/4.jpg)
Naming Convention
• Legal names can only contain letters, underscores, numbers, and the dollar sign
• The initial character must be a letter, underscore, or dollar sign - not a number
• The names you define are called identifiers
Legal identifiers
Illegal identifiers. Why?
![Page 5: Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions](https://reader034.vdocument.in/reader034/viewer/2022051620/56649f145503460f94c29a8e/html5/thumbnails/5.jpg)
Vocabulary
![Page 6: Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions](https://reader034.vdocument.in/reader034/viewer/2022051620/56649f145503460f94c29a8e/html5/thumbnails/6.jpg)
Comments
• Ignored by the computer• Helps us write notes• Helps remember what
that part of the program does
![Page 7: Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions](https://reader034.vdocument.in/reader034/viewer/2022051620/56649f145503460f94c29a8e/html5/thumbnails/7.jpg)
Functions
• Allow us to execute certain actions like draw shapes, set colors
• Usually lowercase followed by parentheses
![Page 8: Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions](https://reader034.vdocument.in/reader034/viewer/2022051620/56649f145503460f94c29a8e/html5/thumbnails/8.jpg)
Expressions, Statements
• An expression o like a phraseo Often a combination of
operators• A statement
o A set of expressionso Like a sentenceo Ends with the statement
terminator
![Page 9: Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions](https://reader034.vdocument.in/reader034/viewer/2022051620/56649f145503460f94c29a8e/html5/thumbnails/9.jpg)
Data types
• Processing can store and manipulate different kinds of data including numbers, letters, words, colors, etc
• The computer stores each in a different way so it needs to know which kind of data it is in order to manage it
• intinteger data
• floatfloating-point numbers that have a decimal point
• StringWords and sentences
• booleanTrue or false
![Page 10: Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions](https://reader034.vdocument.in/reader034/viewer/2022051620/56649f145503460f94c29a8e/html5/thumbnails/10.jpg)
Variables
• A container for storing data
• Allows a data element to be reused
• Every variable had a name, value and data type
• A variable must be declared before it is used
![Page 11: Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions](https://reader034.vdocument.in/reader034/viewer/2022051620/56649f145503460f94c29a8e/html5/thumbnails/11.jpg)
Operators
• Symbols used to write mathematical expressions
• + (Addition)• - (Subtraction)• * (Multiplication)• / (Division)
![Page 12: Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions](https://reader034.vdocument.in/reader034/viewer/2022051620/56649f145503460f94c29a8e/html5/thumbnails/12.jpg)
Relational Operators
• > (greater than)• >= (greater than and
equal to)• < (less than)• <= (less than and equal
to)• == (equal to)• != (not equal to)
![Page 13: Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions](https://reader034.vdocument.in/reader034/viewer/2022051620/56649f145503460f94c29a8e/html5/thumbnails/13.jpg)
![Page 14: Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions](https://reader034.vdocument.in/reader034/viewer/2022051620/56649f145503460f94c29a8e/html5/thumbnails/14.jpg)
References Processing: A programming Handbook for Visual
Designers - Casey Reas, Ben Fry
Processing: Creative Coding and Computational Art - Ira Greenberg
![Page 15: Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions](https://reader034.vdocument.in/reader034/viewer/2022051620/56649f145503460f94c29a8e/html5/thumbnails/15.jpg)
Op
Open CodeLabs Every Wednesday, 6:00pm - 8:00pm
10th Floor Lab, Building L