Not Equals Operator
# Equal operator if 'Yes' == 'Yes': # evaluates to True print('They are equal') if (2 > 1) == (5 < 10): # evaluates to True print('Both expressions give the same result') c = '2' d = 2 if c == d: print('They are equal') else: print('They are not equal')
The equal operator,
==, is used to compare two values, variables or expressions to determine if they are the same.
If the values being compared are the same, the operator returns
True, otherwise it returns
The operator takes the data type into account when making the comparison, so a string value of
"2" is not considered the same as a numeric value of
We’ve learned about and explored a powerful tool in Python — control flow! It’s so powerful, in fact, that it can be used to tell someone’s fortune.
Use your knowledge of control flow to create a program that will help Sal's customers get the best deals on all their shipping needs.