Next, I list the available Python operators in their precedence order. I also provide some specific details about some of them.
The .(dot) operator is used to access attributes and methods of a variable (object). In the following example, the dot enables the object t to access its method append.
These are bitwise operators.
The % (modulo) operator lets you know whether a number is divisible by another number. For example, if a % b == 0, a is divisible by b.
These operators provide shifting operations. The <<operator ensures left shifting (at bit level),and the >>operator ensures right shifting (at bit level).>>> x = 2 # the binary representation is 0010
The bitwise AND operator
The bitwise XOR (exclusive OR) operator
The bitwise OR operator
The operators in and not in work only with lists. Another aspect of this group is that there's an important difference between the == operator and the = assigning symbol. ischecks whether two variables refer to the same object. On the other hand, is not checks whether two variables don't refer to the same object.
The == operator ensures equality testing, whereas = assigns a value to a variable.
Tip Keep in mind that x = y doesn't create a new copy of y. Instead, it makes a reference to it.
However, if later you define x=x+1, a new reference for x is created, and then they become different because the operator has created a new object.
Note that x.append(5) doesn't create a new reference to x because x changes itself withoutusing a = operator.
As a good programmer, you need to know that logical operations can also be emulated by using if statements. Note that the return values are not limited to zeros and ones.
The operation a and b can be written as the following:
The operation a or b can be written as the following:
The operation not a can be written as the following:
Starting with Python 2.0, the language also implements a full set of augmented assignment operators.That includes: +=, -=, *=, /=, %=, **=, &=, |=, ^=, »=, and «=
Python Related Interview Questions
|Perl Scripting Interview Questions||C++ Interview Questions|
|PHP Interview Questions||C Interview Questions|
|Ruby on Rails Interview Questions||Ruby Interview Questions|
|Django Interview Questions||Lisp programming Interview Questions|
|R Programming language Interview Questions||wxPython Interview Questions|
|Python Automation Testing Interview Questions|
Extending And Embedding Python
Objects Interfacing And Distribution
Working With Databases
Other Advanced Topics
Basic Network Background
Python And Guis
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.