Malhar Lathkar has Published 50 Articles

What does 'is not' operator do in Python?

Malhar Lathkar

Malhar Lathkar

Updated on 26-Feb-2020 10:41:38

228 Views

In Python, is and is not operators are called identity operators. Each object in computer's memory is assigned a unique identification number (id) by Python interpreter. Identity operators check if id() of two objects is same. 'is not' operator returns true of id() values are different and false if they ... Read More

What does 'in' operator do in Python?

Malhar Lathkar

Malhar Lathkar

Updated on 26-Feb-2020 10:41:06

485 Views

In Python, in and not in operators are called membership operators. Their purpose is to check if an object is a member of a certain sequence object like string, list, or tuple. The in operator returns true if object is present in sequence, false if not found>>> 'p' in 'Tutorialspoint' ... Read More

What does 'not in' operator do in Python?

Malhar Lathkar

Malhar Lathkar

Updated on 26-Feb-2020 10:40:31

211 Views

In Python, in and not in operators are called membership operators. Their purpose is to check if an object is a member of a certain sequence object like string, list, or tuple. The not in operator returns false if object is present in sequence, true if not found>>> 'p' not ... Read More

What is right shift (>>) operator in Python?

Malhar Lathkar

Malhar Lathkar

Updated on 26-Feb-2020 10:37:00

9K+ Views

In Python >> is called right shift operator. It is a bitwise operator. It requires a bitwise representation of object as first operand. Bits are shifted to right by number of bits stipulated by second operand. Leading bits as towards left as a result of shifting are set to 0.>>> ... Read More

What is modulo % operator in Python?

Malhar Lathkar

Malhar Lathkar

Updated on 26-Feb-2020 10:23:56

349 Views

The % symbol is defined in Python as modulo operator. It can also be called remainder operator. It returns remainder of division of two numeric operands (except complex numbers).>>> a=10 >>> b=3 >>> a%b 1 >>> a=12.25 >>> b=4 >>> a%b 0.25 >>> a=-10 >>> b=6 >>> a%b 2 >>> a=1.55 >>> b=0.05 >>> a%b 0.04999999999999996

What are boolean operators in Python?

Malhar Lathkar

Malhar Lathkar

Updated on 26-Feb-2020 10:23:13

7K+ Views

The logical operators and, or and not are also referred to as boolean operators. While and as well as or operator needs two operands, which may evaluate to true or false, not operator needs one operand evaluating to true or false.Boolean and operator returns true if both operands return true.>>> ... Read More

What is different in | and OR operators in Python?

Malhar Lathkar

Malhar Lathkar

Updated on 26-Feb-2020 10:22:24

1K+ Views

In Python or is a logical operator and | is a bitwise operator. The or operator requires two opeans of any type and may be true or false. It returns true if any one operand evaluates to true.>>> a=50 >>> b=25 >>> a>40 or b>40 True >>> a>100 or b>> ... Read More

What is different in OR and AND operators in Python?

Malhar Lathkar

Malhar Lathkar

Updated on 26-Feb-2020 10:21:41

5K+ Views

In Python, and and or (along with not) are defined as logical operators. Both require two operands which may evaluate to true or false.The and operator returns True only if both operands are True.>>> a=50 >>> b=25 >>> a>40 and b>40 False >>> a>100 and b>> a==0 and b==0 False ... Read More

Does Python have a ternary conditional operator?

Malhar Lathkar

Malhar Lathkar

Updated on 26-Feb-2020 07:28:43

149 Views

Ternary operator was added in Python 2.5. Its syntax is:Syntaxx if expr==True else yExampleFollowing example illustrates usage>>> percent=59 >>> 'pass' if percent>=50 else 'fail' 'pass' >>> percent=45 >>> 'pass' if percent>=50 else 'fail' 'fail'

How to create a complex number in Python?

Malhar Lathkar

Malhar Lathkar

Updated on 24-Feb-2020 10:04:52

118 Views

Complex number is made up of real and imaginary parts. Real part is a float number, and imaginary part is any float number multiplied by square root of -1 which is defined as j.>>> no=5+6j >>> no.real 5.0 >>> no.imag 6.0 >>> type(no) The resulting object is of complex data ... Read More

Advertisements