Skip to Content
Getting Started with Processing.py
book

Getting Started with Processing.py

by Allison Parrish, Ben Fry, Casey Reas
May 2016
Beginner content levelBeginner
242 pages
4h 19m
English
Make: Community
Content preview from Getting Started with Processing.py

Chapter 4. Variables

A variable stores a value in memory so that it can be used later in a program. The variable can be used many times within a single program, and the value is easily changed while the program is running.

First Variables

One of the reasons we use variables is to avoid repeating ourselves in the code. If you are typing the same number more than once, consider making it into a variable to make your code more general and easier to update.

Example 4-1: Reuse the Same Values

For instance, when you make the y coordinate and diameter for the two circles in this example into variables, the same values are used for each ellipse:

size(480, 120)
y = 60
d = 80
ellipse(75, y, d, d)    # Left
ellipse(175, y, d, d)   # Middle
ellipse ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Introduction to D3.js with React

Introduction to D3.js with React

Adam Janes

Publisher Resources

ISBN: 9781457186820Errata Page