Bitwise operator works on bits and performs bit by bit operation.
Assume if a=60; and b = 13; Now in binary format they will be as follows:
a = 0011 1100
Identity operators compare the memory locations of two objects.
There are two Identity operators explained below:
Operator
Description
**
Exponentiation(raise to the power)
~ + -
C complement, unary plus and minus (method names for the last two are +@ and -@)
Assume variable a holds 10 and variable b holds 20 then:
Example
=
There may be a situation when you want to check for another condition after a condition resolves a condition resolves to true. In such a situation, you can use the nested if construct.
There are following logical operators supported by Python language.
The continue statement in Python returns the control to the beginning of the while loop. The continue statement rejects all the remaining statements in the current iteration of the loop and moves the control back to the top of the loop.
In
Evaluates to true if it finds a variable in the specified sequence and false otherwise.
The break statement in python terminates the current loop and resumes execution at the next statement, just like the traditional break found in C.
The most common use for break is when some external condition is triggered requiring a hasty exit from a…
Python supports to have an else statement associated with a loop statements.
· If the else statement is used with a forloop, the else statement is executed when the loop has exhausted iterating the list.
The elif statement allows you to check multiple expressions for truth value and execute a block of code as soon as one of the conditions evaluates to true.
Like the else, the elif statement is optional. However, unlike else, for which there can be at…
The If statement of python is similar to that of other languages. The if statement contains a logical expression using which data is compared, and a decision is made based on the result of the comparison.
If the suite of an if clause consists only of a single line, it may go on the same line as the header statement:
Here is an example of a one-line if clause:
If(expression == 1) : print “value of expression is 1”
An else statement can be combined with an if statement. An elsestatement contains the block of code that executes if the conditional expression in the if expression in the if expression resolves to 0 or a false value.
The pass statement in python is used when a statement is required syntactically but you do not want any command or code to execute.
The pass statement is a null operation; nothing happens when it executes.