Malhar Lathkar has Published 50 Articles

What does 'is' operator do in Python?

Malhar Lathkar

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

How do I sort a list of dictionaries by values of the dictionary in Python?

Malhar Lathkar

Malhar Lathkar

Updated on 31-Jan-2023 18:05:35

301 Views

In this article, we will show how to sort a list of dictionaries by the values of the dictionary in Python. Sorting has always been a useful technique in everyday programming. Python's dictionary is often used in a wide range of applications, from competitive to developer-oriented (example-handling JSON data). It ... Read More

How to replace backward "" slash from a string

Malhar Lathkar

Malhar Lathkar

Updated on 23-Jun-2020 14:44:01

490 Views

In Python it does give the desired result>>> var  = "aaa\bbb\ccc and ddd\eee" >>> var.split('\') ['aaa', 'bbb', 'ccc and ddd', 'eee']

How to replace Digits into String using Java?

Malhar Lathkar

Malhar Lathkar

Updated on 20-Jun-2020 13:19:39

1K+ Views

For this purpose, we create an object of HashMap class which is defined in java.util packageMap map = new HashMap();This hashmap object associates each digit with its corresponding word representationmap.put("0", "zero");Initialize an empty string object.String newstr="";Next, run a for loop over the length of given string and extract each character by ... Read More

How i can replace number with string using Python?

Malhar Lathkar

Malhar Lathkar

Updated on 20-Jun-2020 09:05:51

1K+ Views

For this purpose let us use a dictionary object having digit as key and its word representation as value −dct={'0':'zero', '1':'one', '2':'two', '3':'three', '4':'four',      '5':'five', '6':'six', '7':'seven', '8':'eight', '9':'nine'Initializa a new string object newstr=''Using a for loop traverse each character  ch from input string at check if it is ... Read More

Python3 - Why loop doesn't work?

Malhar Lathkar

Malhar Lathkar

Updated on 20-Jun-2020 07:39:18

102 Views

It does work. As you have used sleep() method inside the loop, no activity takes place for (0.9*36) seconds. It is not asking for input. After the end of loop, the window will show text field with the given string inside it.

How to indent an if...else statement in Python?

Malhar Lathkar

Malhar Lathkar

Updated on 18-Jun-2020 13:04:11

604 Views

One of the characteristic features of Python is use of uniform indent to denote a block of statements. A block is initiated by − symbol As soon as − symbol is typed and enter pressed, any Python aware editor will take cursor to next line with increased indent. All lines ... Read More

Can we use pass statement in a Python if clause?

Malhar Lathkar

Malhar Lathkar

Updated on 18-Jun-2020 13:01:38

79 Views

In Python, pass keyword is a dummy statement. It is used where a statement is necessary to fulfill syntax requirement but the actual implementation of processing logic is yet to be finalized. It can be used in if as well as else blockif expr==True:    pass else:    pass

What does colon ':' operator do in Python?

Malhar Lathkar

Malhar Lathkar

Updated on 18-Jun-2020 12:59:27

8K+ Views

The : symbol is used for more than one purpose in PythonAs slice operator with sequence −The − operator slices a part from a sequence object such as list, tuple or string. It takes two arguments. First is the index of start of slice and second is index of end ... Read More

What is tilde (~) operator in Python?

Malhar Lathkar

Malhar Lathkar

Updated on 18-Jun-2020 08:35:21

4K+ Views

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 1For example if a=60 (0011 1100 in binary) its complement is -61 (-0011 1101) stored ... Read More

Advertisements