Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question: Write a python function occurrences, without any argument. This function should: a) Prints the message: Type an integer value or q to finish, and

Question:

Write a python function occurrences, without any argument. This function should:

a) Prints the message: Type an integer value or q to finish, and press Enter: and stores the typed integers in a list (a variable local to the function) named data, until the user types the letter q to end the input messages.

b) Prints two lists:

1) The list of all integers between the minimum and maximum value in data, inclusive.

2) The list of occurrences of each value in data, i.e., the number of times each value was entered.

Here is an example of run: Type an integer value or q to finish, and press Enter: 0 Type an integer value or q to finish, and press Enter: 3 Type an integer value or q to finish, and press Enter: 5 Type an integer value or q to finish, and press Enter: 7 Type an integer value or q to finish, and press Enter: 3 Type an integer value or q to finish, and press Enter: 7 Type an integer value or q to finish, and press Enter: 3 Type an integer value or q to finish, and press Enter: 4 Type an integer value or q to finish, and press Enter: q [0, 1, 2, 3, 4, 5, 6, 7] [1, 0, 0, 3, 1, 1, 0, 2] The user typed 0 once, never typed 1 or 2, typed 3 three times, 4 once, 5 once, never typed 6 and typed 7 twice.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions