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
Python Get a list as input from user
In this article, we will see how to ask the user to enter elements of a list and create the list with those entered values. Python provides several approaches to collect user input and build lists dynamically. Using Loop with input() and append() The most straightforward approach is to ask for the number of elements first, then collect each element individually using a loop ? numbers = [] # Input number of elements n = int(input("Enter number of elements in the list : ")) # iterating till the range for i in range(0, n): ...
Read MorePython Generate successive element difference list
Finding the difference between successive elements in a list is a common operation in Python. This article explores three efficient methods to calculate consecutive element differences using list comprehension, list slicing, and the operator module. Using List Comprehension with Index The most straightforward approach uses list comprehension with index positions to access consecutive elements ? numbers = [12, 14, 78, 24, 24] # Given list print("Given list:", numbers) # Using index positions with list comprehension differences = [numbers[i + 1] - numbers[i] for i in range(len(numbers) - 1)] # Print result print("Successive differences:", ...
Read MoreHow to disable form fields using CSS or JavaScript?
Form fields can be disabled using CSS or JavaScript to prevent user interaction when certain conditions are met. This is useful for creating read-only forms, conditional inputs, or preventing submission before validation. Syntax /* CSS approach */ selector { pointer-events: none; opacity: value; } /* HTML disabled attribute */ Method 1: Disable Form Fields with CSS To disable form fields with CSS, we use the pointer-events property to prevent mouse interactions and opacity to provide visual feedback. The pointer-events: none disables all mouse events, ...
Read MorePython Generate random string of given length
In this article we will see how to generate a random string with a given length. This will be useful in creating random passwords or other programs where randomness is required. Using random.choices() The choices() function in the random module can produce multiple random characters which can then be joined to create a string of given length ? Example import string import random # Length of string needed N = 5 # With random.choices() res = ''.join(random.choices(string.ascii_letters + string.digits, k=N)) # Result print("Random string :", res) The output of the ...
Read MorePython Generate random numbers within a given range and store in a list
In this article we will see how to generate random numbers between a pair of numbers and store those values in a list. Python's random module provides the randint() function for this purpose. Syntax random.randint(start, end) Parameters: start − Lower bound (inclusive) end − Upper bound (inclusive) Both start and end should be integers Start should be less than or equal to end Using a Function with Loop In this example we use the range() function in a for loop. With help of append() we generate and add these random numbers ...
Read MoreHow to add a Login Form to an Image using HTML and CSS?
A login form on an image creates an attractive, modern website design commonly used by restaurants, event organizers, and businesses. This approach overlays a functional login form on a background image, making the website more visually appealing than standard forms. Syntax .container { background-image: url('image-path'); background-size: cover; position: relative; } form { position: absolute; /* positioning and styling properties */ } Approach To create a login form on an image, follow these steps ...
Read MorePython Categorize the given list by string size
Let's consider a list containing many strings of different lengths. In this article we will see how to group those elements into categories where the strings are of equal length in each group. Using For Loop We design a for loop which will iterate through every element of the list and append it only to the group where its length matches with the length of existing elements ? Example days = ['Monday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] # Given list print("Given list:") print(days) # Categorize by string size len_comp = lambda x, y: len(x) ...
Read MoreCreating a Navigation Bar with three Different Alignments using CSS
In HTML, a navigation bar is a group of buttons and images arranged either in a row or a column and used as a control site for linking particular webpages. It is regarded as one of the fundamental tools used in web design. Without affecting the content of the pages, the HTML navigation bar separates structure from content and adds creativity to the layout of the website. Using HTML, we create a navigation bar, and CSS gives it a beautiful appearance. Additional functionality may be added using JavaScript. In HTML, a navigation bar can be implemented in a variety ...
Read MoreConverting an image to ASCII image in Python
Converting an image to ASCII art involves transforming pixel brightness values into corresponding ASCII characters. This creates a text-based representation of the original image using characters like #, @, *, and . to represent different shades. Required Library We'll use the Pillow library for image processing − pip install Pillow ASCII Character Set First, define the ASCII characters arranged from darkest to lightest − ASCII_CHARS = ['#', '?', '%', '.', 'S', '+', '.', '*', ':', ', ', '@'] print("ASCII characters from dark to light:", ASCII_CHARS) ASCII characters from ...
Read MoreCreate a Circular Progress Bar using HTML and CSS
A progress bar displays the status of a procedure within an application. A progress bar shows how much of the process has already been completed and how much is still left to do. The various components of the progress bar will be designed using HTML, and the progress bar itself may be modified using CSS properties. Progress bars are frequently used on websites to highlight particular data in a more appealing way for users. One advantage of employing a circle progress bar over a standard (horizontal) progress bar is that you can accommodate more progress bars in one row, ...
Read More