Lesson 3.1-3.2 Notes and Homework
This is the jupyter notebook for lessons 3.1-3.2.
- Variables
- Assignments
- In Class Problems:
- Index always starts at 1 for the AP Exam, must be whole numbers, goes up the number of elements in the list, and cannot be negative
- AP Exam Differences
- Homework
num1 = 5
num2 = 9
num1 = num2
# num1 is 9, num2 is also 9
print("num1:",num1)
print("num2:",num2)
num1 = 15
num2 = 25
num3 = 42
num2 = num3
num3 = num1
num1 = num2
# num1 and num2 are 42, num3 is 15
print("num1:",num1)
print("num2:",num2)
print("num3:",num3)
num1 = 1
num2 = 4
# Both of these will show the sum:
print(num1 + num2)
num2 += num1
print(num2)
colorList = ["green", "red", "pink", "purple", "blue", "brown"]
# List starts at 0, but remember for the AP Exam it starts at 1
print(str(colorList))
questionNum = 0
score = 0
qList = ["What is 200/40?", "What is 45*2?", "What is 2^6?", "What is 1011 in binary equal to?", "What is 101110 in binary equal to?"]
qSoln = ["5", "90", "64", "22", "92"]
qAmount = len(qList)
while questionNum < qAmount:
print("Question #", str(questionNum + 1), ":", str(qList[questionNum]))
answer = input()
if answer == qSoln[questionNum]:
score += 1
print(answer, "is correct!")
else:
print(answer, "is incorrect!")
questionNum += 1
if questionNum == qAmount:
percent = (score/qAmount)*100
print("You Scored:", score, "/", qAmount, "(", str(percent), "%)")
print("Here are the answers:")
i = 0
while i < len(qSoln):
answerText = qSoln[i]
print("Question #", str(i+1), ":", answerText)
i += 1