Welcome to Westonci.ca, the Q&A platform where your questions are met with detailed answers from experienced experts. Ask your questions and receive accurate answers from professionals with extensive experience in various fields on our platform. Get quick and reliable solutions to your questions from a community of experienced experts on our platform.

Produce a program using a loop that requests for 8 floating point numbers from a user.once provided the program should calculate the average of all numbers that are less than 10.5


Sagot :

Answer:

The program in Python is as follows:

total = 0

count = 0

for i in range(8):

   num = float(input())

   if num < 10.5:

       total+=num

       count+=1

print("Average: ",total/count)

Explanation:

This initializes the total to 0

total = 0

This initializes the count to 0

count = 0

This loop is executed 8 times

for i in range(8):

This request for float number

   num = float(input())

If input is less than 10.5

   if num < 10.5:

The sum is taken

       total+=num

And count is incremented by 1

       count+=1

The loop ends here

This calculates and prints the average

print("Average: ",total/count)