Fiveable
Fiveable
pep
Fiveable
Fiveable

or

Log in

Find what you need to study


Light

3.3 Mathematical Expressions

3 min readdecember 23, 2022

Minna Chow

Minna Chow

Milo Chang

Milo Chang

Minna Chow

Minna Chow

Milo Chang

Milo Chang

An algorithm is a set of instructions used to accomplish a specific task or solve a problem.

Sound familiar? The definition of an algorithm is very close to the definition of a program. That said, there are some major differences. The key difference is that an algorithm represents the problem-solving logic, while a program is how you carry it out. Programs execute algorithms.

Going back to our cake metaphor from Big Idea 1, an algorithm would represent the steps you take to make the cake while a program would represent the written recipe that the baker, or computer, uses to make the cake.

Algorithms can be expressed in a wide range of ways. They can be formally written out in a programming language like C+ or Java (or a block-based language like Scratch!) for a computer to execute, written out in or a natural language like English, or even drawn out in a diagram.

Your computer will only do exactly what you tell it to, so it's important to make sure you're being clear and detailed when transferring your algorithms from your head to a program.

Sequencing

Every algorithm is created using three basic concepts: , , and . These concepts are conveyed in code statements, which are parts of program code that express an action to be carried out.

consists of steps in your algorithm that are implemented in the order they're written in. Once you execute one statement, you go on to the next one.

first_number = 7
second_number = 5
sum_value = first_number + second_number
print (sum_value)

Each of these statements are run in sequential order: the computer reads and processes them one after the other.

We'll talk more about and later in Big Idea 3.

Expressions

Like you learned in math class, an expression is a statement that returns only one value.

It can consist of a value, a variable, an operator or a procedure call that returns a value.

Programs work with : your good old fashioned addition, subtraction, multiplication and division signs.

Here are the operators in College Board's .

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-YY4sZN7LIa6L.png?alt=media&token=41d381f1-b288-4484-af78-19e9d40bd57b

The arithmetic operators in Python are the same, except MOD is represented by the % sign.

You'll notice the addition of a new operator known as the MOD operator. This is short for the . In the a MOD b format, a is divided by b and MOD gives you what the remainder would be. For example, 13 MOD 3 would return 1 because 13 divided by 3 can be written as 4 remainder 1.

🔗 Code.org has created a visual to represent how MOD works known as the Modulo Clock.

Evaluating an expression is done through an order of operations specified by the programming language you're working with. It's generally going to be PEMDAS, like it is in mathematics. In College Board's , the has the same precedence as the multiplication and division operators. (PEMMDAS?)

❗Don't forget that, in the PEMDAS system, it's multiplication or division and addition or subtraction, depending on what order they're written in the equation. Liberal use of parentheses can help make some of this less confusing.

Key Terms to Review (7)

Arithmetic Operators

: Arithmetic operators are symbols used in programming languages to perform mathematical calculations such as addition, subtraction, multiplication, division, and modulus (remainder).

Iteration

: Iteration refers to the repetition of a set of instructions until a specific condition is met. It allows programs to perform tasks repeatedly without having to write repetitive code.

MOD operator

: The MOD operator, short for modulus, is a mathematical operation that returns the remainder when one number is divided by another.

Modulo operator

: The modulo operator, represented by the symbol %, is a mathematical operation that returns the remainder when one number is divided by another.

Pseudocode

: Pseudocode is a simplified programming language that uses plain English to outline the logic of a program. It helps programmers plan and organize their code before writing it in an actual programming language.

Selection

: Selection refers to the process of making a decision based on a condition or criteria. It allows the program to choose between different paths of execution.

Sequencing

: Sequencing refers to the order in which code statements are executed. It determines the flow of a program, with each statement being executed one after another.

3.3 Mathematical Expressions

3 min readdecember 23, 2022

Minna Chow

Minna Chow

Milo Chang

Milo Chang

Minna Chow

Minna Chow

Milo Chang

Milo Chang

An algorithm is a set of instructions used to accomplish a specific task or solve a problem.

Sound familiar? The definition of an algorithm is very close to the definition of a program. That said, there are some major differences. The key difference is that an algorithm represents the problem-solving logic, while a program is how you carry it out. Programs execute algorithms.

Going back to our cake metaphor from Big Idea 1, an algorithm would represent the steps you take to make the cake while a program would represent the written recipe that the baker, or computer, uses to make the cake.

Algorithms can be expressed in a wide range of ways. They can be formally written out in a programming language like C+ or Java (or a block-based language like Scratch!) for a computer to execute, written out in or a natural language like English, or even drawn out in a diagram.

Your computer will only do exactly what you tell it to, so it's important to make sure you're being clear and detailed when transferring your algorithms from your head to a program.

Sequencing

Every algorithm is created using three basic concepts: , , and . These concepts are conveyed in code statements, which are parts of program code that express an action to be carried out.

consists of steps in your algorithm that are implemented in the order they're written in. Once you execute one statement, you go on to the next one.

first_number = 7
second_number = 5
sum_value = first_number + second_number
print (sum_value)

Each of these statements are run in sequential order: the computer reads and processes them one after the other.

We'll talk more about and later in Big Idea 3.

Expressions

Like you learned in math class, an expression is a statement that returns only one value.

It can consist of a value, a variable, an operator or a procedure call that returns a value.

Programs work with : your good old fashioned addition, subtraction, multiplication and division signs.

Here are the operators in College Board's .

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-YY4sZN7LIa6L.png?alt=media&token=41d381f1-b288-4484-af78-19e9d40bd57b

The arithmetic operators in Python are the same, except MOD is represented by the % sign.

You'll notice the addition of a new operator known as the MOD operator. This is short for the . In the a MOD b format, a is divided by b and MOD gives you what the remainder would be. For example, 13 MOD 3 would return 1 because 13 divided by 3 can be written as 4 remainder 1.

🔗 Code.org has created a visual to represent how MOD works known as the Modulo Clock.

Evaluating an expression is done through an order of operations specified by the programming language you're working with. It's generally going to be PEMDAS, like it is in mathematics. In College Board's , the has the same precedence as the multiplication and division operators. (PEMMDAS?)

❗Don't forget that, in the PEMDAS system, it's multiplication or division and addition or subtraction, depending on what order they're written in the equation. Liberal use of parentheses can help make some of this less confusing.

Key Terms to Review (7)

Arithmetic Operators

: Arithmetic operators are symbols used in programming languages to perform mathematical calculations such as addition, subtraction, multiplication, division, and modulus (remainder).

Iteration

: Iteration refers to the repetition of a set of instructions until a specific condition is met. It allows programs to perform tasks repeatedly without having to write repetitive code.

MOD operator

: The MOD operator, short for modulus, is a mathematical operation that returns the remainder when one number is divided by another.

Modulo operator

: The modulo operator, represented by the symbol %, is a mathematical operation that returns the remainder when one number is divided by another.

Pseudocode

: Pseudocode is a simplified programming language that uses plain English to outline the logic of a program. It helps programmers plan and organize their code before writing it in an actual programming language.

Selection

: Selection refers to the process of making a decision based on a condition or criteria. It allows the program to choose between different paths of execution.

Sequencing

: Sequencing refers to the order in which code statements are executed. It determines the flow of a program, with each statement being executed one after another.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.