- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Arjun Thakur has Published 1109 Articles
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
Arjun Thakur
360 Views
Following is a program to swap two numbers using XOR operator.Examplepublic class ab31_SwapTwoNumberUsingXOR { public static void main(String args[]){ int a, b; Scanner sc = new Scanner(System.in); System.out.println("Enter a value :"); a = sc.nextInt(); ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
Arjun Thakur
813 Views
Recursion is the process of repeating items in a self-similar way. In programming languages, if a program allows you to call a function inside the same function, then it is called a recursive call of the function.Following is an example to find palindrome of a given number using recursive function.Examplepublic ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
Arjun Thakur
3K+ Views
Selection sort is a simple sorting algorithm. This sorting algorithm is an in-place comparison-based algorithm in which the list is divided into two parts, the sorted part at the left end and the unsorted part at the right end. Initially, the sorted part is empty and the unsorted part is ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
Arjun Thakur
121 Views
You can create an array to keep track of all non digit characters in a string. Then finally join this array using "".join method. examplemy_str = 'qwerty123asdf32' non_digits = [] for c in my_str: if not c.isdigit(): non_digits.append(c) result = ''.join(non_digits) print(result)OutputThis will give the outputqwertyasdfexampleYou can ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
Arjun Thakur
2K+ Views
You can find the hash of a file using the hashlib library. Note that file sizes can be pretty big. Its best to use a buffer to load chunks and process them to calculate the hash of the file. You can take a buffer of any size.Exampleimport sys import hashlib ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
Arjun Thakur
430 Views
The JSON module is a very reliable library to serialize a Python dictionary into a string, and then back to a dictionary. The dumps function converts the dict to a string. exampleimport json my_dict = { 'foo': 42, 'bar': { 'baz': "Hello", 'poo': ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
Arjun Thakur
2K+ Views
To write an SQL in query, you need to ensure that you provide the placeholders in the query using so that the query is properly escaped. For example, Examplemy_tuple = ("Hello", "world", "John") placeholder= '?' placeholders= ', '.join(placeholder for _ in my_tuple) query= 'SELECT name FROM students WHERE id IN ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
Arjun Thakur
97 Views
If you want to check if an object, x is an instance of exactly a given type(not a subtype), you can use typeto get its type and check using is statement.examplex = "Hello" if type(x) is str: print("x is an instance of str")OutputThis will give the outputx is an ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
Arjun Thakur
522 Views
Python has a function called defaultdict that groups Python tuple elements by their first element.Examplelst = [ (1, 'Hello', 'World', 112), (2, 'Hello', 'People', 42), (2, 'Hi', 'World', 200) ]from collections import defaultdictd = defaultdict(list) for k, *v in lst: d[k].append(v) print(d)OutputThis will give the outputdefaultdict(, ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
Arjun Thakur
19K+ Views
You need to decode the bytes object to produce a string. This can be done using the decode function from string class that will accept then encoding you want to decode with. examplemy_str = b"Hello" # b means its a byte string new_str = my_str.decode('utf-8') # Decode using the utf-8 encoding ... Read More