You are on page 1of 3

Think.Create.

Code
Code101x Course Handout

Course Details

No Prerequisites Required
Expressions: Resource Support
Course Dates
This course is self-paced. Expressions can be a powerful way to make the production of artwork
Start Date: 30th September 2015 with code more efficient and easier to manipulate. We can use
0:00 AM UTC
operators to control our code and make changes.
Finish Date: 31st March 2016
0:00 AM UTC
In Week 2, we introduce the use of expressions. In this reference sheet
Time Commitment below, we have included a list of common operators and advice on
Between 2 to 3 hours per week. calculating expressions that might provide a useful guide when using
expressions in your code.
Assessment Due Date
This course is self-paced so you
can complete your assessments Operators Quick-Reference List
when it suits you.
Operators
Grading Scheme
Divide /
Pass (50% or higher)
Fail (under 50%) Multiply *
Addition +
Minus -
Increment ++
(increases value of integer by 1)
Decrement --
(Decreases value of integer by 1)
Modulo %
Calculates remainder when one
number is divided by another)
Logical Operators
AND &&
OR || (symbol above the backslash key
NOT !
Relational Operators
Equal to ==
Not equal to !=
Less than <
Greater than >
Less than or equal to <=
Greater than or equal to >=
The Order of Operations

The order in which we calculate expressions can impact on our answer.


So, in which order should we calculate our expressions? “PODM AS” is
a little trick to remember! Sometimes people also refer to this as
“BODMAS”.

The following is the sequence of rules to follow:


• Parentheses (brackets) first: Calculate items in brackets.
• Orders (or Exponents): Calculate Powers and Roots before
multiply, divide, add, or subtract. Follow these first rules first,
and then for D, M , A, S, from left to right.
• Division and Multiplication: Before add or subtract.
• Addition and Subtraction last.

For some of us it might take some practice and problem solving and
that is okay. We all learn at different paces. When calculating your
expressions, it can be extremely useful to work them out on paper first
and do them in steps. Let’s have a look at an example calculation
below.

Example Calculation

Let’s say we have the following expression:

int x = 5
(x+12)+(x*30)-11

First, we begin by replacing the x or y with the assigned integer. We


know that x is 5, so let’s replace the x with this information:

(5+12)+(5*30)-11

Okay, let’s follow our PODMAS rule and begin making our calculations.
We begin by attending to the brackets (parenthesis) first. Let’s begin by
adding 5 and 12 together:

((5+12)+5*30)-11
(17+5×30)-11

2 edx./adelaidex/code101x Code101x Course Handout


Let’s multiply 5 and 30 together as this is still within the bracket:

(17+150)-11

Now, let’s add 17 and 150 together first, as they are still within brackets:

167-11

Okay, now we can do our final calculation by subtracting 11 from 167


and our answer is:

156

For more information visit:


http://www.m athsisfun.com /operation-order-bodm as.htm l

Online Calculators

The following online calculators might be useful when practicing your


expression calculations and to check your answers:

• “Maths Is Fun”: http://www.mathsisfun.com/algebra/operations-


order-calculator.html

• “Wolfram”: www.wolframalpha.com

Using Expressions in the Discussion Forum

If you require further support, please seek help from your peers or the
instructor in the course discussion forum.

If you would like to use appropriate formatting for expressions in a


discussion post, edX have put together a resource for you about how
this can be done. Please view materials here: http://edx-guide-for-
students.readthedocs.org/en/latest/SFD_mathformatting.html

3 edx./adelaidex/code101x Code101x Course Handout

You might also like