Nikitha N

Nikitha N

54 Articles Published

Articles by Nikitha N

54 articles

How to compare string and number in Python?

Nikitha N
Nikitha N
Updated on 24-Mar-2026 3K+ Views

In Python, you cannot directly compare strings and numbers using comparison operators like , or == because they are different data types. However, there are several approaches to handle string-number comparisons depending on your needs. Direct Comparison Behavior Attempting to compare a string and number directly will raise a TypeError in Python 3 − # This will raise a TypeError try: result = "12" < 100 print(result) except TypeError as e: print(f"Error: {e}") Error: '

Read More

Execute a script when a mouse wheel is being scrolled over an element in HTML?

Nikitha N
Nikitha N
Updated on 16-Mar-2026 395 Views

When a mouse wheel is being scrolled over an element, the onwheel attribute triggers a JavaScript function. This event is useful for creating interactive elements that respond to scroll gestures, such as image galleries, zoom controls, or custom scroll behaviors. Syntax Following is the syntax for the onwheel attribute − Content The onwheel attribute can be used with any HTML element. The event object contains information about the scroll direction and delta values. Basic Mouse Wheel Event Example Following example shows how to execute a script when a mouse wheel is ...

Read More

Execute a script when the length of the media changes in HTML?

Nikitha N
Nikitha N
Updated on 16-Mar-2026 288 Views

The ondurationchange attribute in HTML triggers when the duration of an audio or video element changes. This event occurs when the browser has loaded enough of the media file to determine its total length, or when the duration metadata becomes available. Syntax Following is the syntax for the ondurationchange attribute − The attribute can also be added using JavaScript − audioElement.ondurationchange = function() { /* code */ }; videoElement.addEventListener("durationchange", myFunction); When Duration Changes Occur The ondurationchange event is fired in the following scenarios − When ...

Read More

Set the text wrap in a form in HTML

Nikitha N
Nikitha N
Updated on 16-Mar-2026 857 Views

The wrap attribute in HTML controls how text wrapping behaves in a element. This attribute determines whether line breaks are inserted when the text reaches the edge of the textarea and how those line breaks are handled when the form is submitted to the server. Syntax Following is the syntax for the wrap attribute − Text content The value can be soft, hard, or off. Wrap Attribute Values The wrap attribute accepts three possible values − soft − Text wraps visually in the textarea, but line breaks are not ...

Read More

How to specify that the target will be downloaded when a user clicks on the hyperlink in HTML?

Nikitha N
Nikitha N
Updated on 16-Mar-2026 213 Views

The download attribute in HTML specifies that the target will be downloaded when a user clicks on the hyperlink, rather than navigating to the linked resource. This attribute transforms any link into a download trigger, allowing users to save files directly to their device. Syntax Following is the syntax for the download attribute − Link Text You can also specify a filename for the downloaded file − Link Text Parameters The download attribute accepts the following values − Empty value − download without a value uses the ...

Read More

How do we define the start of a term in a definition list in HTML?

Nikitha N
Nikitha N
Updated on 16-Mar-2026 306 Views

The HTML tag is used to define the start of a term in a definition list. A definition list is similar to other lists but in a definition list, each list item contains two entries: a term and a description. The tag defines the term, while the tag provides its corresponding definition or description. Syntax Following is the syntax for the tag − Term Description of the term The element must be used within a (definition list) container and is ...

Read More

Which is the best tutorial site to learn HTML?

Nikitha N
Nikitha N
Updated on 16-Mar-2026 232 Views

HTML stands for Hyper Text Markup Language, which is the most widely used language on the web to develop web pages. HTML was created by Tim Berners-Lee in late 1991, and "HTML 2.0" was the first standard HTML specification published in 1995. HTML 4.01 was a major version published in late 1999. The current version is HTML5, which is an extension of HTML 4.01 and was officially published in 2012. What Does HTML Look Like? HTML uses a system of tags to structure content on a web page. Here is a basic example of an HTML page − ...

Read More

How to set the decoration of a text with JavaScript?

Nikitha N
Nikitha N
Updated on 15-Mar-2026 1K+ Views

Use the textDecoration property in JavaScript to decorate text. This property allows you to add underlines, overlines, strikethrough effects, and more to any text element. Syntax element.style.textDecoration = "value"; Common textDecoration Values Value Effect underline Adds line below text overline Adds line above text line-through Strikes through text none Removes decoration Example: Basic Text Decoration Text Decoration Example This is demo text. ...

Read More

Is it correct to use JavaScript Array.sort() method for shuffling?

Nikitha N
Nikitha N
Updated on 15-Mar-2026 137 Views

No, it is not correct to use JavaScript's Array.sort() method for shuffling arrays. While it may appear to work, it produces biased results and is not a proper shuffling algorithm. Why Array.sort() Fails for Shuffling Using Array.sort(() => Math.random() - 0.5) seems like a clever shortcut, but it doesn't produce truly random shuffles. The sort algorithm expects consistent comparison results, but random comparisons violate this assumption. // WRONG: Biased shuffling with sort() let arr = [1, 2, 3, 4, 5]; let biasedShuffle = arr.sort(() => Math.random() - 0.5); console.log("Biased result:", biasedShuffle); Biased result: ...

Read More

How to create a two dimensional array in JavaScript?

Nikitha N
Nikitha N
Updated on 15-Mar-2026 803 Views

A two-dimensional array has more than one dimension, such as myarray[0][0] for element one, myarray[0][1] for element two, etc. JavaScript doesn't have true 2D arrays, but you can create arrays of arrays to achieve the same functionality. Method 1: Using Array Constructor with Loop This method creates an empty 2D array and fills it row by row: var myarray = new Array(3); for (i = 0; ...

Read More
Showing 1–10 of 54 articles
« Prev 1 2 3 4 5 6 Next »
Advertisements