5-7 Notes
How .
grade1 = 90
grade2 = 65
grade3 = 60
grade4 = 75
grade5 = 95
grade1 + grade2 + grade3 + grade4 + grade5
print("100 == 100:",100==100)
print("Hello == Adios:","greeting"=="farewell")
print("Hello != Adios:","greeting"!="farewell")
print("Hello == Hola:","greeting"=="greeting")
print("5>=4:", 5>=4)
print ('')
# Notice that relational operators can even work on lists!
# For lists, the relational operator compares each respective component until an answer is derived
print("['a','b','c'] > ['x','y','z']:", ['a','b','c'] > ['x','y','z'])
print("[1,2,3,5] > [1,2,3,4]:", [1,2,3,5] > [1,2,3,4])
print("[1,2,3,5] < [1,2,3,4]:", [1,2,3,5] < [1,2,3,4])
print("[1,2,3,5] == [1,2,3,4]:", [1,2,3,5] == [1,2,3,4])
Logical Operators!
These types of operators don't necessarily deal with equivalent/non-equivalent values, but they rather work on operands to produce a singular boolean result
AND : returns TRUE if the operands around it are TRUE OR : returns TRUE if at least one operand is TRUE NOT : returns TRUE if the following boolean is FALSE Turn the following arithmetic phrases into either True or False statements as indicated USING LOGICAL OPERATORS
print("1 > 2 or 5 < 12:",)
# Output TRUE using OR ^
# Output FALSE using NOT
print("24 > 8:", "NOT 24 > 8")
# Output FALSE using AND
print("10 > 20:",)
num1 = 100
num2 = 100
sum = num1 + num2
if sum == 200:
print(sum)
print("is not equal to 200")
else:
print(sum)
cost = 10
expired == TRUE
if (expired == TRUE)
{
console.log("This product is expired")
}
else
{
if (cost >= 50)
{
console.log ("This product is too expensive.")
}
else
{
if (cost >= 25)
{
console.log ("This is a regular product")
}
else
{
console.log ("This is a cheap product")
}
}
}
const myQuestions = [
{
question: "What class are we in?",
answers: {
a: "Yeung, APCSP",
b: "Mortensen, APCSP",
c: "Swanson, APUSH"
},
correctAnswer: "b"
},
{
question: "Which group had the best lesson?",
answers: {
a: "Unit 1-2",
b: "Unit 3-4",
c: "Unit 5-7"
},
correctAnswer: "c"
},
{
question: "What coding language is this code written in?",
answers: {
a: "Python",
b: "C++",
c: "C#",
d: "Javascript"
},
correctAnswer: "d"
}
];