QUESTION IMAGE
Question
part 5: comparison operators
understanding the symbols
operator meaning example
== equals age == 18
!= not equals name != \john\
greater than score > 80
< less than temp < 32
= greater than or equal grade >= 90
<= less than or equal speed <= 55
practice exercise 7: operator detective
for each condition, write true or false based on the given values
given: age = 16, name = \sarah\, score = 85
- age == 16: true
- age >= 18: false
3 name == \sarah\: true
- name != \john\: true
- score > 90: false
- score <= 85: true
- age < 20: true
practice exercise 8: write the conditions
write the correct condition for each scenario
- check if someones name is exactly \alex\ condition
- check if temperature is at or below freezing (32 degrees) condition:
- check if a student did not get a perfect score (100) condition
- check if someone can rent a car (25 or older) condition:
Step1: Analyze name - equality condition
We need to check if name is "Alex", so we use the "==" operator.
name == "Alex"
Step2: Analyze temperature - freezing condition
Freezing is 32 degrees and we want to check if temperature is at or below it, so we use "<=".
temp <= 32
Step3: Analyze non - perfect score condition
A perfect score is 100 and we want to check if score is not 100, so we use "!=".
score != 100
Step4: Analyze car - renting age condition
To rent a car one must be 25 or older, so we use ">=".
age >= 25
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
- name == "Alex"
- temp <= 32
- score != 100
- age >= 25