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 by mkotla
77 articles
What is the basic syntax to access Python Dictionary Elements?
You can access dictionary values in Python using two main approaches: the square bracket notation [] and the get() method. Both methods allow you to retrieve values using their corresponding keys. Using Square Bracket Notation The most common way to access dictionary values is using square brackets with the key ? my_dict = { 'foo': 42, 'bar': 12.5 } new_var = my_dict['foo'] print(new_var) 42 KeyError Example If you try to access a key that doesn't exist, Python raises a KeyError ? ...
Read MoreC# Equivalent to Java Functional Interfaces
The C# equivalent to Java's functional interfaces is delegates. Delegates in C# provide the same functionality as functional interfaces in Java, allowing you to treat methods as first-class objects and use lambda expressions for concise code. Java functional interfaces define a contract with a single abstract method, while C# delegates directly represent method signatures that can be assigned lambda expressions or method references. Syntax Following is the syntax for declaring a delegate in C# − public delegate ReturnType DelegateName(ParameterType parameter); Following is the syntax for assigning a lambda expression to a delegate − ...
Read MoreSet the shape of the area in HTML
The shape attribute in HTML defines the clickable area's geometry within an image map. It works with the element to create interactive regions on images that users can click to navigate to different links. Syntax Following is the syntax for the shape attribute − The shape attribute accepts four possible values: rect, circle, poly, and default. Each shape type requires specific coordinate formats. Shape Values and Coordinates The following table shows the valid shape values and their coordinate requirements − Shape Value Coordinates Format Description ...
Read MoreExecute a script after the document is printed in HTML?
The onafterprint event attribute in HTML executes a JavaScript function after the user has printed the document or closed the print preview dialog. This event is useful for tracking print actions, cleaning up resources, or providing user feedback after printing. Syntax Following is the syntax for the onafterprint attribute − You can also use it with JavaScript event listeners − window.addEventListener("afterprint", functionName); Using onafterprint Attribute The onafterprint attribute is typically added to the element and triggers when the print dialog is closed, regardless of whether the user ...
Read MoreHTML5 check if audio is playing
In HTML5, you can check if an audio element is currently playing by using the paused property. This property returns a boolean value indicating whether the audio is paused or playing. Syntax Following is the basic syntax to check if audio is playing − audioElement.paused The paused property returns false when the audio is playing and true when it is paused or stopped. Using a Function to Check Audio Status Following function checks if an audio element is currently playing − function isPlaying(audelem) { return !audelem.paused; ...
Read MoreConvert HTML5 into standalone Android App
Converting an HTML5 application into a standalone Android app allows you to distribute your web-based content through the Google Play Store. This process involves creating a WebView-based Android application that loads and displays your HTML5 content locally. A WebView acts as a browser component within your Android app, providing the ability to display web content without requiring an internet connection when files are stored locally. Prerequisites Before starting the conversion process, ensure you have the following − Android Studio − The official IDE for Android development HTML5 files − Your complete web application including HTML, ...
Read MoreHow to specify that the element should automatically get focus when the page loads in HTML?
The autofocus attribute in HTML is used to specify that an element should automatically receive focus when the page loads. This eliminates the need for users to manually click on the element before interacting with it, improving user experience and accessibility. Syntax Following is the syntax for using the autofocus attribute − Click Me The autofocus attribute is a boolean attribute, meaning it doesn't require a value. Its mere presence on an element indicates that the element should receive focus automatically. Supported Elements The autofocus attribute can be used with ...
Read MoreExecute a script when the element gets user input in HTML?
The oninput event attribute is used to execute a script when an element receives user input. This event fires immediately when the user types, deletes, or modifies content in form elements like text inputs, textareas, and content-editable elements. Syntax Following is the syntax for the oninput event attribute − Where script is the JavaScript code to execute when the input event occurs. How It Works The oninput event triggers whenever the value of an input element changes. Unlike onchange, which fires only when the element loses focus, oninput fires in real-time ...
Read MoreHow to get a decimal portion of a number with JavaScript?
In JavaScript, you can extract the decimal portion of a number using several methods. The most common approach is using the modulo operator (%) with 1. Using the Modulo Operator (%) The % operator returns the remainder after division. When used with 1, it gives the decimal part: var num1 = 5.3; var num2 = 4.2; var num3 = 8.6; document.write(num1 ...
Read MoreHow to test if a JavaScript cookie has expired?
To test if a JavaScript cookie has expired, you need to check if the cookie exists or returns null. When a cookie expires, the browser automatically removes it, so attempting to access it will return null or undefined. Using document.cookie (Vanilla JavaScript) The most straightforward approach is to create a helper function that checks if a cookie exists: function getCookie(name) { const cookies = document.cookie.split(';'); for (let cookie of cookies) { const [cookieName, cookieValue] = cookie.trim().split('='); ...
Read More