Akshitha Mote has Published 37 Articles

Do you think declarations within Python class are equivalent to those within __init__ method?

Akshitha Mote

Akshitha Mote

Updated on 24-Apr-2025 19:11:45

163 Views

In Python, the declarations within a class are not equivalent to those within the __init__() method. Let's discuss the class and __init__() method. A class is a collection of objects. It contains the blueprints or the prototype from which the objects are being created. It ... Read More

Does Python have “private” variables in classes?

Akshitha Mote

Akshitha Mote

Updated on 24-Apr-2025 18:59:51

2K+ Views

In Python there are no private variables in classes. By default all the variables and methods are public. There is sometimes an emulation of private variables by using the double underscore __ prefix to the variable's names. This makes these variables not ... Read More

What is function of ^ operator in Python

Akshitha Mote

Akshitha Mote

Updated on 18-Apr-2025 21:45:21

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) ... Read More

Explain function of % operator in Python.

Akshitha Mote

Akshitha Mote

Updated on 18-Apr-2025 19:16:17

552 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 (*), ... Read More

Does Python have a ternary conditional operator?

Akshitha Mote

Akshitha Mote

Updated on 18-Apr-2025 19:13:45

249 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 ... Read More

How to create an empty list in Python?

Akshitha Mote

Akshitha Mote

Updated on 17-Apr-2025 16:42:25

597 Views

In Python, list is one of the built-in data types. A Python list is a sequence of items separated by commas, enclosed in square brackets [ ]. The items in a Python list need not be of the same data type.  In this article, we will discuss different ways to ... Read More

How to create Python dictionary from list of keys and values?

Akshitha Mote

Akshitha Mote

Updated on 17-Apr-2025 16:41:25

23K+ Views

In Python, the dictionary is one of the built-in data types that stores the data in the form of key-value pairs. The pair of key-value is separated by a comma and enclosed within curly braces {}. The key and value within each pair are separated by a colon (:). Each ... Read More

What is tilde (~) operator in Python?

Akshitha Mote

Akshitha Mote

Updated on 15-Apr-2025 17:47:07

7K+ 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 ... Read More

How to convert an integer to an ASCII value in Python?

Akshitha Mote

Akshitha Mote

Updated on 15-Apr-2025 14:44:38

2K+ Views

Converting Integer to ASCII Using chr() Function In Python, the chr() function converts an integer value to the corresponding ASCII (American Standard Code for Information Interchange) character only if the integer range lies between 0 and 127. The chr() function accepts Unicode values within the range of 0 to 1114111. ... Read More

What is behavior of ++ and -- operators in Python?

Akshitha Mote

Akshitha Mote

Updated on 15-Apr-2025 14:28:21

238 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 ... Read More

Advertisements