Server Side Programming Articles

Page 601 of 2109

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 802 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

Optimization Tips for Python Code?

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

Python may not be as fast as compiled languages, but proper optimization techniques can significantly improve performance. Many large companies successfully use Python for heavy workloads by applying smart optimization strategies. Use Built-in Functions Built-in functions are written in C and are much faster than custom Python code. Always prefer built-ins when available ? # Fast - using built-in sum() numbers = [1, 2, 3, 4, 5] total = sum(numbers) print(total) # Slower - manual loop total = 0 for num in numbers: total += num print(total) 15 ...

Read More

Python Input Methods for Competitive Programming?

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

In competitive programming, efficient input/output methods can significantly improve your solution's performance. Python offers several approaches for reading input, each with different speed characteristics. Let's explore various I/O methods using a simple example: reading four numbers a, b, c, d and printing their product. Basic Input Methods Using List Comprehension This method uses list comprehension to convert input strings to integers − a, b, c, d = [int(x) for x in input().split()] print(a * b * c * d) Using map() Function The map() function provides a cleaner syntax for type ...

Read More

Timeit in Python with Examples?

Jennifer Nicholas
Jennifer Nicholas
Updated on 25-Mar-2026 520 Views

Python provides the timeit module for precise timing measurements of small code snippets. Unlike the basic time module, timeit accounts for background processes and provides more accurate performance measurements. What is Python timeit? The timeit module runs code approximately 1 million times (default value) and measures the minimum execution time. This approach eliminates timing variations caused by background processes and system overhead. Using timeit from Command Line You can use timeit directly from the command line interface. The module automatically decides the number of repetitions ? C:\Users\rajesh>python -m timeit "'-'.join(str(n) for n in range(200))" ...

Read More

File Objects in Python?

SaiKrishna Tavva
SaiKrishna Tavva
Updated on 25-Mar-2026 6K+ Views

In Python, file handling is a native feature that doesn't require importing any external libraries. The open() function opens a file and returns a file object, which contains methods and attributes for retrieving information or manipulating the opened file. File Operations Overview File operations in Python follow a standard sequence ? Opening a file Performing read or write operations Closing the file Opening a File The built−in open() function creates a file object. It takes two main arguments: the filename and ...

Read More

Detection of a specific color(blue here) using OpenCV with Python?

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

Image processing and color detection might seem complex at first, but OpenCV makes it straightforward. In this tutorial, we'll learn how to detect specific colors (blue in this case) using Python and OpenCV. Understanding Color Models Computers represent colors using color models that describe colors as tuples of numbers. The two most common models are RGB (Red, Green, Blue) and HSV (Hue, Saturation, Value). RGB Color Model RGB represents colors as three components, each ranging from 0 to 255. The tuple (0, 0, 0) represents black, while (255, 255, 255) represents white. For pure blue, the ...

Read More

Linear Regression using Python?

Jennifer Nicholas
Jennifer Nicholas
Updated on 25-Mar-2026 914 Views

Linear regression is one of the simplest standard tools in machine learning to indicate if there is a positive or negative relationship between two variables. It's also one of the few good tools for quick predictive analysis. In this tutorial, we'll use Python pandas package to load data and then estimate, interpret and visualize linear regression models. What is Regression? Regression is a form of predictive modelling technique which helps in creating a relationship between a dependent and independent variable. Types of Regression Linear Regression Logistic Regression Polynomial Regression Stepwise Regression Where is ...

Read More
Showing 6001–6010 of 21,090 articles
« Prev 1 599 600 601 602 603 2109 Next »
Advertisements