Table of contents |
|
Introduction |
|
Algorithms |
|
Sequencing in Algorithms |
|
Expressions |
|
Key Terms |
|
This chapter covers mathematical expressions and algorithms, key concepts in the AP Computer Science Principles course. It introduces algorithms, their relationship to programs, sequencing as a core algorithmic concept, and how expressions are used with arithmetic operators. Understanding these concepts is essential for creating and implementing algorithms in programming for the AP CSP exam.
Algorithms are built using three core concepts: sequencing, selection, and iteration. These are expressed through code statements, which are instructions for actions to be executed.
Sequencing refers to executing steps in the exact order they are written. For example:
first_number = 7
second_number = 5
sum_value = first_number + second_number
print(sum_value)
An expression is a statement that evaluates to a single value. It may include:
Programs use arithmetic operators for calculations, including addition (+), subtraction (-), multiplication (*), and division (/).
The operators in College Board’s Pseudocode align with Python, except for the MOD operator, which is represented as %
in Python. The Modulo (MOD) operator returns the remainder of a division operation. For example:
Order of Operations
1. What is a mathematical expression in the context of computer science? | ![]() |
2. How do algorithms use mathematical expressions in their processes? | ![]() |
3. What is the difference between an expression and an equation in programming? | ![]() |
4. Why is sequencing important in algorithms involving mathematical expressions? | ![]() |
5. Can you provide examples of common mathematical expressions used in algorithms? | ![]() |