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
Articles on Trending Technologies
Technical articles with clear explanations and examples
Whatsapp using Python?
WhatsApp automation using Python allows developers to send messages programmatically. Since WhatsApp doesn't provide official API access for personal accounts, we use Selenium to automate WhatsApp Web through a browser interface. Requirements To create a WhatsApp automation script, you need three essential components ? Install Selenium Install Selenium using pip ? pip install selenium Chrome WebDriver Download the Chrome WebDriver compatible with your Chrome browser version from the official ChromeDriver website. Extract it to a known location on your system. WhatsApp Account Ensure you have an active WhatsApp account ...
Read MoreChanging Class Members in Python?
Python object-oriented programming allows variables to be used at the class level or the instance level. Class variables are shared among all instances of a class, while instance variables are unique to each object. Understanding the difference between class and instance variables is crucial when modifying class members. Let's explore how to properly change class variables through examples. Class vs Instance Variables Here's a basic example demonstrating class and instance variables ? # Class Shark class Shark: animal_type = 'fish' # Class Variable ...
Read MoreCount Negative Numbers in a Column-Wise and Row-Wise Sorted Matrix using Python?
In this example, we will count negative numbers in a column-wise and row-wise sorted matrix. A sorted matrix has elements arranged in ascending order both horizontally (across rows) and vertically (down columns). Understanding the Problem For a sorted matrix, once we encounter a positive number in a row, all subsequent elements in that row will also be positive. This property allows us to optimize our counting approach. Creating the Matrix Let's start by creating a sample sorted matrix ? matrix = [ [-7, -3, 2, 3], ...
Read MoreClass or Static Variables in Python?
In this article we are going to learn about class or static variables in Python. The class variables or static variables are used to share data across all the instances of a class. Unlike instance variables which are specific to each object, class variables maintain a common value for all objects of the class. They are defined within the class but outside any instance methods, making them accessible to all instances. These variables are used when we want to have a single shared state or value among all instances. Syntax class ClassName: ...
Read MoreHow to input multiple values from user in one line in Python?
In Python, to get multiple values from users in a single line, there are several approaches. The most common methods use split() with map() or list comprehension to parse space-separated input. Using Multiple input() Calls The basic approach uses separate input() calls for each value − x, y, z = input(), input(), input() print(x) print(y) print(z) If the user enters 5, 10, 15 in separate prompts, the output will be − 5 10 15 This method requires multiple user inputs, which is not ideal for single-line input. Using map() ...
Read MoreMathematical Functions in Python?
Python's math module provides essential mathematical functions for performing operations ranging from basic arithmetic to complex trigonometric and logarithmic calculations. All math functions work with integers and real numbers, but not with complex numbers. To use mathematical functions, you need to import the math module ? import math Mathematical Constants The math module provides several important mathematical constants ? Constant Description math.pi Returns the value of π: 3.141592 math.e Returns the value of natural base e: 2.718282 math.tau Returns the value of ...
Read MoreHow to write an empty function in Python?
In this article, we will see how we can create empty functions in Python. A function is a block of organized, reusable code that is used to perform a single, related action. Functions provide better modularity for your application and a high degree of code reusing. Function blocks begin with the keyword def followed by the function name and parentheses (). Here, we will see examples of empty functions using the pass statement. What is the pass Statement? The pass statement is a null operation in Python. It does nothing when executed and serves as a placeholder ...
Read MoreReloading modules in Python?
The reload() function is used to reload a previously imported module. This is particularly useful during interactive development sessions where you modify a module's code and want to see changes without restarting the Python interpreter. When you modify a module file after importing it, Python continues to use the cached version. The reload() function forces Python to re-read and re-execute the module code. How reload() Works When reload() is executed, several important things happen: The module's code is recompiled and re-executed, creating new objects bound to names in the module's dictionary Old objects are only ...
Read MoreInplace vs Standard Operators in Python
Python provides two types of operators: inplace operators that modify variables directly, and standard operators that create new values. Understanding the difference helps you write more efficient code. Inplace Operators Inplace operators modify the original variable without creating a copy. They use compound assignment syntax like +=, -=, etc. Basic Example a = 9 a += 2 print(a) 11 The += operator adds 2 to the original value of a and updates it in place. Common Inplace Operators += (addition) -= (subtraction) *= (multiplication) /= (division) %= ...
Read MoreGlobal and Local Variables in Python?
In Python, variables have different scopes that determine where they can be accessed. There are two main types: global variables (accessible throughout the entire program) and local variables (accessible only within the function where they are defined). Local Variables Local variables are created inside a function and can only be accessed within that function. They exist only during the function's execution ? def my_function(): x = "Python" # Local variable print("Inside function:", x) my_function() # print(x) # This would cause NameError Inside ...
Read More