Articles on Trending Technologies

Technical articles with clear explanations and examples

Inplace vs Standard Operators in Python

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

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 More

Global and Local Variables in Python?

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

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

Time Functions in Python?

Chandu yadav
Chandu yadav
Updated on 25-Mar-2026 15K+ Views

Python provides a comprehensive library to read, represent and manipulate time information through the time module. Date, time and datetime are objects in Python, so whenever we perform operations on them, we work with objects rather than strings or timestamps. The time module follows the EPOCH convention, which refers to the starting point for time calculations. In Unix systems, EPOCH time started from January 1, 1970, 12:00 AM UTC. Understanding EPOCH Time To determine the EPOCH time value on your system ? import time print(time.gmtime(0)) time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, ...

Read More

Transpose a matrix in Python?

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

Transpose a matrix means we're turning its columns into its rows. Let's understand it by an example what it looks like after the transpose. Let's say you have original matrix something like − matrix = [[1, 2], [3, 4], [5, 6]] print(matrix) [[1, 2], [3, 4], [5, 6]] In above matrix we have two columns, containing 1, 3, 5 and 2, 4, 6. So when we transpose above matrix, the columns becomes the rows. So the transposed version would look something like − [[1, 3, 5], [2, 4, 6]] ...

Read More

ipaddress - IPv4/IPv6 manipulation library in Python

Vrundesha Joshi
Vrundesha Joshi
Updated on 25-Mar-2026 1K+ Views

Internet Protocol is currently in the process of moving from version 4 to version 6. This is necessitated because version 4 doesn't provide enough addresses to handle the increasing number of devices with direct connections to the internet. An IPv4 address is composed of 32 bits, represented into four eight-bit groups called "octets". This is a "dotted decimal" format where each eight-bit octet can have a decimal value 0 to 255. For example: 192.168.1.1 IPv4 address with CIDR notation: 192.168.1.1/24 where 24 means first three octets identify the network and last octet identifies node. An IPv6 ...

Read More

urllib.robotparser - Parser for robots.txt in Python

Nitya Raut
Nitya Raut
Updated on 25-Mar-2026 829 Views

Web site owners use the /robots.txt file to give instructions about their site to web robots; this is called The Robots Exclusion Protocol. This file is a simple text-based access control system for computer programs that automatically access web resources. Such programs are called spiders, crawlers, etc. The file specifies the user agent identifier followed by a list of URLs the agent may not access. Example robots.txt File #robots.txt Sitemap: https://example.com/sitemap.xml User-agent: * Disallow: /admin/ Disallow: /downloads/ Disallow: /media/ Disallow: /static/ This file is usually put in the top-level directory of your web server. ...

Read More

urllib.parse — Parse URLs into components in Python

Nitya Raut
Nitya Raut
Updated on 25-Mar-2026 9K+ Views

The urllib.parse module provides a standard interface to break Uniform Resource Locator (URL) strings into components or to combine the components back into a URL string. It also has functions to convert a "relative URL" to an absolute URL given a "base URL." This module supports the following URL schemes: file ftp gopher hdl http https imap mailto mms ...

Read More

html.parser — Simple HTML and XHTML parser in Python

Vrundesha Joshi
Vrundesha Joshi
Updated on 25-Mar-2026 2K+ Views

The html.parser module in Python's standard library provides the HTMLParser class for parsing HTML and XHTML documents. This class contains handler methods that can identify tags, data, comments, and other HTML elements. To use HTMLParser, create a subclass that inherits from HTMLParser and override specific handler methods to process different HTML elements. Basic HTMLParser Setup Here's the basic structure for creating a custom HTML parser ? from html.parser import HTMLParser class MyParser(HTMLParser): pass parser = MyParser() parser.feed('') Handling Start Tags The handle_starttag(tag, attrs) method is called ...

Read More

Bisect - Array bisection algorithm in Python

Vrundesha Joshi
Vrundesha Joshi
Updated on 25-Mar-2026 795 Views

The bisect module provides efficient algorithms for maintaining sorted lists. Instead of sorting after every insertion, it uses binary search to find the correct position quickly. This is much more efficient for frequent insertions into large sorted lists. bisect_left() Finds the insertion point for a value to maintain sorted order. If the value already exists, it returns the position before any existing entries ? import bisect nums = [10, 20, 30, 40, 50] position = bisect.bisect_left(nums, 25) print(f"Insert 25 at position: {position}") # Insert to verify nums.insert(position, 25) print(f"Updated list: {nums}") ...

Read More

Any & All in Python?

Jennifer Nicholas
Jennifer Nicholas
Updated on 25-Mar-2026 1K+ Views

Python provides two built-in functions any() and all() for evaluating boolean conditions across iterables. The any() function implements OR logic, while all() implements AND logic. Python any() Function The any() function returns True if at least one item in an iterable is true, otherwise it returns False. If the iterable is empty, it returns False. Syntax any(iterable) The iterable can be a list, tuple, set, or dictionary. Example with List items = [False, True, False] result = any(items) print(result) print("Result is True because at least one item is True") ...

Read More
Showing 7071–7080 of 61,303 articles
« Prev 1 706 707 708 709 710 6131 Next »
Advertisements