Python Variables and Data Types Flashcards
1
Q
Comparison Operators
A
are used to write expressions that compare one value with another
The expressions always result in True or False
2
Q
comparison expression sample:
A
print(“mint” == “strawberry”)
>False
3
Q
Comparison operators
A
Equals == (100==100) Not equal != (100!=100) Less than < (100<100) Greater than > (100>100) Less than or equal <= (100<=100) Greater than or equal >= (100=>100)
4
Q
Comparison Operators with if
A
my_name = "Brighticorn" your_name = "Grace Hopper"
if my_name == your_name:
print(“We have the same name!”)
else:
print(“You have a cool name.”)
> You have a cool name.
5
Q
more samples
A
password = "love2code" input_password = "love_to_code"
if password != input_password:
print(“ACCESS DENIED”)
> ACCESS DENIED