
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10451 Articles for Python

2K+ Views
A Non-word character is any type of character that is not a letter, digit, or underscore, i.e., anything other than [a-z, A-Z, 0-9_]. Examples of non-word characters are symbols, punctuation marks, spaces, tabs, and other special characters. In Python, Regular Expressions (RegEx) are used to match the patterns in the given input strings. The re module in Python provides different methods to use the regular expressions. This module helps the developers to perform search operations, validations, filtering and much more, based on string patterns. To match a non-word character in Python, we can use the special character class \W inside ... Read More

4K+ Views
In Python, Regular Expressions (RegEx) are used to match patterns in the given input strings. The re module in Python provides different methods to use the regular expressions. This module helps the developers to perform search operations, validations, filtering, and much more based on string patterns. In this article, we will explore different ways to match a word in Python using the re module. Match a Specific Word using re.search() In Python, the re.search() method is used to search for a pattern within a given string. If the pattern is found, then it returns a match object otherwise, it returns ... Read More

239 Views
A Dictionary in Python is a mutable, unordered collection of data in a key-value format. A dictionary can also contain another dictionary as a value, and this is known as a Nested Dictionary or a dictionary within a dictionary. In this article, we are going to explore all the different ways to use a dictionary within a dictionary in Python. Syntax to define a Dictionary within another Following is the syntax of creating a Dictionary within another Dictionary in Python - outer_dict = { 'key1': { 'inner_key1': ... Read More

153 Views
When we are starting with Python, mostly created first program will be "Hello, World", which prints the statement "Hello, World" as the output. Before we begin with the first program, we need to install Python in our system from the official website. Choose a Code Editor After installing Python, we need to select the text editor based on our requirements and usage. Following are the different editors available - IDLE: It comes pre-installed with Python VS Code: A popular and lightweight code editor PyCharm: This is useful ... Read More

887 Views
A dictionary in Python is a collection of key-value pairs. In a few cases, we may have to remove a key and its associated value from a dictionary. Python provides multiple ways to do this safely and efficiently. Using pop() method The pop() method is used to remove the specified key and returns the corresponding value. If the key does not exist, then it raises a KeyError unless a default value is provided. Example Following is an example, which shows how to remove a key from the dictionary using the pop() method - my_dict = {'a': 1, 'b': 2, 'c': ... Read More

919 Views
Adding new keys to a dictionary in Python, can done by simply assigning a value to a key that isn't present. There are several ways to do this, which include different methods and techniques for adding keys and their corresponding values. Using update() Method Using Assignment (=) operator Using the ... Read More

204 Views
In Python, merging dictionaries is a common task that combines key-value pairs from two or more dictionaries into a single dictionary. If duplicate keys exist, the values from the second dictionary will typically take precedence when merging. Python offers several methods for merging dictionaries, each with its characteristics. Below are some common methods: Using double asterisk (**) Operator Using update() Method Using collections.ChainMap class Using ( | ) merge Operator Using double asterisk (**) Operator We can combine two dictionaries in Python using ... Read More

227 Views
In Python, converting different data types into strings is a common requirement when we want to display or store information in text format. The built-in str() function is used for this conversion. This function accepts any Python object as a parameter and returns a string representation of it. The basic syntax of the str() function is as follows: str(object) Where object is any valid Python object, such as int, float, bool, list, etc. In this article, we will explore different data type conversions into a string in Python. Conversion of Integer to String An integer can be converted into ... Read More

772 Views
Data conversion in Python refers to changing the data type of a value to another data type. Python supports two different types of data conversion, such as Implicit conversion and explicit conversion. Implicit Conversion is performed by the Python interpreter automatically. Explicit Conversion is manually done by the programmer using built-in functions in Python Implicit Conversion Python automatically converts one data type to another, and this type of conversion is called Implicit conversion. To avoid any data loss during runtime, the smaller data type is converted ... Read More

421 Views
When working with strings, we may need to concatenate or join multiple strings together. Python provides several methods to perform the concatenation of strings. Following are various ways to print concatenated strings using a single statement. Using the "+" Operator Using f-string Using format() Method Using join() Method Using print() with Multiple Arguments Using List or Tuple Unpacking Using map() with str Using the "+" Operator The "+" operator is the simplest and most direct way to concatenate two or more strings in Python. It joins the strings end-to-end. Here's an example of using the + operator - ... Read More