Ask Question
11 February, 12:33

Read three numbers from user input. Then, print the product of those numbers. Ex: If input is 2 3 5, output is 30. Note: Our system will run your program several times, automatically providing different input values each time, to ensure your program works for any input values. (note I am using python language)

+4
Answers (1)
  1. 11 February, 14:06
    0
    This is written in Python 3. And I am assuming that since the output is "30", which is derived from the inputs 2, 3, and 5, these three are multiplied to get the final output.

    fnum = int (input ('Enter first number: '))

    snum = int (input ('Enter second number: '))

    tnum = int (input ('Enter third number: '))

    output = (fnum * snum) * tnum

    print ("The output is:", output)

    Explanation:

    For the first three lines, we ask the user to input 3 numbers. At the same time, we are also converting these inputs into int type.

    fnum = int (input ('Enter first number: ')) snum = int (input ('Enter second number: ')) tnum = int (input ('Enter third number: '))

    The breakdown here is as follows:

    fnum, snum, and tnum are user-defined variables which will hold the user's inputs. int () is needed to define that everything inside it is an integer. If we don't first convert the input to integers, we will receive an error during multiplication saying that we cannot multiply non-int type variables. You can also choose to use Float here instead of Int - in which case, it will be float (). input ('Enter first number:')) - this is the part where we ask the user to enter the number they want.

    Put together, it looks like this:

    variable = int (input ('Your Custom Text Here: '))

    The next block would be:

    output = (fnum * snum) * tnum

    This is where we multiply the first, second, and third number to get to the output.

    Finally, we print it with:

    print ("The output is:", output)

    Concatenating a string and variable looks like this.

    print ("text here", output) - when concatenating a string and a variable, simply add a comma after the quotation marks of the string.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Read three numbers from user input. Then, print the product of those numbers. Ex: If input is 2 3 5, output is 30. Note: Our system will ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers