Found 34494 Articles for Programming

Making zero array by decrementing pairs of adjacent

Rinish Patidar
Updated on 28-Aug-2023 15:34:10

56 Views

The problem statement includes making an array zero array by decrementing pairs of adjacent. The array will be given in the input and we can perform the operation on the array i.e. subtract 1 from ith and (i+1)th index where 0

Python program to convert int to exponential

Gireesha Devara
Updated on 29-Aug-2023 14:17:26

1K+ Views

Exponential notation also known as scientific notation, is a way to express numbers that are very large or very small using a combination of a coefficient and an exponent. It is commonly used in scientific and mathematical calculations. In exponential notation, a number is expressed as the product of a coefficient and a power of 10. The coefficient is typically a decimal number between 1 and 10, and the power of 10 indicates the scale of the number. For example − The number 1, 000, 000 can be expressed as 1 x 10^6 or 1e+6 in exponential notation. The ... Read More

Java Math subtractExact(long x, long y) method

Rinish Patidar
Updated on 28-Aug-2023 15:31:08

161 Views

We will discuss the Java Math subtractExact(long x, long y) method in Java language and understand its functionalities and working. The subtractExact()is an inbuilt function in the Java Math library. The function returns the difference between the two parameters passed as arguments in the function. The function returns an exception when the returned value overflows the range of values of a particular data type. The syntax of the subtractExact() function long a; long b; long subtractExact(long a, long b); The parameters passed in the function are a and b which are of long data types. The function returns ... Read More

Python program to convert float to exponential

Gireesha Devara
Updated on 29-Aug-2023 14:18:23

2K+ Views

Float to exponential conversion involves transforming a decimal number, represented as a float, into exponential notation, also known as scientific notation. Exponential notation is commonly used for expressing very large or very small numbers in a concise manner, particularly in scientific and mathematical calculations. On the other hand, a float is a data type used to store real numbers, including both whole and fractional numbers. In Python, floats are commonly used to represent floating-point numbers. The process of converting a float to exponential can be achieved using various approaches in Python, such as using the format() function, f-string formatting, or ... Read More

Hoax Number

Rinish Patidar
Updated on 28-Aug-2023 15:28:20

159 Views

The problem statement includes checking if the given number N, which will be the user input, is a hoax number or not. A Hoax number is a composite number whose sum of digits of its distinct prime factors is equal to the sum of the digits of the composite number itself. Since 1 is not a prime number, we don’t consider 1 as a sum of digits of distinct prime numbers. If a prime number is a factor of the composite number more than once, it is just considered once while taking the sum of digits of prime factors. In ... Read More

Python Program To Convert dictionary values to Strings

Gireesha Devara
Updated on 29-Aug-2023 14:19:41

279 Views

A dictionary in Python is an unordered collection of key-value pairs. It is a data structure that allows you to store and retrieve values based on a unique key associated with each value. Keys in a dictionary are used to uniquely identify values, and they must be immutable, such as strings, numbers, or tuples. On the other hand, the associated values in a dictionary can be of any data type and can be mutable. When we want to convert a dictionary values to strings, we need to iterate over the dictionary using a loop and convert each value to a ... Read More

Hardy-Ramanujan Theorem

Rinish Patidar
Updated on 28-Aug-2023 15:27:05

134 Views

The Hardy−Ramanujan Theorem states that the number of distinct prime factors of any natural number N will be approximately equal to the value of $\mathrm{\log(\log N)}$ for most of the cases. For example, let’s consider N to be 1000. The number of distinct prime factors of 15 are 2 and 5 i.e. 2 distinct prime factors. The value of $\mathrm{\log_{e}(\log_{e}(1000))}$ is equal to 1.932 which is approximately equal to 2. The Hardy−Ramanujan theorem is proved in the above case. Since the theorem states that the number of distinct prime factors will be approximately equal to $\mathrm{\log(\log(N))}$ for most of ... Read More

Python Program to convert Dictionary to List by Repeating keys corresponding value times

Gireesha Devara
Updated on 29-Aug-2023 14:10:32

72 Views

In Python, dictionaries are key-value pairs where each key is associated with a corresponding value. When we want to convert a dictionary to a list by repeating keys, we need to iterate over each key-value pair and repeat the key based on its corresponding value. Input Output Scenarios See the following input-output scenarios to understand the concept of converting a dictionary to a list by repeating keys corresponding to the number present in the values. Input dictionary: {'a': 3, 'b': 2, 'c': 1} Output list: ['a', 'a', 'a', 'b', 'b', 'c'] In the input dictionary the key 'a' has ... Read More

Python program to convert Dict of list to CSV

Gireesha Devara
Updated on 29-Aug-2023 14:07:37

820 Views

In a dictionary, keys must be unique and immutable, while values can be of any type and can have a list of values. In the case of a dictionary of lists, each key points to a list that can contain multiple elements.  Here's an example of a dictionary of lists − data = {'numbers':[1, 2, 3, 4, 5, 6], 'states':['UP', 'Tamil Nadu', 'Telangana', 'Gujarat', 'UP', 'Tamil Nadu'], 'cities':['Agra', 'Chennai', 'Hyderabad', 'Surat', 'Lucknow', 'Coimbatore']}) In the above dictionary, each key is mapped to a list of values. For instance, the 'states' key maps to the list ['UP', 'Tamil Nadu', 'Telangana', ... Read More

Given a Number N in Decimal Base, find Number of its Digits in any Base (base b)

Rinish Patidar
Updated on 28-Aug-2023 15:25:51

134 Views

The problem statement includes finding the number of digits in N when represented in any base b numeral system. Initially, N is given in the base−10 numeral system. In the problem, we will be provided with a positive integer N in the input which will be in the base−10 numeral system and a positive integer b greater than 1. Our task will be to find the number of digits when N is being represented in the base−b numeral system. Any number represented in any base number, every digit from right represents the number of times power of that base number ... Read More

Advertisements