Question: 3. (50 point) Write a python script that gets a sequence of space separated integers as a list. It then gets a desired integer from

 3. (50 point) Write a python script that gets a sequence

3. (50 point) Write a python script that gets a sequence of space separated integers as a list. It then gets a desired integer from user. The script needs to return indices of all two list members whose sum are equal to the user's desired integer if there is any - duplicate indices should not appear in the output) Note that you can use nested loops to iterate over the list elements and solve this question. However, such a solution is computationally very expensive. To have a solution with a reasonable computation cost you have to use Python dictionary in your solution. You get no credit for solving this question without a Python Dictionary For example: enter the elements of a list 12345678 enter your desired integer 07 This means that elements with the indices of O and 7 (1.e. 1 and 8 in the list), 1 and 6 (e. 2 and 7 in the list), 2 and 5 (l.e. 3 and 6 in the list), and 3 and 4 (1. 4 and Sin the list) add up to the desired integer which is 9. Another example would be: enter the elements of a list 0-2 11 13 14 102 78 2 82 80 enter your desired integer

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 Databases Questions!