224k views
0 votes
Using a post-test while loop, write a program that lets users enter N floating point numbers and then calculates and displays their product. The value of N must be given by the user in the beginning of the program. CodeHs and Python 3

User Rhobincu
by
7.4k points

1 Answer

2 votes

Answer: Here is an example of a post-test while loop in Python 3 that lets users enter N floating point numbers and then calculates and displays their product:

# Ask the user to enter the value of N

n = int(input("Enter the value of N: "))

# Initialize the product to 1

product = 1

# Initialize the counter

i = 1

# Post-test while loop

while i <= n:

# Ask the user to enter a floating point number

num = float(input("Enter a floating point number: "))

# Multiply the current product by the entered number

product *= num

# Increment the counter

i += 1

# Display the product

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

User Muhammedv
by
7.8k points