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
How do you give brianliest
KatRina [158]

Answer:

When you ask a question in brainly, two helpers will answer it, then on each answerer you'll find "mark as brainliest" button which looks like a crown.

Hope this helps :)

6 0
3 years ago
WILL GIVE BRAINLEIST PLZ HELP PLZ AND THANK YOU
Anna35 [415]

Answer:

SIR I AM A BRAINLT MODERRATER U CAN NOT POST THINGS LIKE THIS  I LOOKED THIS UP AND ITS A TEST

Explanation:

3 0
3 years ago
Which mechanical switches are the loudest and clickiest?
telo118 [61]

Answer:

1.Cherry MX Blue

2.most expensive is Gateron Blue

3 0
3 years ago
Three of the most important jobs of security management are to ensure _____ are organized according to sensitivity, ensure that
Leokris [45]

Answer:

separation of duties, accountability, people

Explanation:

Three of the most important jobs of security management are to ensure separation of duties are organized according to sensitivity, ensure that roles maintain accountability, and to manage people because that is the enemy of security.

4 0
3 years ago
How to trigger watchers on initialization in vue.js ?
ale4655 [162]

Answer:

variable when the component is mounted. This triggers the watchers which then triggers an emit i have in the watcher. I do not want the emit to happen when the variable is only being initialized. The variable is from the data section of the vue component.

3 0
2 years ago
Other questions:
  • In dt.py, you will implement a basic decision tree classifier for
    5·1 answer
  • 2 Which statement best explains how computers are used to analyze information?
    6·1 answer
  • If you “bury” a story on Digg, what have you done
    10·1 answer
  • Explain how inflation flattens the universe
    6·2 answers
  • What is the difference between primary storage, secondary storage and off-line storage?
    5·1 answer
  • Create a class called Hangman. In this class, Create the following private variables: char word[40], progress[40], int word_leng
    11·1 answer
  • How is communication within healthcare different than communication within other industries ?
    13·1 answer
  • First person to answer gets free brainlist
    15·2 answers
  • What is the output of the following code?int *p; int *q; p = new int; *p = 43; q = p;*q = 52; p = new int; *p = 78; q = new int;
    5·1 answer
  • What is the earliest age you can collect social security.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!