Computer Science, asked by Anonymous, 7 months ago

Take three numbers as input from the users. Store these numbers in a list. Display their product on the screen.

Answers

Answered by surajnegi0600
0

Answer:

numbers = []

for i in range(3):

   number = int(input("Enter a number: "))

   numbers.append(number)

product = 1

for number in numbers:

   product *= number

print("The product of the numbers is: ", product)

Explanation:

Here's a breakdown of the code:

  • We first create an empty list called numbers.
  • Using a for loop, we prompt the user to enter three numbers. We use the input() function to get the input as a string, and then use the int() function to convert it to an integer. We then append each number to the numbers list.
  • We initialize a variable product with the value 1. This variable will be used to store the product of the numbers in the list.
  • Next, we use another for loop to iterate over the numbers in the numbers list. Within the loop, we use the *= operator to update the value of the product variable. The *= operator is a shorthand for product = product * number. This way, on each iteration, the product variable will be updated with the product of all the numbers seen so far.
  • Finally, we use the print() function to display the product on the screen.

More questions and answers

https://brainly.in/question/50334736

https://brainly.in/question/6902368

#SPJ1

Similar questions