VKS Pythonselection
VKS Pythonselection
Python
What are logical expression
Logical expression is an expression which
contain relational or logical operators and
return a Boolean value True or False.
Relational operators are > ,<,<=,>=,== !=
Relational operators are used to compare 2
values and return a Boolean value True or
False
Membership operator ‘in’ and identity operator
‘is’ also used to create an expression which
result in True or False
Identity comparison
The operators "is" and "is not" are used to
compare for object identity: "x is y" is True if and
only if x and y are the same object, i.e., they refer
to the same memory location. Object identity is
determined using the "id()" function.
if statement
if...else statement
if...elif...else staement
Nested if..else statement
if Boolean Expression:
STATEMENT(S)
# indentation for block must
The if statement starts with the if keyword
followed by the conditional expression.
The EXPRESSION must be followed by (:)
colon.