Articles on Trending Technologies

Technical articles with clear explanations and examples

Returning Multiple Values in Python?

Arjun Thakur
Arjun Thakur
Updated on 25-Mar-2026 7K+ Views

Python functions can return multiple values, which is a powerful feature not available in many programming languages like C++ or Java. When a function returns multiple values, they can be stored in variables directly or accessed using different data structures. There are several approaches to return multiple values from a function: tuples, lists, dictionaries, classes, and generators. Each method has its own advantages depending on your specific use case. Using Tuples The simplest way to return multiple values is using a tuple. Python automatically packs multiple return values into a tuple ? def calculate_values(x): ...

Read More

What is the maximum possible value of an integer in Python?

Ankith Reddy
Ankith Reddy
Updated on 25-Mar-2026 3K+ Views

Python has different integer limits depending on the version. In Python 2, integers had a maximum value before switching to long type, but Python 3 has unlimited precision integers bounded only by available memory. Python 2 Integer Behavior In Python 2, integers automatically switched to long type when they exceeded their limit ? import sys print(type(sys.maxint)) print(type(sys.maxint + 1)) Python 2 Maximum and Minimum Values import sys print(sys.maxint) # Max Integer value print(-sys.maxint - 1) # Min Integer value 2147483647 -2147483648 ...

Read More

Whatsapp using Python?

Chandu yadav
Chandu yadav
Updated on 25-Mar-2026 817 Views

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 More

Changing Class Members in Python?

Chandu yadav
Chandu yadav
Updated on 25-Mar-2026 663 Views

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 More

Count Negative Numbers in a Column-Wise and Row-Wise Sorted Matrix using Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 618 Views

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 More

Class or Static Variables in Python?

Yaswanth Varma
Yaswanth Varma
Updated on 25-Mar-2026 7K+ Views

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 More

How to input multiple values from user in one line in Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 6K+ Views

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 More

Mathematical Functions in Python?

George John
George John
Updated on 25-Mar-2026 3K+ Views

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 More

How to write an empty function in Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 3K+ Views

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 More

Reloading modules in Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 20K+ Views

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 More
Showing 7061–7070 of 61,303 articles
« Prev 1 705 706 707 708 709 6131 Next »
Advertisements