# Noemi Cabrera
# September 27, 2021
# In this lesson, I learned to use comparison operators in if conditionals. This makes it easier for the code to
# make decisions based on the input. The comparision operators are placed on the if statement. If the
# condition is true, the if statement will display. If it's not true, the else statement will display.
# I didn't have any difficulties in this activity.
# However, when I did the last task I forgot to put a colon at the end of the if statement, so a syntax error
# displayed. To fix this, I just added a colon at the end of the if statement.
# [ This code uses the comparison operator(>) to evaluate if 3 is greater than 5.
# Since 3 is not greater than 5, False is displayed.] review and run code
3 > 5
# [ This code uses the comparison operator (<=) to evaluate if 3 less than or equal to 5.
# Since 3 is less than 5, True is displayed. ] review and run code
3 <= 5
# [ This code assings the variable x the value of 3 using a single equal sign. Then x is evaluated to see if it
# equals to 9 by using 2 equal signs. This displays False, since x is not equal to 9. ] review and run code
x = 3
x == 9
# [ This code uses the comparison operators =! and == to evaluate if x is not equal to 9 and if x is equal to 3.
# Since x is not equal to 9 and equal to 3, True is displayed for both statements. ] review and run code
x = 3
print("x not equal 9 is", x != 9)
print("x equal 3 is", x == 3)
# [This code assings x a value. Then it displays True if x is equal to 13 and False if x is not equal to 13.]
x = 11
print("x is equal to 13 : ",x == 13)
# [This code assings a value to y and d. Then these are compared to see if y is greater than d.
# This displays to false because y is not greater than d.]
y= 3+3
d= 2+4
print ("3 + 3 is greater than 2 + 4 : ", y > d)
# [This code uses the (>) comparison operator in an if conditional. If x is greater than 25, the if statement will
# display. But if x is not greater than 25, the else statement will display.] review code and run cell
x = 21
if x > 25:
print("x is already bigger than 25")
else:
print("x was", x)
x = 25
print("now x is", x)
# [ This code uses the == comparison operator in an if conditional. The variable x is assigned 18. If x + 18 is
# equal to x + x, then the if statement will print. If this is not true, the else statement will print.]
# review code and run cell
x = 18
if x + 18 == x + x:
print("Pass: x + 18 is equal to", x + x)
else:
print("Fail: x + 18 is not equal to", x + x)
# [ In this code, the if statement tests if x is not equal to the variable test_value.
# Since x is equal to 18 and test_value is also equal to 18, the else statement will print.]
# review code and run cell. "!" means "not"
x = 18
test_value = 18
if x != test_value:
print('x is not', test_value)
else:
print('x is', test_value)
# [ This code displays a syntax error because the single equal sign is misused. The variable x is assigned 2 by
# using the single equal sign. However, in the if statement x is meant to be compared so you have to use the double
# equal sign (==).] review code and run cell
# DON'T ASSIGN (x = 2) when you mean to COMPARE (x == 2)
x = 2
if x = 2:
print('"==" tests for, is equal to')
else:
pass
# This code contains an if/else stament. If y is greater than x+x, the if statement will display.
# If y is not greater than x+x, the else statement will display.
x = 3
y = x + 8
if y >= x+x:
print("y greater than or equal x + x is True")
else:
print("y greater than or equal x + x is False")