Find Area and Perimeter of Rectangle in JavaScript

Disha Verma
Updated on 18-Mar-2025 12:59:21

9K+ Views

To find the area and perimeter of a rectangle in JavaScript, we will be using the basic formulas for the perimeter and area of a rectangle. The area of a rectangle is the multiplication of its length by its breadth, and the perimeter of a rectangle is the sum of the lengths of all its four sides. In this article, we are going to understand the formula for the area and perimeter of a rectangle, how to find them using JavaScript, and implement practical examples for this. Understanding the Formulas The formulas for the area and perimeter of a ... Read More

Create a Program Without a Main Method in Java

Alshifa Hasnain
Updated on 18-Mar-2025 11:15:51

2K+ Views

Java is a statically typed, object-oriented programming language that needs a main method as an entry point for running. But it is possible to develop Java programs without a main method under certain conditions. Different Approaches The following are the different approaches for creating a program without a main method in Java − Using Static Blocks Using a Servlet Using a JavaFX Application Using Static Blocks (Before Java 7) In previous implementations of Java (prior to Java 7), a program was possible to run with a ... Read More

Difference Between JavaScript and ECMAScript

Alshifa Hasnain
Updated on 18-Mar-2025 11:15:26

5K+ Views

In this article, we will learn the difference between JavaScript and ECMAScript. JavaScript and ECMAScript are used somewhat interchangeably, but not quite. JavaScript is a general programming language in general use, and ECMAScript is its standard foundation. What is JavaScript? JavaScript was originally called LiveScript, but Netscape renamed it to JavaScript, perhaps due to the hype surrounding Java. JavaScript first appeared in Netscape 2.0 in 1995 under the name LiveScript. The language's general-purpose core has been integrated into Netscape, Internet Explorer, and other web browsers.The norm of scripting languages such as JavaScript is ECMAScript. The following are the features of ... Read More

Create an Array of Integers in JavaScript

Alshifa Hasnain
Updated on 18-Mar-2025 11:14:51

18K+ Views

In this article, we will learn to create an array of integers in JavaScript. The Array parameter is a list of strings or integers. When you specify a single numeric parameter with the Array constructor, you specify the initial length of the array. The maximum length allowed for an array is 4, 294, 967, 295. Different Approaches The following are the two different approaches to creating an array of integers in JavaScript − Using Array Literals Using the Array Constructor Using Array Literals One of the simplest ways to create ... Read More

C++ Program to Count the Sum of Numbers in a String

AYUSH MISHRA
Updated on 18-Mar-2025 08:20:46

9 Views

In this problem, we are given a string containing alphanumeric characters, and the task is to extract all the numbers from the string and compute their sum. The numbers may appear anywhere within the string, and we need to identify them and add them together. In this article, we are going to explore different approaches to solving this problem in C++.Example 1Input: str = "anshu123ayush45anshu"Output: Sum = 174Explanation:The numbers extracted from the string are 123, 45, and 6. Their sum is 123 + 45 + 6 = 174.Example 2Input: str = "1abc2def34ghi56jkl"Output: Sum = 93Explanation:The numbers extracted from the string ... Read More

What is a Namespace in Python

SaiKrishna Tavva
Updated on 17-Mar-2025 18:12:02

3K+ Views

A Namespace in Python is a container that holds a set of identifiers (variable names) and their associated objects (values). It helps implement the concept of scope in your program, determining which variables are accessible at any given point in your code. Every time a new scope is created—like when a function is defined or executed—a new namespace is created. This namespace acts as an "evaluation context" for the identifiers defined within it. Types of Namespaces Following are the three types of namespaces in Python. Local Namespace: Created for each function, method, or class block. ... Read More

Destructor Method __del__ in Python

SaiKrishna Tavva
Updated on 17-Mar-2025 16:59:25

719 Views

Python programmers often need to delete directories for tasks like cleaning up temporary files. Deleting directories isn't as simple as deleting files and requires careful handling. This article explores effective methods for deleting Python directories. We'll provide step-by-step explanations and code examples, covering error handling, read-only files, and recursive removal of subdirectories. Using shutil.rmtree() for Recursive Deletion The shutil module provides the rmtree() function, which recursively deletes a directory and all its contents. This is the simplest method for deleting a directory and all its contents. Example The following code defines a function called delete_directory_with_shutil. This function takes the path ... Read More

Add Files to a ZIP File Using Python

SaiKrishna Tavva
Updated on 17-Mar-2025 16:58:53

3K+ Views

Managing files and archives is an essential skill. One common archive format is the ZIP file, which simplifies data compression and storage. Python, known for its versatility and power, provides the zip file module, making it easy for developers to interact with ZIP files efficiently. Key Features of the zipfile Module Some key features of the zipfile module are as follows- Creating ZIP files: You can create new ZIP archives. Modifying existing ZIP files: You can add files to existing archives. Reading ZIP files: You can extract ... Read More

Select First Row of Each Group By in SQL

Deepanshi Singh
Updated on 17-Mar-2025 16:57:30

255 Views

When working with large datasets in SQL, you may often need to retrieve only the first row of each group based on a specific column. For example, you might want to fetch the earliest order for each customer, the highest-paid employee in each department, or the latest transaction per user. Selecting the First Row of Each Group In data analysis and database management, grouping data and extracting specific rows—such as the first or earliest record in each group—is a common and essential task. This technique is beneficial for scenarios like: Finding the first transaction ... Read More

Selecting Multiple Columns Based on Condition in SQL

Priyanka Gupta
Updated on 17-Mar-2025 16:56:58

209 Views

Selecting Multiple Columns Based On Condition Structured Query Language is used to manage and query databases. One common use case of databases is to select single columns or multiple columns of a table based on specific conditions. The SQL SELECT statement is used to retrieve data from a database. These conditions help filter the data to match your query. These conditions are : AND and OR IN BETWEEN Syntax Following is the syntax for selecting multiple columns is − SELECT col 1 , col ... Read More

Advertisements