Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 (15 points] This question will ask you to do an exercise involving lists. You are asked to write a function fetch that takes

image text in transcribed

Question 1 (15 points] This question will ask you to do an exercise involving lists. You are asked to write a function fetch that takes in a list of positive, non-zero integers, and returns the smallest integer not in the list. For example, the smallest positive integer not in the list [1, 5, 2] is 3, so the function should return 3. You must also write a function get_input_from_user that creates a list based on user input, which we will use to create the list for the first function. The two functions should be implemented as follows: Name: fetch Parameters: A list numbers' of positive, non-zero integer values. Return value: The smallest positive integer not in the list. If an empty list is given, return the value 1. Name: get_list_from_input Parameters: No parameters Return value: A list of positive, non-zero integers entered by the user. What it should do: Ask the user to enter a number(s) with the prompt 'Enter number(s): !, then convert their entered numbers to integer and store them in a list. Keep asking the user to enter numbers until they enter the word 'done', at which point you should return the list of all numbers entered. The user may enter just one number on a line, or they could enter a series of comma-separated numbers, in which case each of the numbers must be added to the list. If the user enters any values less than 1, do not add them to the list. For example, if the user enters "4,5,-2 on one line, 4 and 5 should be added to the list, but -2 should not. You can assume the user will not enter any spaces, and only enter digits from 0-9 without any letters or special characters. Filename You must write this program in a file called sequence.py. In the file, the two functions are already defined for you, and at the bottom of the file there are calls to the functions. Examples (as executed in Thonny) EXAMPLE 1: >>> %Run sequence.py Enter number(s): done

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_2

Step: 3

blur-text-image_3

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

Generative Artificial Intelligence For Project Management With Aws

Authors: Timothy Krimmel

1st Edition

B0CQV9KWB8, 979-8872627197

More Books

Students also viewed these Databases questions

Question

Why does Pavlovs work remain so important?

Answered: 1 week ago