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
You’ve been hired to help with installing cable at a new office building for the local branch of the Social Security Administrat
Morgarella [4.7K]

Answer:The arrangements are as follows:

Orangewhite color

Orange color

Greenwhite color

Blue color

Bluewhite color

Green color

Brownwhite color

Brown color

Explanation:

The will be put side by side in the order above and pushed into the connector. Thank you

6 0
4 years ago
Parts of a computer software
VARVARA [1.3K]

Answer:

I think application software

utility software

networking software

4 0
3 years ago
Though there are no specific federal laws for cyberbullying, in some cases cyberbullying
inessss [21]
Cyberbullying overlaps with discriminatory harassment
7 0
3 years ago
A user is trying to log into windows on her notebook computer. she enters the correct password for her user account, but the sys
ASHA 777 [7]
Try restarting the PC. I have the same issue on Windows 10 sometimes generally its a network error because Windows 10 has a lot of internet required features... 
7 0
4 years ago
What can make an online interface difficult to use?​
Natalija [7]

Answer:

their is a lot miscomsuptions

Explanation:

8 0
3 years ago
Other questions:
  • A security system uses sensors at every door and window which will set off an alarm if any one of them is opened. There is also
    13·1 answer
  • Which network component allows computers to communicate on a network without being connected directly to each other?
    9·1 answer
  • 6-3.1 After visiting a large number of Web sites to complete your research for a lengthy research paper, your computer begins to
    14·2 answers
  • There is a class called Roster whose constructor takes a List of tuples with the names of students and their grades in the class
    13·1 answer
  • Your friend Rebecca called because she is working on a budget and needs help with the AutoSum feature. She thinks AutoSum will b
    8·1 answer
  • Improvements in technology make the world seem larger to people.<br> a. True<br> b. False
    6·2 answers
  • What output is produced by the following code? Integer first = new Integer(7); Integer second = first; if (first == second) Syst
    15·1 answer
  • Select the device that will have the most network ports
    8·1 answer
  • Advantages against its counterpart because of its portability​
    8·1 answer
  • "Automated Deployment" is one of the prerequisite for DevOps implementation.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!