Recap:

  • We learned what is a assignment operator
  • We learned how to use the assignment operator
  • We learned how to store a value inside a variable using the assignment operator
  • We experimented with a few examples

Hacks:

Answer these:

  • In your own words, briefly explain by writing down what an assignment operator is
  • Assignment operator assign values to variables.
  • In Collegeboard pseudocode, what symbol is used to assign values to variables?
  • Arrows like "num1 → 3"
  • 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:

Copy the all the html code into a markdown file and run your local server. You will then see a decimal to binary converter near the html code. The problem is that it is not converting the decimal to binary. This is because the variables are not defined properly and it is your job to use the information learned today to fix the converter. Don't change the css

</p>
  • Define variable
  • It's a placeholder in your program for a value
  • It's also a variable is a named unit of data that can be assigned a value
</div> </div> </div>

Hacks

Questions

  • What is a list? Lists are sequences of elements with each element being a variable.
  • What is an element? Elements are the strings that are going to print.
  • What is an easy way to reference the elements in a list or string? With a bracket
  • What is an example of a string? Name, id, anything that is a letter, number, or words.

Hacks

  • Create a list with indices
  • Index a part of the list that you created.
  • Try to index from the end
shoppingList = ["lemon", "vegetable", "candy", "chip", "meat", "rice"]
print(shoppingList[-4])
candy

Hacks

num1=input("Input a number. ")
num2=input("Input a number. ")
num3=input("Input a number. ")
add=input("How much would you like to add? ")

# Add code in the space below
numlist = [int(num1), int(num2), int(num3)]


# The following is the code that adds the inputted addend to the other numbers. It is hidden from the user.

for i in numlist:
    numlist[i -1] += int(add)

print(numlist)
[1, 2, 3]
import getpass, sys

def question_with_response(prompt):
    print("Question: " + prompt)
    msg = input()
    return msg

questions = 4
correct = 0

print('Hello, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(questions) + " questions.")
question_with_response("Are you ready to take a test?")

rsp = question_with_response("The purpose of lists and dictionaries are to manage the ____ of a program")
if rsp == "complexity":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")

rsp = question_with_response("Lists are a form of data ______")
if rsp == "abstraction":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")

rsp = question_with_response("Which brackets are used to assign values to a variable to make a list?")
if rsp == "[]":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!") 

print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions))
Hello, antony running /home/antony/anaconda3/bin/python
You will be asked 4 questions.
Question: Are you ready to take a test?
Question: The purpose of lists and dictionaries are to manage the ____ of a program
complexity is correct!
Question: Lists are a form of data ______
abstraction is correct!
Question: Which brackets are used to assign values to a variable to make a list?
[] is correct!
antony you scored 3/4

Hacks

  • On a single markdown file:
    • Insert a screenshot of your score on the python quiz
    • Insert a screenshot of your simplifying of the food list
    • Why are using lists better for a program, rather than writing out each line of code?
    • Make your own list the "long and slow way" then manage the complexity of the list

Rubric

  • In ordere to earn a .20/.20 you must
    • On a markdown post:
    • make an attempt at the python quiz
    • Successfully simplify the food list
    • Answer the question in detail
    • Provide evidence of your own list that you coded
name1 = "Steven"
name2 = "Mike"
name3 = "Jack"
name4 = "Ava"
name5 = "Olivia"

name = [name1, name2, name3, name4, name5]
# slow way
print(name1, name2, name3, name4, name5)

# fast way
print(name)
Steven Mike Jack Ava Olivia
['Steven', 'Mike', 'Jack', 'Ava', 'Olivia']
name = ["chicken","bread","milk","cream","soda"]
print(name[2])
print(name[-1])
milk
soda
</div>