Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Server Side Programming Articles
Page 606 of 2109
Develop Notepad using Tkinter in python
Tkinter is a standard GUI library in Python that enables developers to create desktop applications. In this tutorial, we'll build a fully functional notepad text editor with file operations, editing features, and menu functionality using Tkinter. Prerequisites Python installed (3.x recommended) Tkinter module (comes pre-installed with Python) Note: Tkinter is included as a standard library with Python 3.x installations. Notepad Menu Structure Our notepad will contain four main menu categories with their respective sub-items: File Menu: New, Open, Save, ...
Read MoreMD5 hash encoding using Python?
Data security is a major concern for all IT companies. Multiple hashing techniques are available to protect and verify our data integrity. One of the most commonly used hashing algorithms is MD5, which we can easily implement in Python. What is Hash? A hash function takes a variable-length sequence of bytes as input and converts it to a fixed-length sequence. Getting your original data back from the hash is computationally difficult. For example, if x is your input and f is the hashing function, then calculating f(x) is quick and easy, but trying to obtain x again is ...
Read MorePrint Colors of terminal in Python
In the terminal, if you want to make text appear in colored mode, there are numerous ways in Python programming to achieve it. Python offers several modules and built-in methods to add colors to terminal output. Using the termcolor Module The termcolor module provides ANSI color formatting for terminal output. It's one of the most popular libraries for adding colors to text. Installation First, install the termcolor module using pip − pip install termcolor Basic Usage Here's how to use termcolor to print colored text − import sys from ...
Read MoreReplacing strings with numbers in Python for Data Analysis
In data analysis, converting categorical strings to numerical values is essential for machine learning algorithms and statistical analysis. Python provides several methods to map string values to integers efficiently. Consider this sample dataset with stock recommendations ? Company Industry Recommendation HDFC Bank Finance Hold Apollo Healthcare Buy Hero Automobile Underperform Yes Bank Finance Hold M&M Automobile Underperform Fortis Healthcare Buy We need to convert the Recommendation column to numerical values: Buy=1, Hold=2, Underperform=3. Method 1: Using ...
Read MorePattern matching in Python with Regex
Regular expressions (regex) are a powerful tool for pattern matching and string manipulation in Python. The re module provides comprehensive regex functionality for finding, matching, and replacing text patterns. What is Regular Expression? A regular expression is a sequence of characters that defines a search pattern. In Python, the re module handles string parsing and pattern matching. Regular expressions can answer questions like ? Is this string a valid URL? Which users in /etc/passwd are in a given group? What is the date and ...
Read MoreWhy is python best suited for Competitive Coding
Competitive programming involves solving algorithmic problems efficiently using appropriate data structures within time constraints. Programmers must not only solve problems correctly but also optimize for time and space complexity. Here's an example of a typical competitive programming problem ? Given a string s of length n with only lowercase letters, calculate the number of ways to remove exactly one substring so that all remaining characters are equal. You must remove at least one character. While any programming language can solve such problems, Python offers unique advantages for competitive coding. Development Speed Python significantly ...
Read MorePerforming Google Search using Python code?
In this article, we will learn how to perform Google searches using Python code. This is particularly useful when working on projects that need to access web data or integrate search results into your application. Prerequisites Python installed on your system Install the google module using pip ? pip install google Method 1: Getting Search Result URLs This approach returns a list of URLs from Google search results that you can use programmatically ? # Performing Google search and getting URLs class GoogleSearch: def __init__(self, ...
Read MoreHow to generate byte code file in python
Python automatically compiles your source code to bytecode (stored in .pyc files) before executing it. This compiled bytecode is stored for faster execution on subsequent runs. When you import a module for the first time, or when your source file is newer than the existing compiled file, Python creates a .pyc file. In Python 3, these files are stored in a __pycache__ subdirectory rather than alongside your .py file. Automatic Bytecode Generation The simplest way to generate a .pyc file is to import the module ? # Create a simple module first (save as test_module.py) ...
Read MorePython program to check if a number is Prime or not
A prime number is a natural number greater than 1 that has exactly two factors: 1 and itself. Numbers like 2, 3, 5, 7, 11 are prime numbers because they cannot be divided evenly by any other number except 1 and themselves. Let's say the following is our input − 7 The output should be as follows − Prime Number Using Basic Loop Method Let us check if a number is prime using a for loop by testing divisibility from 2 to half of the number − Example ...
Read MoreDefining Clean Up Actions in Python
There are numerous situations where we want our program to perform specific cleanup tasks, regardless of whether it runs successfully or encounters an error. While we commonly use try and except blocks to handle exceptions, Python provides a special clause for defining cleanup actions. The finally clause in a try statement is designed for defining cleanup actions that must be executed under any circumstances ? Basic Syntax try: raise SyntaxError("Sample error") finally: print("Learning Python!") Learning Python! Traceback (most recent call last): File "", ...
Read More