Found 34484 Articles for Programming

How does == operator works in Python 3?

Malhar Lathkar
Updated on 26-Feb-2020 10:58:05

111 Views

The == symbol is defined as equality operator. It returns true if expressions on either side are equal and false if they are not equal>>> (10+2) == 12 True >>> 5*5 == 5**2 True >>> (10/3)==3 False >>> 'computer'=="computer" True >>> 'COMPUTER'.lower()=='computer' True

What is object-oriented programming (OOP)?

Moumita
Updated on 10-Feb-2020 11:00:45

12K+ Views

Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which may contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods. For example, a person is an object which has certain properties such as height, gender, age, etc. It also has certain methods such as move, talk, and so on.ObjectThis is the basic unit of object-oriented programming. That is both data and function that operate on data are bundled as a unit called an object.ClassWhen you define a class, you define a blueprint for ... Read More

What is C++ programming language?

Paul Richard
Updated on 10-Feb-2020 10:58:50

4K+ Views

C++ is a programming language developed by Bjarne Stroustrup in 1979 at Bell Labs. C++ is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features. It is a superset of C, and that virtually any legal C program is a legal C++ program. C++ runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.It is a language that is − Statically typed − A programming language is claimed to use static typing when type checking is performed during compile-time as opposed to run-time. Compiled − A compiled ... Read More

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

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

10K+ 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.>>> bin(a)     #binary equivalent 0110 0100 '0b1100100' >>> b=a>>2     #binary equivalent 0001 1101 >>> b 25 >>> bin(b) '0b11001'

What does 'not in' operator do in Python?

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

227 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 'in' operator do in Python?

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

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

What does 'is not' operator do in Python?

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

302 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 are same.>>> a=10 >>> b=a >>> id(a), id(b) (490067904, 490067904) >>> a is not b False >>> a=10 >>> b=20 >>> id(a), id(b) (490067904, 490068064) >>> a is not b True

What does 'is' operator do in Python?

Malhar Lathkar
Updated on 09-Sep-2023 09:46:50

2K+ 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' operator returns false of id() values are different and true if they are same.>>> a=10 >>> b=a >>> id(a), id(b) (490067904, 490067904) >>> a is b True >>> a=10 >>> b=20 >>> id(a), id(b) (490067904, 490068064) >>> a is b False

What is Python equivalent of the ! operator?

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

2K+ 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 (** , ^ , %, //) ?

Malhar Lathkar
Updated on 26-Feb-2020 10:44:55

237 Views

In Python ** is a raised to operator. It returns x raised to y in the expression x**y>>> x=5 >>> y=3 >>> x**y 125^ is a bitwise XOR operator. Taking two bits as operands it returns 1 if one is 1 and other is 0>>> a=10 >>> bin(a)    #0001 1010 '0b1010' >>> b=20 >>> bin(b)    #0010 0100 '0b10100' >>> c=a^b >>> c   30 >>> bin(c)    #0011 1110 '0b11110'// is defined as floor division operator. It returns integer part of result of division operation>>> 10/3 3.3333333333333335 >>> 10//3 3For negative division, floor rounds towards negative infinity.>>> -10/3 ... Read More

Advertisements