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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

comparison expression sample:

A

print(“mint” == “strawberry”)

>False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

more samples

A
password = "love2code"
input_password = "love_to_code"

if password != input_password:
print(“ACCESS DENIED”)
> ACCESS DENIED

How well did you know this?
1
Not at all
2
3
4
5
Perfectly