Over 10 Million Study Resources Now at Your Fingertips

Download as :
Rating : ⭐⭐⭐⭐⭐
Price : $10.99
Pages: 3
Words: 613

Rate Food & Unique Numbers Homework Answers Needed

Your Question:


Ten students were asked to rate the quality of the food in the student cafeteria on a scale of 1 to 3 (1 means poor, 2 means average, 3 means good). Write a program to read the responses of the 10 students into an array and summarize the frequency of the rating. An example is shown below.

3 3

4. Use a single-subscripted array to solve the following problem. Read in 10 numbers, each of which is between 10 and 100, inclusive. As each number is read, print it only if it is not a duplicate of a number already read. Provide for the "worst case" in which all 10 numbers are different. Use the smallest possible array to solve this problem.

Step By Step Answers with Explanation

print("Enter the 10 responses (1 for poor, 2 for average, 3 for good):")

for i in range(10):

        # Increment the corresponding rating frequency.

        ratings[response - 1] += 1

for i, frequency in enumerate(ratings):

    print(f"{i + 1}\t\t{frequency}")

# Read 10 numbers from the user.

print("Enter 10 numbers between 10 and 100, inclusive:")

    if 10 <= number <= 100:

        # Check if the number is already in the unique_numbers list.


            print("Duplicate number. Ignored.")

for number in unique_numbers:

    print(number, end=" ")

How It Works
Login account
Login Your Account
Add to cart
Add to Cart
Make payment
Document download
Download File
PageId: ELI758CD60
Uploaded by :
Page 1 Preview
step by step answers with explanation
Sell Your Old Documents & Earn Wallet Balance