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
Programming Articles
Page 386 of 2547
Get Application Version using Python
In software development, whenever developers add new features or fix bugs in an application, they assign it a new version number. This helps users identify the latest updates and features available in that application. Using Python, we can retrieve the version of any application installed on Windows systems. We'll use the pywin32 library to interact with executable files through the Win32 API, which provides access to Windows system information. Installation First, install the required package ? pip install pywin32 Getting Application Version Here's how to retrieve the version number of any Windows ...
Read MoreExtract hyperlinks from PDF in Python
To extract hyperlinks from PDF in Python can be done using several libraries like PyPDF2, PDFminer, and pdfx. Each offers different approaches and capabilities for extracting URLs from PDF documents. PyPDF2: A Python built-in library that acts as a PDF toolkit, allowing us to read and manipulate PDF files. PDFMiner: A tool used for extracting information from PDF documents, focusing on getting and analyzing text data. ...
Read MoreDisable Exit (or [ X ]) in Tkinter Window
The window manager implements the Tkinter window control icons. To hide and show the Tkinter window control icons, we can use the built-in protocol() function, which describes whether we want to disable control icons' functionality. To disable the Exit or [X] control icon, we have to define the protocol() method. We can limit the control icon definition by specifying an empty function for disabling the state of the control icon. Syntax window.protocol("WM_DELETE_WINDOW", callback_function) Where: WM_DELETE_WINDOW - Protocol for window close event callback_function - Function to handle the close event (use empty function to ...
Read MoreCreating Tkinter full-screen application
Tkinter initially creates a window that contains application components such as widgets and control bars. We can switch a native-looking application to a full-screen application by using the attributes('-fullscreen', True) method. To make the window full-screen, just invoke the method with the particular window. Basic Full-Screen Example Here's how to create a basic full-screen Tkinter application ? # Import tkinter library from tkinter import * # Create an instance of tkinter frame or window win = Tk() # Set the geometry of tkinter frame win.geometry("750x250") # Create a Text widget text = Label(win, ...
Read MoreConvert Images to PDFs using Tkinter
Python is a scripting language that helps create various file converters. Using the img2pdf module and Tkinter, we can build a GUI application that converts multiple images into PDF format. The img2pdf library efficiently parses image data and converts it to PDF without quality loss. Installation First, install the required module ? pip install img2pdf Building the Image to PDF Converter We will create a Tkinter application with file selection dialog and conversion functionality ? from tkinter import * from tkinter import filedialog, messagebox from tkinter import ttk import img2pdf import ...
Read MoreSort a List of Tuples in Increasing Order by the Last Element in Each Tuple using Python program
When working with lists of tuples, you often need to sort them based on the last element of each tuple. Python provides multiple approaches: using sorted() with a key function, the list.sort() method, or implementing a custom bubble sort algorithm. Using sorted() with Key Function The most Pythonic approach uses sorted() with a lambda function as the key ? data = [(1, 92), (34, 25), (67, 89)] print("Original tuple list:") print(data) # Sort by last element of each tuple sorted_data = sorted(data, key=lambda x: x[-1]) print("Sorted list of tuples:") print(sorted_data) Original tuple ...
Read MorePython Program to Find the Cumulative Sum of a List where the ith Element is the Sum of the First i+1 Elements From The Original List
When it is required to find the cumulative sum of a list where the ith element is the sum of the first i+1 elements from the original list, we can use different approaches. The cumulative sum creates a new list where each element represents the running total up to that position. Method 1: Using List Comprehension This approach uses list comprehension with slicing to calculate cumulative sums ? def cumulative_sum(my_list): cumulative_list = [] my_length = len(my_list) cumulative_list = [sum(my_list[0:x:1]) for x in range(1, my_length+1)] ...
Read MorePython Program to Find all Numbers in a Range which are Perfect Squares and Sum of all Digits in the Number is Less than 10
When it is required to find all numbers in a range that are perfect squares and the sum of digits in the number is less than 10, list comprehension is used. A perfect square is a number that can be expressed as the product of an integer with itself. Below is the demonstration of the same − Example lower_limit = 5 upper_limit = 50 numbers = [] numbers = [x for x in range(lower_limit, upper_limit + 1) if (int(x**0.5))**2 == x and sum(list(map(int, str(x)))) < 10] print("The result is:") print(numbers) Output The ...
Read MorePython Program to Create a List of Tuples with the First Element as the Number and Second Element as the Square of the Number
When you need to create a list of tuples where each tuple contains a number and its square, Python provides several approaches. The most common methods are list comprehension, using loops, and the map() function. Using List Comprehension List comprehension provides a concise way to create the list of tuples ? numbers = [23, 42, 67, 89, 11, 32] print("The list is:") print(numbers) result = [(num, pow(num, 2)) for num in numbers] print("The resultant tuples are:") print(result) The list is: [23, 42, 67, 89, 11, 32] The resultant tuples are: [(23, 529), ...
Read MorePython Program to Find the Second Largest Number in a List Using Bubble Sort
Finding the second largest number in a list can be accomplished using bubble sort to first arrange elements in ascending order, then accessing the second-to-last element. Bubble sort repeatedly compares adjacent elements and swaps them if they are in the wrong order. Understanding Bubble Sort Bubble sort works by comparing each pair of adjacent elements and swapping them if the first element is greater than the second. This process continues until no more swaps are needed. Bubble Sort Process Initial: ...
Read More