Integer or Int
Description
Whole number
Used for counting
Used for arrays indices (rows of data)
Examples:
Processing:
int count = 0;
JavaScript:
var highScore = 15350;
Python:
score = 250
Do not use commas in your numbers!
Shortcuts (Assignment Operators)
Quick Math
+= means “add this”
-= means “subtract this”
*= means “multiply it by this”
/= means “divide it by this”
This updates the variable when used
Example:
Processing, Java-based, and C-based:
int count = 2;
println(count); // Prints "2"
count += 3;
println(count); // Prints "5"
Python:
count = 2
print(count) # Prints "2"
count += 3
print(count) # Prints "5"
Adding or Subtracting 1
variableName++ means “add 1” or variableName += 1
variableName-- means “subtract 1” or variableName -= 1
This updates the variable when used
Examples:
Processing, Java-based, and C-based:
float count = 0;
println(count); // Prints "0"
count++;
println(count); // Prints "1"
float health = 10;
println(health); // Prints "10"
health--;
println(health); // Prints "9"
This ++ shortcut after the variable name does not work in python.
Last updated
Was this helpful?