Introduction to Operations

Operations in Artsy refer to mathematical and logical calculations that can be performed on variables and constants. Some common operations in Artsy include addition, subtraction, multiplication, division, modulo, and comparisons (such as equal to, not equal to, greater than, less than, etc.). In this section, we'll explore some simple programs that demonstrate how these operations work in Artsy.

Let's start with a program that adds two numbers:

# declare the variables
declare a as int;
declare b as int;
declare c as int; 

# initialize the variables 
let a = 5;
let b = 7;
let c = a + b;

# print
print c;

In this program, we declare two integer variables a and b, and then assign them the values 5 and 7 respectively. We then use the addition operator + to add a and b together, and store the result in a new variable c. Finally, we print the value of c.

Next, let's look at a program that uses a comparison operator:

# declare the variables
declare a as int;
declare b as int;

# initialize the variables
let a = 5;
let b = 7;

# if statements 
if (a < b) {
  print "a is less than b";
} else {
  print "a is greater than or equal to b";
}

In this program, we declare two integer variables a and b, and then assign them the values 5 and 7 respectively. We then use the less than operator < to compare a and b. If a is less than b, we print the message "a is less than b". Otherwise, we print the message "a is greater than or equal to b".

Now, let's look at a program that uses a modulo operator (WIP):

# declare the variables
declare a as int;

# initialize the variables 
let a = 10;
let b = 3;
let c = a % b; (Working Progress)

# print
print c;

In this program, we declare an integer variable a, and assign it the value 10. We also declare another integer variable b, and assign it the value 3. We then use the modulo operator % to find the remainder when a is divided by b, and store the result in a new variable c. Finally, we print the value of c.

These are just a few examples of the many different operations that can be performed in Artsy. By combining these operations, you can create more complex programs and algorithms.

Return to Homepage

Artsy Coding