Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Articles - Page 967 of 1048
562 Views
The AND and & are logical operators in Python that are used to perform different operations. The AND is a logical AND operator, and the ampersand (&) is a bitwise operator. In this article, we will explore the behavior of these operators and their differences. AND Operator in Python The logical AND operator in Python needs two operands. This operator returns true if both operands are true and false if either operand is false. This operator is mostly used in situations where you want to make sure that two things are true at the same time. Example of the AND ... Read More
8K+ Views
The Boolean operators in Python return two values, either true or false. These operators are mostly used in conditional statements, loops, and logical expressions. Python has a built-in Boolean datatype that returns Boolean values based on comparisons or logical evaluations between operands. Boolean Operators in Python There are three main Boolean operators in Python: OR, AND, and NOT. These operators return Boolean values based on the operands. OR Operator in Python The OR operator in Python returns true if one of the operands is true and false if both operands are false. This operator ... Read More
742 Views
The modulo operator is denoted by the "%" symbol in Python. It can also be called the remainder operator because it is used to return the remainder of the division of two numeric operands. Using this operator, we can solve problems ranging from simple to complex. Syntax of Python Modulo Operator The modulo operator in Python works the same as the remainder of dividing the two numeric operands. Following is the syntax of the modulo operator - Result = a % b Where a and b are the operands, % represents the modulo operator, and ... Read More
8K+ Views
In Python, the bitwise operator ~ (pronounced as tilde) is a complement operator. It takes one bit operand and returns its complement. If the operand is 1, it returns 0, and if it is 0, it returns 1. For example, consider the 4-bit binary number (1100)2. By performing the tilde operation, each bit is flipped and results in (0011)2. Tilde Operation on Decimal Numbers When we perform a tilde operation on decimal numbers, the following steps are involved: Convert the decimal number to binary, including the sign. If the number is positive, place 0 in ... Read More
144 Views
Understanding the Operator in Python The is one of the operators available in Python. The present version that we are using is Python 3. The previous version was Python 2. Some of the operators in Python 2 don't support in Python 3. is used in Python 2, which is not supported in Python. The operator != is used in Python 3. The functionality of the or != is to represent not equal to. The output of these operators is in the format of Boolean values True or False. Syntax The following is the syntax for using ... Read More
312 Views
In C/C++, Java, etc., ++ and -- operators are defined as increment and decrement operators. In Python, they are not defined as operators. Increment and Decrement Operators in Python In Python, objects are stored in memory. Variables are just labels. Numeric objects are immutable. Hence, they can't be incremented or decremented. However, prefix ++ or -- doesn't give an error but doesn't perform either. As Prefix In the following example, when have used prefix increment which does not raise an error - x=5 print(++x) print(--x) Following is the output of the above code - 5 5 As Postfix In ... Read More
637 Views
The % symbol in Python is defined as the modulo operator. It can also called as remainder operator. It returns the remainder of the division of two numeric operands (except complex numbers). The Python modulo % operator is a part of arithmetic operations like addition (+), subtraction (-), multiplication (*), division (/), exponential (**), and floor division (//). The following is the basic syntax for the % modulo operator - x % y Modulo Operation on Integers When we perform a modulo operation on two integers, the result is the remainder of the division, ... Read More
1K+ Views
In Python, the XOR operator is one of the bitwise operators and is represented by the caret symbol ^. It returns 0 if both operands are the same and 1 if the operands are different. Truth Table of XOR The following is the truth table of the XOR (exclusive OR) operator - A B ... Read More
5K+ Views
In Python, 'not in' membership operator evaluates to true if it does not finds a variable in the specified sequence and false otherwise. For example >>> a = 10 >>> b = 4 >>> l1 = [1,2,3,4,5] >>> a not in l1 True >>> b not in l1 False Since 'a' doesn't belong to l1, a not in b returns True. However, b can be found in l1, hence b not in l1 returns False
319 Views
The Python ternary operator returns a value based on whether a condition is True or False. It is similar to an if-else statement but is expressed in a single line. For understanding the ternary operator, we need to have an idea about conditional statements. Let's have a basic understanding of the if-else statement. We will have an if block followed by an else block here. The if block is executed when the given condition is True, and the else block is executed if the given condition is False. The following is the basic syntax of the if-else statement - if condition: ... Read More