top of page

Block Programming - Operators

Operators are another key concept in programming that you'll often use in block programming as well. They let you perform operations on variables and values. The exact operators available to you may vary depending on the specific block programming platform you're using, but generally, there are several different types of operators you might use.

Arithmetic Operators: These let you perform basic mathematical operations. For instance, you might use an addition (+) operator to add two numbers together, or a subtraction (-) operator to subtract one number from another. If you have a variable 'distance', you could use the '+' operator to increase the distance value by a certain amount.

  1. Set variable... > ('distance' to 0)

  2. Change variable... > ('distance' by 5 using '+')

Comparison Operators: These let you compare two values and evaluate to a Boolean (true or false) result. For instance, you might use an equality (==) operator to check if two values are the same, or a greater than (>) operator to check if one value is larger than another. This can be useful in 'if' conditions.

  1. If... > ('distance' is '>=' 10)

  2. Then... > ('Stop moving')

Logical Operators: These allow you to perform operations on Boolean values. The most common logical operators are 'and', 'or', and 'not'. You could use these in more complex conditions.

  1. If... > ('distance' is '<=' 5) 'and' ('battery level' is '>=' 20%)

  2. Then... > ('Move forward')

Assignment Operators: These operators are used to assign a new value to a variable. The basic assignment operator is '=', but there are also compound assignment operators like '+=' and '-=' which change the value of the variable and assign it in one step.

  1. Set variable... > ('distance' to 'distance + 5') using '+='

These examples give you an idea of how you might use operators in block programming.

Recent Posts

See All
Block Programming - Functions

Functions are a fundamental concept in programming, including block programming, because they allow you to group a set of actions...

 
 
Block Programming - Variables

Variables in block programming work similarly to those in text-based programming languages. They allow you to store and manipulate data...

 
 

Kommentarer


Det er ikke lenger mulig å kommentere dette innlegget. Kontakt nettstedseieren for mer informasjon.

Tel: 1-888-876-4265

© 2019 Rohbot Kit by illuminEd Inc

Sign up to receive Rohbot news and updates.

Thanks for submitting!

© Rohan  Jay  - High School Senior at  PRISMSUS 

american_citizenship_award_pin.jpg
image.png
image.png
bottom of page