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
This is due in like an hour but I'm confused so please do lend assistance
blagie [28]
Yes you do have to program it first.
4 0
3 years ago
The _______ provides access to the internet; may also be internal?
VikaD [51]
World Wide Web (WWW)? I honestly don't know.
8 0
3 years ago
What is an iterator and why is it useful for ADTs?
VladimirAG [237]

Answer:

Iterator is the element that used for transversing of any container by the user. This provides the facility to user to process any constituent belonging to the container and storage of these elements can be in any form.

This situation takes place under the isolation condition of the user from the container's internal model. Abstract data types use iterators for the maintenance of the transversal of the data structure.

4 0
4 years ago
What is the best way to appeal to an audience in any medium ?
BigorU [14]

Answer:

I think it's D

Explanation:

The best way to appeal is with emotions

8 0
3 years ago
To remove all the changes made to your system, the Windows ________ utility returns your computer to the state it was in when it
coldgirl [10]

Answer: Refresh

Explanation:Refresh is the tool available in the operating system for the regaining the page with actual factors . It eliminates the factors that made change before in the computer.

It is also done for the quick updating of the desktop so that the work done in the system in from the initial period and not containing any previous changes.It regains the utility,refreshes the function back  to active mode etc.

4 0
3 years ago
Other questions:
  • During the past decade ocean levels have been rising faster than in the past, an average of approximately 3.1 millimeters per ye
    14·1 answer
  • While in slide show mode, if you are not careful you can close the application by clicking the x on the menu bar
    12·2 answers
  • Respecting culture in the workplace means understanding that
    5·2 answers
  • Which os the following is NOT true about the proof of work concept?
    8·1 answer
  • Primary technology skills are skills that are necessary for success in online education
    9·2 answers
  • What are like arms surrounding all the other code blocks?
    11·2 answers
  • What are the concerns surrounding 5G cellular networks?​
    6·1 answer
  • How did imperialism lead to WWI? A The debate of the morality of imperialism created tensions around Europe b Native people were
    12·1 answer
  • Will social media lose its relevance?​
    6·1 answer
  • Lance is at a bus station. his friend is using the atm machine to withdraw some money. lance notices a stranger deceptively watc
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!