Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please you must use python and read the prompt carefully. Objective: To write a program to remove duplicates from a list Write a program that

Please you must use python and read the prompt carefully.
Objective: To write a program to remove duplicates from a list
Write a program that inputs a list of integers from the user, and removes the duplicate list elements, plus outputs their min and max values. Here is some sample output:
Please enter some positive integers, hitting return after each one. Enter 'q' to quit:
10
5
9
1
5
10
q
You entered 4 unique numbers:
10 5 9 1
with minimum value: 1 and maximum value: 10
Please enter some positive integers, hitting return after each one. Enter 'q' to quit:
2.5
You entered 0 unique numbers:
Please enter some positive integers, hitting return after each one. Enter 'q' to quit:
4
5
-3
You entered 2 unique numbers:
4 5
with minimum value: 4 and maximum value: 5
Please enter some positive integers, hitting return after each one. Enter 'q' to quit:
55
22
22
75
42
68
q
You entered 5 unique numbers:
55 22 75 42 68
with minimum value: 22 and maximum value: 75
Hints and Rules
Your program should stop the input if anything other than a positive integer is entered. You may want to use the "isdecimal()" function and/or others described in the Python docs for string methods.
Your program should have at least 2 functions, including a main() function (no global variables or global code other than a call to main within an if-statement)
If at least one positive integer is entered, your program should output the smallest (minimum) and largest (maximum) values in the list.
When the program is finished, the program must have a list that stores each number only once (without duplicates), in the same order they were entered. So you can't just skip outputting the duplicates - you have to remove them (or replace them)
The easiest and most efficient way to do this is to store only the non-repeating elements (only store a number in the array the first time you see it). You can use the "in" or "not in" boolean operators described in section 10.5 of your book.
A more intuitive and more complicated way to do it is to input all the numbers from the user into a list, and then change the list so it contains only the distinct numbers entered by the user. To remove the duplicates, you should make it appear as if the elements hadn't been there. So do not just set duplicates to an "empty" value, but delete them (you can use the del statement described in section 10.9 of your book)
Every function (except main) needs to have a comment in a triple-quoted string at the beginning, briefly explaining what it does.

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

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

Discuss the techniques of sales forecasting.

Answered: 1 week ago

Question

Write short notes on Marketing mix.

Answered: 1 week ago