Programming Articles - Page 140 of 3366

How to Call a Parent class method in Python ?

Priya Sharma
Updated on 14-Aug-2023 13:05:46

15K+ Views

In object-oriented programming, inheritance allows you to create new classes based on existing ones, providing a way to reuse code and organize your program's structure. Python, being an object-oriented language, supports inheritance and allows you to override methods defined in parent classes in child classes. However, there may be situations where you want to leverage the functionality of a parent class method while extending or modifying it in the child class. Method Overriding in Python Before we learn about calling parent class methods, let's briefly discuss method overriding. Method overriding is a feature in object-oriented programming that allows a ... Read More

Get the List of all empty Directories in Python

Priya Sharma
Updated on 14-Aug-2023 13:01:49

1K+ Views

When working with file systems and directories in Python, it's often useful to be able to identify and handle empty directories. Empty directories can accumulate over time, taking up unnecessary space or cluttering the directory structure. Being able to programmatically find and handle these empty directories can help streamline file system operations and improve overall organization. In this tutorial, we will explore different methods to obtain a list of all empty directories using Python. We will cover two approaches: the first using the os.walk() function, and the second utilizing the os.scandir() function. Both methods are efficient and provide different benefits ... Read More

Functional Transforms for Computer Vision using PyTorch

Priya Sharma
Updated on 14-Aug-2023 15:51:07

269 Views

Computer vision tasks often require preprocessing and augmentation of image data to improve model performance and generalization. PyTorch, a popular deep learning framework, provides a powerful library for image transformations called torchvision.transforms. This library offers a wide range of predefined transforms for data augmentation and preprocessing. However, in some cases, predefined transforms may not be sufficient, and we need to apply custom transformations to our image data. In this blog post, we will explore the concept of functional transforms in PyTorch and demonstrate how to create and apply custom transforms for computer vision tasks. Understanding Transforms in PyTorch Transforms in ... Read More

Finding All substrings Frequency in String Using Python

Priya Sharma
Updated on 14-Aug-2023 12:54:48

489 Views

String manipulation and analysis are fundamental tasks in many programming scenarios. One intriguing problem within this domain is the task of finding the frequency of all substrings within a given string. This article aims to provide a comprehensive guide on efficiently accomplishing this task using the powerful Python programming language. When working with strings, it is often necessary to analyze their contents and extract valuable information. The frequency of substrings is an important metric that can reveal patterns, repetitions, or insights into the structure of the string. By determining how many times each substring appears in a given string, we ... Read More

Finding All possible space joins in a String Using Python

Priya Sharma
Updated on 14-Aug-2023 12:47:19

204 Views

In the world of natural language processing (NLP) and text manipulation, finding all possible space joins in a string can be a valuable task. Whether you're generating permutations, exploring word combinations, or analyzing text data, being able to efficiently discover all the potential ways to join words using spaces is essential. Through this process, we'll generate all possible combinations, enabling us to explore numerous word arrangements and gain valuable insights from our text data. Problem Statement Given a string of words, we want to generate all possible combinations by inserting spaces between the words. string = "hello world". To further ... Read More

Difference between Lock and Rlock objects

Priya Sharma
Updated on 14-Aug-2023 12:45:32

883 Views

Concurrent programming involves the execution of multiple threads or processes concurrently, which can lead to challenges such as race conditions and data inconsistencies. To address these issues, Python provides synchronization primitives, including the Lock and RLock objects. While both objects serve the purpose of controlling access to shared resources, they differ in behavior and usage. The Lock object is a fundamental mutual exclusion mechanism. It allows multiple threads to acquire and release the lock, but only one thread can hold the lock at any given time. When a thread attempts to acquire a lock that is already held by another ... Read More

Converting Speech to Text to Text to Speech in Python

Priya Sharma
Updated on 14-Aug-2023 12:43:32

3K+ Views

In today's digital age, the ability to seamlessly convert between speech and text has become increasingly important. From voice-controlled assistants to transcription services, this functionality is in high demand across a wide range of applications. Python, with its extensive library ecosystem, offers powerful tools and APIs that make it relatively straightforward to implement speech-to-text and text-to-speech conversions. In this blog post, we will explore how to leverage Python to convert speech to text and text to speech, empowering developers to create innovative applications that bridge the gap between spoken and written communication. Converting Speech to Text The first step ... Read More

AttributeError in Python

Priya Sharma
Updated on 14-Aug-2023 12:40:53

364 Views

Python is a versatile and powerful programming language that allows developers to build a wide range of applications. However, like any programming language, Python is not immune to errors. One common error that developers encounter is the AttributeError. Let’s explore what an AttributeError is, why it occurs, and how to handle it effectively. What is an AttributeError? An AttributeError is an exception that occurs when an object does not have a particular attribute or method that is being accessed. It is raised when an invalid attribute reference or assignment is made to an object. Reasons for AttributeError An AttributeError can ... Read More

Age Calculator using Python Tkinter

Tapas Kumar Ghosh
Updated on 11-Jul-2025 17:34:00

2K+ Views

An age calculator in Python using Tkinter is a GUI (Graphical User Interface) application that allows users to determine their age based on their date of birth (DOB). To design the user interface of this application, we use various methods provided by the Tkinter library such as Tk(), pack(), Entry(), Button(), and more. GUI of Age Calculator Let us build a GUI-based age calculator where the user can enter their age in the format of years, months, and days. Ensure that single-digit numbers are prefixed with a 0. Creating an Age Calculator Application using Python Tkinter To create an ... Read More

Adding Custom Values Key in a List of Dictionaries in Python

Disha Verma
Updated on 14-Aug-2023 12:34:14

292 Views

In this article, we will learn how to add a custom key with corresponding values to a list of dictionaries in Python. Dictionaries in Python are collections of unordered items stored in the form of key-value pairs inside curly braces like this − Dictionary = {key: value, ….} Suppose we have a list of dictionaries called dict_list and a key new_key, with its values provided in a separate list value_list. The goal is to add new_key to each dictionary in dict_list, assigning it the corresponding value from value_list. Let’s understand it with an example − #List of dictionary we ... Read More

Advertisements