2.1 Basics

Enduring Understanding

      • To find specific solutions to generalizable problems, programmers represent and organize data in multiple ways.

      • The way statements are sequenced and combined in a program determines the computed result.

Lesson Objectives

  1. Represent a value with a variable.

  2. Determine the value of a variable as a result of an assignment.

  3. Express an algorithm that uses sequencing without using a programming language.

  4. Represent a step-by-step algorithmic process using sequential code statements.

  5. Evaluate expressions that use arithmetic operators.

  6. Represent a string using a variable.

  7. Evaluate expressions that manipulate strings.

  8. Represent a list using a variable.

  9. For list operations:

    • Write expressions that use list indexing and list procedures.

    • Evaluate expressions that use list indexing and list procedures.

  10. For relationships between two variables, expressions, or values:

    • Write expressions using relational operators.

    • Evaluate expressions that use relational operators.

  11. For relationships between Boolean values:

    • Write expressions using logical operators.

    • Evaluate expressions that use logic operators.

  12. For generating random values: a. Write expressions to generate possible values. b. Evaluate expressions to determine the possible results.

Essential Knowledge

  1. A variable is an abstraction inside a program that can hold a value. Each variable has associated data storage that represents one value at a time, but that value can be a list or other collection that in turn contains multiple values.

  2. Using meaningful variable names helps with the readability of program code and understanding of what values are represented by the variables.

  3. Some programming languages provide types to represent data, which are referenced using variables. These types include numbers, Booleans, lists, and strings.

  4. Some values are better suited to representation using one type of data rather than another.

  5. The assignment operator allows a program to change the value represented by a variable.

  6. The value stored in a variable will be the most recent value assigned.

  7. An algorithm is a finite set of instructions that accomplish a specific task.

  8. Beyond visual and textual programming languages, algorithms can be expressed in a variety of ways, such as natural language, diagrams, and pseudocode.

  9. Algorithms executed by programs are implemented using programming languages.

  10. Every algorithm can be constructed using combinations of sequencing, selection, and iteration.

  11. Sequencing is the application of each step of an algorithm in the order in which the code statements are given.

  12. An expression can consist of a value, a variable, an operator, or a procedure call that returns a value.

  13. Expressions are evaluated to produce a single value.

  14. The evaluation of expressions follows a set order of operations defined by the programming language.

  15. Sequential statements execute in the order they appear in the code segment.

  16. Clarity and readability are important considerations when expressing an algorithm in a programming language.

  17. Arithmetic operators are part of most programming languages and include addition, subtraction, multiplication, division, and modulus operators.

  18. The order of operations used in mathematics applies when evaluating expressions. The MOD operator has the same precedence as the * and / operators.

  19. Some values are better suited to representation using one type of data rather than another.

  20. An index is a common method for referencing the elements in a string using natural numbers.

  21. A string is an ordered sequence of characters.

  22. String concatenation joins together two or more strings end-to-end to make a new string.

  23. A substring is part of an existing string.

  24. A list is an ordered sequence of elements.

  25. An element is an individual value in a list that is assigned a unique index.

  26. An index is a common method for referencing the elements in a list using natural numbers.

  27. Data abstractions can be created using lists.

  28. The exam reference sheet provides basic operations on lists, including:

    • accessing an element by index

    • assigning a value of an element of a list to a variable

    • assigning a value to an element of a list

    • inserting elements at a given index

    • adding elements to the end of the list

    • removing elements

    • determining the length of a list

  29. A Boolean value is either true or false.

  30. The exam reference sheet provides the following relational operators: =, ≠, >, <, ≥, and ≤.

  31. The exam reference sheet provides the logical operators NOT, AND, and OR, which evaluate to a Boolean value.

  32. The operand for a logical operator is either a Boolean expression or a single Boolean value.

  33. Exam reference sheet has a RANDOM method.

    • Using random number generation in a program means each execution may produce a different result.