Variable Hacks

Hacks #1:

Answer these:

  • In your own words, briefly explain by writing down what an assignment operator is
  • An assignment operator is an equal sign, which is needed in order to store a value inside a variable.
  • In Collegeboard pseudocode, what symbol is used to assign values to variables?
  • <–
  • A variable, x, is initially given a value of 15. Later on, the value for x is changed to 22. If you print x, would the command display 15 or 22?
  • 22

Hacks #2:

Questions

  • What is a list? A: Lists are sequences of elements where every element = a variable.

  • What is an element A: Elements are variables that are parts of lists.

  • What is an easy way to reference the elements in a list or string? A: An easy way to access elements is by putting the elements in an index and then using numbers to call specific parts of the string.

  • What is an example of a string? A: “hello world”

Hacks

  • Create a list with indices
  • Index a part of the list that you created.
  • Try to index from the end

Create an index of your favorite foods

Tips: Index starts at 1, Strings are ordered sequences of characters

Extra work: Try to create an index that lists your favorite food and print the element at index 3. More work: Create a list of your favorite foods and create an index to access them.

Number List Fix

Variable Quiz

Simplify Food List

Managing Complexity List