Menu

Programs need to make decisions. bubblecode uses if, else, and end if with English-like comparisons.

Simple if

if.bubble

The code inside if ... end if only runs when the condition is true.

if / else

Use else to handle what happens when the condition is false:

ifelse.bubble

Multiple conditions

Chain conditions with else if:

grades.bubble

Comparisons you can use

Here are the English-like comparisons bubblecode supports:

  • is or is equal to — checks equality
  • is not or is not equal to — checks inequality
  • is greater than — larger
  • is less than — smaller
  • is greater than or equal to — at least
  • is less than or equal to — at most
compare.bubble

Exercise

Exercise

Create a variable "temp" with value 35. If temp is greater than 30, print "It is hot!". Otherwise print "It is cool."

exercise.bubble

Quiz

Question 1 of 3

What keyword ends an if block in bubblecode?