Lecture 2: Variables, Assignment, Sequential Steps

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/31

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering key concepts from the lecture notes on variables, memory, naming, assignment, and sequential steps.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

32 Terms

1
New cards

Main Memory

The primary memory where variables live during program execution; part of the memory hierarchy; slower than CPU registers but larger and more persistent.

2
New cards

Memory hierarchy

Organization of memory levels from fastest/smallest to slowest/largest: CPU registers, Cache, Main Memory, Secondary Memory, Offline Memory.

3
New cards

Box metaphor

Main memory is like a collection of memory boxes that hold information used by the program.

4
New cards

Variable

A box of memory that holds a unit of information, such as a number; a named storage location.

5
New cards

Variable name

The label used to refer to a particular memory box; example age.

6
New cards

Python naming rules

Names can start with a letter or underscore, may contain letters, numbers, underscores, and cannot be a reserved keyword.

7
New cards

Python keywords

Reserved words in Python with special meaning, such as False, True, None, and, as, assert, break, class, continue, def, del, etc.

8
New cards

Reserved keyword

A word reserved by the language for its syntax and not allowed as an identifier.

9
New cards

Naming conventions

Desirable to use descriptive, readable names; constants often ALL_CAPS; variables usually start with lowercase; common prefixes for indexing like i, j, k.

10
New cards

Descriptive naming example

Volumeofthesphere is descriptive; shorter alternatives like Vsphere or Vsphere may be used.

11
New cards

Problem to software mapping

Process of translating a real world problem into software by identifying questions to answer and data to represent.

12
New cards

Payoff_time naming

A descriptive name for time to payoff, with variations like payofftime or payofftime_months for units.

13
New cards

Assignment

The process of putting a value into a memory box, replacing the old value.

14
New cards

Assignment statement

Python statement of the form a = b; first the right-hand side is evaluated, then the value is stored in the left-hand side.

15
New cards

Left-hand side (LHS)

The variable name that will hold the assigned value.

16
New cards

Right-hand side (RHS)

The value or expression that is evaluated to produce the value to store.

17
New cards

Evaluation order

In an assignment, the RHS is evaluated before updating the LHS.

18
New cards

Z = X + 1 example

Compute the value of X, add 1, then store the result in Z.

19
New cards

Sequential steps

A sequence of instructions executed in a specific order; essential for programming and solving problems.

20
New cards

Pseudocode

A flexible, natural language style for expressing steps before coding; focuses on procedure rather than details.

21
New cards

Pseudocode guidelines

Be clear, concise, use one action per line, use bullets, avoid code, start with high level steps.

22
New cards

Quadratic pseudocode

Pseudocode steps to solve a quadratic equation by setting coefficients, computing discriminant and roots, then displaying results.

23
New cards

Special assignment operators

Operators like +=, -=, *=, /= that modify the left-hand variable by the value on the right.

24
New cards

Output/print

Basic output to the console; print(x) displays the value of x, where x can be a literal, a variable, or an expression.

25
New cards

Order of operations

Standard precedence: multiplication and division before addition and subtraction; parentheses can change grouping.

26
New cards

Instruction pointer

Concept indicating the next instruction to execute when stepping through a sequence of statements.

27
New cards

Assignment sequences

Multiple assignments in order; tracking how each statement changes variable values.

28
New cards

3 variable example PI r volume

Example sequence: PI = 3.14159, r = 5.3, volume = PI * r * r * r * (4/3) demonstrating sequential assignments.

29
New cards

Self referential assignment

Assigning a variable using its current value, such as z = z + 1, which uses the old value on the RHS and updates the LHS.

30
New cards

Output example note

Using print to verify computations by displaying results or intermediate values.

31
New cards

Const vs variable naming

Constants are values that do not change; by convention named in ALL_CAPS to distinguish from regular variables.

32
New cards

Single variable placeholder

A variable name acts as a placeholder for its stored value in expressions, such as age in age + 3.