L8A Variables, Loops & Arrays

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

1/9

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

10 Terms

1
New cards

Variables

Values that can be changed over time. 

Think about a pointer system, where the variable points to the allocated memory where the value is stored

<p>Values that can be changed over time.&nbsp;</p><p>Think about a pointer system, where the variable points to the allocated memory where the value is stored</p>
2
New cards

Assignment Statements

Expression is evaluated first before being assigned to the variable

Conversely, its a variable pointing to a value

3
New cards

Assignment: Pros & Cons

  • Allows us to create object with state that can differ over time

  • Harder to debug/verify correctness and the subsitution model fails

4
New cards

Assignment vs Declaration

  • Assigning a new value to a declared name

  • Declaring a new name in a frame, in source names must be declared with a value assigned to it

5
New cards

Why subsitution model breaks down?

The subsitution model fails to account for the changes that happens during the assignment of variables.

In the example, the assignment on line 3 is not reflected in the subsitution model.

<p>The subsitution model fails to account for the changes that happens during the assignment of variables.</p><p>In the example, the assignment on line 3 is not reflected in the subsitution model.</p>
6
New cards

Mutable Data

Data that can be changed after being declared.

7
New cards

Arrays (Python Lists)

Data structure that stores a sequence of data elements accessible via index, starting 0. Read and write at Log(1) while in length of array.

8
New cards

Factorial with Loops Example

knowt flashcard image
9
New cards

Break VS Continue

  • Break stops the whole loop

  • Continue skips the remaining iteration of the loop and moves on to the next iteration

10
New cards

Destructive Function

Function that changes a pair in anyway