Server Side Programming Articles

Page 570 of 2109

Passing Information using GET method in Python

Mohd Mohtashim
Mohd Mohtashim
Updated on 25-Mar-2026 2K+ Views

The GET method sends encoded user information appended to the page request. The page and the encoded information are separated by the ? character as follows − http://www.test.com/cgi-bin/hello.py?key1=value1&key2=value2 The GET method is the default method to pass information from browser to web server and it produces a long string that appears in your browser's Location box. Never use GET method if you have password or other sensitive information to pass to the server. The GET method has size limitation: only 1024 characters can be sent in a request string. The GET method sends information using ...

Read More

CGI Environment Variables in Python

Mohd Mohtashim
Mohd Mohtashim
Updated on 25-Mar-2026 2K+ Views

All CGI programs have access to environment variables that contain important information about the request, server, and client. These variables play an important role while writing any CGI program. Common CGI Environment Variables Variable Name Description CONTENT_TYPE The data type of the content. Used when the client is sending attached content to the server (e.g., file upload). CONTENT_LENGTH The length of the query information. Available only for POST requests. HTTP_COOKIE Returns the set cookies in the form of key-value pairs. HTTP_USER_AGENT Contains information about the ...

Read More

Special Syntax with Parentheses in Python

Mohd Mohtashim
Mohd Mohtashim
Updated on 25-Mar-2026 219 Views

Python regular expressions support special syntax using parentheses for advanced pattern matching. These parentheses provide functionality like comments, case-insensitive matching, and non-capturing groups. Comment Syntax Use (?#comment) to add comments within regex patterns without affecting the match ? import re pattern = r'R(?#This is a comment)uby' text = "Ruby programming" match = re.search(pattern, text) if match: print(f"Found: {match.group()}") else: print("No match found") Found: Ruby Case-Insensitive Flag Use (?i) to enable case-insensitive matching for the rest of the pattern ? ...

Read More

Regular Expression Examples in Python

Mohd Mohtashim
Mohd Mohtashim
Updated on 25-Mar-2026 393 Views

Regular expressions (regex) are powerful tools for pattern matching and text processing in Python. The re module provides functions to work with regular expressions, allowing you to search, match, and manipulate text based on specific patterns. Literal Characters Literal characters in regex match themselves exactly. Here's how to use basic literal matching ? import re text = "python is awesome" pattern = "python" match = re.search(pattern, text) if match: print(f"Found: '{match.group()}'") else: print("Not found") Found: 'python' Character Classes Character classes ...

Read More

Largest Number in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 637 Views

Finding the largest number from a list of non-negative integers requires arranging them in a specific order. For example, given [10, 2], the largest number would be 210, not 102. The key insight is to sort numbers based on which arrangement produces a larger concatenated result. We compare two numbers by checking if x + y is greater than y + x as strings. Algorithm Steps Convert all numbers to strings Sort using a custom comparator that checks concatenated results Join the sorted strings and handle edge cases Implementation Let us see the ...

Read More

Binary Tree Inorder Traversal in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 3K+ Views

Binary tree inorder traversal visits nodes in the order: left subtree, root, right subtree. This article demonstrates how to perform inorder traversal iteratively using a stack instead of recursion. 10 5 15 2 7 20 ...

Read More

Decode Ways in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 1K+ Views

Suppose we have a message containing letters from A to Z that is being encoded to numbers using the following mapping − 'A' → 1, 'B' → 2 ... 'Z' → 26. Given a non-empty string containing only digits, we need to find in how many ways that string can be decoded. For example, if the string is "12", it can be decoded as "AB" (1, 2) or "L" (12), so there are two possible ways. Algorithm Approach We will solve this using dynamic programming with the following steps ? Create a DP array where ...

Read More

Combinations in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 1K+ Views

Generating all possible combinations of k numbers from a range 1 to n is a classic problem that can be solved efficiently using backtracking. For example, if n = 4 and k = 2, the combinations would be [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]. In Python, we can implement this using recursion with backtracking to explore all possible combinations systematically. Using Recursive Backtracking The backtracking approach builds combinations incrementally and backtracks when a complete combination is found ? def combine(n, k): result = [] ...

Read More

Sort Colors in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 3K+ Views

The Sort Colors problem involves sorting an array containing only three values: 0 (red), 1 (white), and 2 (blue). We need to sort them in-place so objects of the same color are adjacent, in the order red, white, blue. For example, if the input array is [2,0,2,1,1,0], the sorted output should be [0,0,1,1,2,2]. Algorithm: Dutch National Flag This problem is efficiently solved using the Dutch National Flag algorithm with three pointers ? Set low = 0, mid = 0, and high = length of array − 1 While mid

Read More

Pow(x, n) in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 2K+ Views

Calculating x to the power n efficiently without using built-in functions like pow() or ** is a common programming problem. We can implement this using binary exponentiation, which reduces time complexity from O(n) to O(log n). Problem Statement Given two inputs x and n, where x is a number in range -100.0 to 100.0 and n is a 32-bit signed integer, we need to calculate xn efficiently. Example If x = 12.1 and n = -2, then xn = 12.1-2 = 1/(12.1)2 = 0.00683 Algorithm We use binary exponentiation which works by breaking down ...

Read More
Showing 5691–5700 of 21,090 articles
« Prev 1 568 569 570 571 572 2109 Next »
Advertisements