Page 278 - Ai_C10_Flipbook
P. 278
Name Symbol Purpose Example Output
Subtraction – Subtracts second values from 14-9 5
the first value. 5.5-2 3.5
Comparison or Relational Operators
Comparison or relational operators evaluate the values on both sides of the operator and return a Boolean result:
True if the condition is met and False otherwise. Relational operators used in Python are given below:
Name Symbol Purpose Example Output
Equal to == Returns True if both the a=16
values are same. b=12
a==b False
Not equal to != Returns True if both the a="Hello"
values are different. b="hello"
a!=b True
Greater than > Returns True if first value Num1=34
is greater than the second Num2=23
value.
Num1>Num2 True
Less than < Returns True if first value is Num1=15
less than the second value. Num2=10
Note, strings are compared
Num1<Num2 False
using their ASCII values.
"Hi">"HI" True
"67">"621" True
Greater than or equal >= Returns True if first value is Num1=5
to greater than or equals to Num2=10
second value.
Num1>=Num2 False
Less than or equal to <= Returns True if first value Num1=5
is less than or equals to Num2=10
second value.
Num1<=Num2 True
Brainy Fact
ASCII Stands for "American Standard Code for Information Interchange." It is a character encoding
standard that uses numeric codes to represent characters in upper and lower case, numbers, and
punctuation symbols.
ASCII value of capital letters A–Z is 65 to 90, small letters is 97 to 122 and numbers 0 to 9 is 48 to 57.
276 Artificial Intelligence Play (Ver 1.0)-X

