Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

make sure both examples work 3. (50 point) Write a python script that gets a sequence of space separated integers as a list. It then

image text in transcribed
make sure both examples work
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

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

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

More Books

Students also viewed these Databases questions

Question

5. Structure your speech to make it easy to listen to

Answered: 1 week ago

Question

1. Describe the goals of informative speaking

Answered: 1 week ago