1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Korolek [52]
3 years ago
11

Implement the function pairSum that takes as parameters a list of distinct integers and a target value n and prints the indices

of all pairs of values in the list that sum up to n. If there are no pairs that sum up to n, the function should not print anything. Note that the function does not duplicate pairs of indices
Computers and Technology
1 answer:
Yuki888 [10]3 years ago
6 0

Answer:

Following are the code to this question:

def pairSum(a,x): #find size of list

   s=len(a) # use length function to calculte length of list and store in s variable

   for x1 in range(0, s):  #outer loop to count all list value

       for x2 in range(x1+1, s):    #inner loop

           if a[x1] + a[x2] == x:    #condition check

               print(x1," ",x2) #print value of loop x1 and x2  

pairSum([12,7,8,6,1,13],13) #calling pairSum method

Output:

0   4

1   3

Explanation:

Description of the above python can be described as follows:

  • In the above code, a method pairSum is declared, which accepts two-parameter, which is "a and x". Inside the method "s" variable is declared that uses the "len" method, which stores the length of "a" in the "s" variable.
  • In the next line, two for loop is declared, in the first loop, it counts all variable position, inside the loop another loop is used that calculates the next value and inside a condition is defined, that matches list and x variable value. if the condition is true it will print loop value.
You might be interested in
What do you think about net neutrality??
Tomtit [17]
I think net neutrality should be kept! Removing net neutrality is unfair for all those who use the Internet! I think life would change is net neutrality did. Certain websites (a lot!) would slow down and cause a lot of people inconvenience, and I bet we'd have to pay more to use some sites!!!

NET NEUTRALITY SHOULD BE PRESERVED!!!!
6 0
3 years ago
Read 2 more answers
This is going to get taken down but I dont care add me on discord cause ima bored<br> -Red-#9847
Alex777 [14]

Answer:

I WILL

Explanation:

6 0
3 years ago
The inside color of text or of an object is called the:
AnnyKZ [126]
Fill color is the answer hope this helps
8 0
3 years ago
Assume we perform a known-plaintext attack against DES with one pair of plaintext and ciphertext. How many keys do we have to te
nasty-shy [4]

Answer:

2^{55} keys in a worst case scenario

Explanation:

So, Average will be : 2^{56} /2

2^{55}(Answer)

5 0
3 years ago
Which actions did Sheila have to take to make the changes observed? Check all that apply.
Harrizon [31]

Answer:

Use

Explanation:

Out line view

6 0
3 years ago
Other questions:
  • Which of the following correctly describes the reason for quality customer service?
    15·2 answers
  • Which of the following typically have the highest auto insurance premiums?
    14·1 answer
  • What does AAC stand for?
    11·2 answers
  • To display measurements on the ruler while changing column widths, hold down the ________ key while dragging the marker.
    13·1 answer
  • Mobile devices need to work within limited screen space ? true or false
    9·2 answers
  • ____ is the dubious practice of registering a domain name and then trying to sell the name for big bucks to the person, company,
    5·2 answers
  • ________models software in terms similar to those that people use to describe real- world objects.
    6·1 answer
  • What is the primary way to access applications in window 10
    7·1 answer
  • Whats the flow in this code, and whats the risk that its creating and what can i do to fix it? (c language)
    10·1 answer
  • Yaaaaaa.........
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!