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
kotykmax [81]
3 years ago
15

Write a function that given an integer N(1<=N<=100) returns an array containing N distinct Integers that sum up to 0. The

function can return any such array. For example, given N=4, the function could return (1,0,-3, 2], and for N=3 one of the possible answers is [-1,0,1] (but there are many more correct answers)
Computers and Technology
1 answer:
Lostsunrise [7]3 years ago
6 0

Answer:

Explanation:

This is simple. I We begin by creating 2 groups of equal and opposite. The total number of elements in both group is N (if N is even) or N-1(if N is odd). The total value of both group should equal to 0. Add 0 if N is odd

We can code this function in python

def array_maker(N):

    if N % 2 == 1:

         if N == 1: # special case

              return [0]

         else:

              left_ray = [i for i in range(-N//2, 1)]

              right_ray = [i for i in range(N//2)]

              left_ray.extend(right_ray)

              return left_ray

    else:

         left_ray = [i for i in range(-N/2, 0)]

         right_ray = [i for i in range(N/2)]

         left_ray.extend(right_ray)

         return left_ray

You might be interested in
Which feature of Microsoft power point allowed you to put a picture in every slide
nasty-shy [4]

Click where you want to insert the picture on the slide.

On the Insert tab, in the Images group, click Pictures.

In the dialog box that opens, browse to the picture that you want to insert, click that picture, and then click Insert.

3 0
3 years ago
Your help will help me understand my answers by comparing to yours. Your kind contribution is very much appreciated.
OLEGan [10]
4. B
for # 5 what illustration are u talking about
6. D
7. D
8. don't understand that question

sorry these questions might be wrong

6 0
3 years ago
STOP DELETING MY ANSWERS AND QUESTIONS!!!!!!!
puteri [66]

Answer:

no

Explanation:

trolled

3 0
3 years ago
Taking multiple cells in a spreadsheet and combining them into one large cell is referred to as
lyudmila [28]
Cell merging or just merging
6 0
3 years ago
Read 2 more answers
5
Vilka [71]
Is there like a graph or something I can look at because then I can help you
5 0
3 years ago
Other questions:
  • When the speaker compares dream memories to fall leaves that are hard to catch,what feeling does the simile suggest?
    14·2 answers
  • We say that a sequence of numbers is a palindrome if it is read the same backward or forward. For example, the sequence: 6, 15,
    11·1 answer
  • A thesaurus can be used to look up a (n) or word similar in meaning to a given word
    15·1 answer
  • Write a program segment that simulates flipping a coin 25 times by generating and displaying 25 random integers, each of which i
    5·1 answer
  • Consider the classes below:
    13·1 answer
  • Given an array a, write an expression that refers to the first element of the array .
    5·1 answer
  • Which device contains or manages shared resources in a network?
    14·2 answers
  • 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
    6·1 answer
  • Discuss the core technologies and provide examples of where they exist in society. Discuss how the core technologies are part of
    14·1 answer
  • Is a mainframe computer portable?​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!