Multiply two decimal numbers and print the product with a precision of 2 decimal places .Input Format:Accept two decimal values as inputOutput Format:Print the product with 2 precisionConstraints: 1<=N1,N2<= 10^15Sample Input 1:125.58 78.65Sample Output 1:9876.87Sample Input 2:2.24 3.56Sample Output 2:7.97
Question
Multiply two decimal numbers and print the product with a precision of 2 decimal places .Input Format:Accept two decimal values as inputOutput Format:Print the product with 2 precisionConstraints: 1<=N1,N2<= 10^15Sample Input 1:125.58 78.65Sample Output 1:9876.87Sample Input 2:2.24 3.56Sample Output 2:7.97
Solution
Here is a Python solution for the problem:
# Accept two decimal values as input
N1 = float(input())
N2 = float(input())
# Multiply the two numbers
product = N1 * N2
# Print the product with 2 decimal precision
print("{:.2f}".format(product))
This program works by first accepting two decimal values as input from the user. It then multiplies these two numbers together to get the product. Finally, it prints the product with a precision of 2 decimal places by using the format function. The :.2f inside the format function is used to specify that we want 2 decimal places of precision.
Similar Questions
Multiply the given two numbers without using * operator.Input Format:Accept two integers as input.Output Format:Print the output as product of input1 and input2Constraints:1 <= INPUT <= 10^15Sample Input :10 2Sample Output :20
Problem Statement:Accept a floating point value and precision value and print the floating point value according to the precision given.Input Format:Accept one floating point and one integer valueOutput Format:print the floating point value according to the given precisionConstraints:3.4E-4932 to 1.1E+4932Sample Input :15.87 6Sample Output :15.870000
Problem Statement:Find the product of numbers from 1 to given nInput FormatA single integer - nOutput FormatPrint the productConstraints1<= n <= 1000000NOTE : The calculated product value might exceed integer range.Sample Input 1:10Sample Output 1:3628800Sample Input 2:5Sample Output 2:120
Problem Statement:Round off the given floating point value with accurate to 2 decimal places.Input Format:Accept a floating point valueOutput Format:Print the value accurate to 2 decimal placesConstraints:3.4E-4932 <= inp <= 1.1E+4932Sample Input 1:-165.12859Sample Output 1:-165.13Sample Input 2:12.53412Sample Output 2:12.53
Accept a floating point value and precision value and print the floating point value according to the precision given.Input Format:Accept one floating point and one integer valueOutput Format:print the floating point value according to the given precision
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.