Found 10411 Articles for Python

How to convert an integer to a character in Python?

Gireesha Devara
Updated on 23-Aug-2023 18:36:02

36K+ Views

To convert an integer to a character in Python, we can use the chr() method. The chr() is a Python built−in method that returns a character from an integer. The method takes an integer value and returns a unicode character corresponding to that integer. Syntax char(number) Parameter The method takes a single integer between the range of 0 to 1, 114, 111. Return Value A unicode character of the corresponding integer argument. And it will raies a ValueError if we pass an out of range value (i, e. range(0x110000)). Also it will raise TypeError − for a non−integer argument. ... Read More

What is the #define Preprocessor in C++?

Jennifer Nicholas
Updated on 18-Jun-2020 13:05:52

533 Views

The #define creates a macro, which is the association of an identifier or parameterized identifier with a token string. After the macro is defined, the compiler can substitute the token string for each occurrence of the identifier in the source file.#define identifier token-stringThis is how the preprocessor is used. The #define directive causes the compiler to substitute token-string for each occurrence of identifier in the source file. The identifier is replaced only when it forms a token. That is, identifier is not replaced if it appears in a comment, in a string, or as part of a longer identifier.example#include #define ... Read More

What does 'not in' operator do in Python?

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

325 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 in 'Tutorialspoint' False >>> 'c' not in 'Tutorialspoint' True >>> 10 not in range(0,5)

What does \\\'is\\\' operator do in Python?

Disha Verma
Updated on 21-Apr-2025 16:34:55

3K+ Views

The "is" operator in Python is an identity operator. This operator checks whether two variables refer to the same object in memory. It returns boolean values as a result. Each object in the computer's memory is assigned a unique identification number (id) by the Python interpreter. Identity operators check if the id() of two objects is the same. The 'is' operator returns false if id() values are different and true if they are the same. Syntax of Python (is) Operator The "is" operator follows the following syntax in Python: variable1 is variable2 The "is" operator ... Read More

What is Python equivalent of the ! operator?

Gireesha Devara
Updated on 09-Sep-2023 09:48:50

3K+ Views

In some languages like C / C++ the "!" symbol is used as a logical NOT operator. !x it returns true if x is false else returns false. The equivalent of this "!" operator in python is logical NOT, It also returns true if the operand is false and vice versa. Example In the Following example the variable operand_X holds a boolean value True, after applying the not operator it returns False. operand_X = True print("Input: ", operand_X) result = not(operand_X) print('Result: ', result) Output Input: True Result: False Example For False value the ... Read More

What does these operators mean (** , ^ , %, //) ?

Disha Verma
Updated on 18-Apr-2025 14:10:06

365 Views

In Python, there are various types of operators used to perform specific functions, such as (**), (^), (%), and (//). The (**) operator represents exponentiation, (^) represents bitwise XOR, (%) represents the modulus operation, and (//) represents floor division. In this article, we will understand the workings of these operators. Exponentiation Operator (**) The exponentiation operator (**) is used to raise a number to a power. This operator works the same as the Python pow() method. In exponentiation, you need two numbers: the first is the base (the number you want to raise), and the second is ... Read More

What is the difference between = and == operators in Python?

Disha Verma
Updated on 18-Apr-2025 14:15:37

1K+ Views

The symbols "=" and "==" look similar but have different meanings and usability in Python. The "=" symbol is the assignment operator, and the "==" symbol represents a comparison operator. In this article, we will understand the difference between these two and how to use them. The "=" Operator The "=" operator in Python is the assignment operator. It is used to assign a value to a variable. You put the variable on the left side and the value or expression on the right side. The value on the right is stored in the variable on the ... Read More

What is different in OR and AND operators in Python?

Disha Verma
Updated on 18-Apr-2025 14:48:45

6K+ Views

The OR and AND operators are the most commonly used logical operators. The logical operators are used to perform decision-making operations. These combine multiple conditions and make a decision based on them. In this article, we will understand what OR and AND operators are in Python and how they differ, along with examples for better understanding. AND Operator in Python The logical AND operator in Python needs two operands. It returns true if both operands are true,  and it returns false if either of the operands is false. This operator is mostly used in situations where you ... Read More

What is different in | and OR operators in Python?

Disha Verma
Updated on 21-Apr-2025 16:33:43

1K+ Views

The OR and (|) are logical operators in Python. The difference between these two is that OR is a Logical OR operator, and | is a Bitwise OR Operator. Both operators are used to perform different operations. In this article, we will explore the behavior of these operators and their differences. 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 needs two values or operands to perform the operation and return the result. OR Operator Example The following ... Read More

What is different in & and AND operators in Python?

Disha Verma
Updated on 18-Apr-2025 15:05:04

475 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

Advertisements