Question: ( a ) For the first part of the program, prompt the user to input a sequence of positive integers, which are saved in a

(a) For the first part of the program, prompt the user to input a sequence of positive integers, which are saved in a list (you may want to instantiate the list first)
a. Terminating Condition: The user will input a q to indicate they have
finished entering the sequence. The q should NOT be added to the list.
b. Prior to entering a q,
i. The program must handle inputs that are not positive integers without
throwing an error. If the input is not a positive integer (and not q),
the program should display an Invalid Input message and NO value
should be added to the list.
ii. if the user inputs a positive integer less than 100, the input should be
stored in the list as an integers
iii. If the user enters a positive integer greater than or equal to100, the
text over should be stored.
Hint: This can be accomplished using a while loop, alongside the isnumeric() function, type casting, selective control statements (if/elif/else),
(b) Display the resulting list from part (a)
(c) Create a second list. Using a For or While Loop, add to the second list the index numbers of all instances of Over in the list created in part (a). Display the completed second list as shown in the example below.
Hint: you may want to use len function, a range, and sequence indexing. You will also need the print function.
(d) Using List Comprehension create a new list that contains all of the values from the list in part (a) that are positive integers, but does NOT include the Over statements. Then display the resulting list

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!