Java Program to Display Factors of a Number

Manisha Chand
Updated on 09-Jun-2025 12:39:33

7K+ Views

In this article, we will understand how to display the factors of a number. Factors are numbers that divide the original number without leaving a remainder. For example, 1, 2, 3, 4, 6, and 12 are factors of 12. If a and b are factors of a number, then a x b is also a factor of the number. If we multiply 3 and 5, we get 15. We say that 3 and 5 are factors of 15. The largest factor of any number is the number itself, and the smallest factor is 1. 1 ... Read More

C++ Program to Check Whether a Number can be Expressed as Sum of Two Prime Numbers

Tapas Kumar Ghosh
Updated on 09-Jun-2025 11:28:29

1K+ Views

You are given a number and you need to write a C++ program to check whether a number can be expressed as sum of two prime numbers. Input / Output Scenarios Following is the input-output statement: Input: n = 19 Output: 19 can be expressed as the sum of two prime numbers. Explanation: 19 = 17 + 2, and both 17 and 2 are prime numbers. Input: n = 36 Output: 36 can be expressed as the sum of two prime numbers. Explanation: 36 = 31 + 5, and both 31 and 5 are prime numbers. C++ Program ... Read More

C++ program to Zoom digits of an integer

Tapas Kumar Ghosh
Updated on 09-Jun-2025 11:25:27

245 Views

Zooming digits means printing the digits of a given number in an enlarged form using special characters. In this article, we will learn to print (display) enlarged (zoomed) form of the digits of a given number. Below is the representation of digits 01438 in zoom format, Example of Zoom Digits in Integers Form To generate the zoomed digit, we define the pattern logic for each digit based on its respective function prototype. Then, we create a function that sets the switch-case logic which processes the selected digit based on either user input or a given number. In this example, ... Read More

What are different data conversion methods in Python?

Sarika Singh
Updated on 09-Jun-2025 10:17:08

891 Views

Data conversion in Python refers to changing the data type of a value to another data type. Python supports two different types of data conversion, such as Implicit conversion and explicit conversion. Implicit Conversion is performed by the Python interpreter automatically. Explicit Conversion is manually done by the programmer using built-in functions in Python Implicit Conversion Python automatically converts one data type to another, and this type of conversion is called Implicit conversion. To avoid any data loss during runtime, the smaller data type is converted ... Read More

How to match a non-whitespace character in Python using Regular Expression?

Niharikaa Aitam
Updated on 09-Jun-2025 09:55:51

4K+ Views

A non-whitespace character is any character that is not a space, tab i.e., \t, newline i.e., or carriage return \r. Examples of non-whitespace characters such as letters, digits, punctuation and special symbols. In Python, Regular Expressions (RegEx) are used to match the patterns in the given input strings. The re module in Python provides different methods to use the regular expressions. This module helps the developers to perform search operations, validations, filtering and much more based on string patterns. To match a non-whitespace character in Python we can use the special character class \S inside a raw string in any ... Read More

What is the difference between Python's re.search and re.match?

Niharikaa Aitam
Updated on 09-Jun-2025 09:47:04

2K+ Views

In Python, Regular expressions are also called RegEx, which is a sequence of characters that defines a search pattern. The re module provides several functions to work with patterns in text. This is widely used in Python tasks such as string matching, validation, and manipulation. The most commonly used functions in the "re" module are re.match() and re.search(). These two methods are used to check for the presence of a pattern, but they differ in the way they look for a pattern match within a string. In this article, we are going to see the difference between the Python re.search() ... Read More

How to update a Python dictionary values?

Niharikaa Aitam
Updated on 09-Jun-2025 09:34:02

73K+ Views

In Python, a Dictionary is one of the data structures that contains key-value pairs enclosed in curly braces '{}'. It is a Mutable and ordered data structure. Before proceeding with updating the values of a dictionary, let's create an example Dictionary with 4 key-value pairs, in which Product, Model, Units, are keys of the Dictionary - # Creating a Dictionary with 4 key-value pairs myprod = { "Product":"Mobile", "Model": "XUT", "Units": 120, "Available": "Yes" } # Displaying the Dictionary print(myprod) # Displaying individual values ... Read More

How to check if a string is alphanumeric in Python?

Sarika Singh
Updated on 09-Jun-2025 09:19:01

7K+ Views

In Python, strings can contain letters, numbers, or special characters. To check if a string is alphanumeric (contains only letters and numbers), we can use different methods. This article shows three simple ways to do that: Using the isalnum() function Using regular expressions Using the isalpha() and isdigit() functions Using the isalnum() Function The isalnum() method returns True if all characters in the string are letters or digits; otherwise, it returns False. Example: Basic Alphanumeric Check In the example below, we take two strings and check if they contain only alphabets and numbers using the isalnum() function: str1 ... Read More

How to join two strings to convert to a single string in Python?

Sarika Singh
Updated on 09-Jun-2025 09:06:16

2K+ Views

In Python, we can join two strings into one single string using different ways, such as - Using the + Operator Using the join() Method Using Formatted Strings String Concatenation in Loops Let us look at each method with examples. Using + Operator The most common way to combine two strings into one in Python is by using the + operator. It joins the strings exactly as they are, without any space or separator in between. Example In the following example, we ... Read More

How to check if a character is upper-case in Python?

Sarika Singh
Updated on 09-Jun-2025 08:55:59

42K+ Views

In this article, we are going to find out how to check if a character is an uppercase letter in Python. We will explore four different approaches - Using the isupper() method Using regular expressions Using ASCII values Direct comparison In each approach, we will check whether a given character is in uppercase and return True or False accordingly. Using the isupper() Method The first and most straightforward way is by using the built-in isupper() method. This method returns True if the ... Read More

Advertisements