Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

part 5: comparison operators understanding the symbols operator meaning…

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

  1. age == 16: true
  2. age >= 18: false

3 name == \sarah\: true

  1. name != \john\: true
  2. score > 90: false
  3. score <= 85: true
  4. age < 20: true

practice exercise 8: write the conditions
write the correct condition for each scenario

  1. check if someones name is exactly \alex\ condition
  2. check if temperature is at or below freezing (32 degrees) condition:
  3. check if a student did not get a perfect score (100) condition
  4. check if someone can rent a car (25 or older) condition:

Explanation:

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

Answer:

  1. name == "Alex"
  2. temp <= 32
  3. score != 100
  4. age >= 25