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
satela [25.4K]
1 year ago
13

Copy and paste your code from the previous code practice. If you did not successfully complete it yet, please do that first befo

re completing this code practice.
After your program has prompted the user for how many values should be in the array, generated those values, and printed the whole list, create and call a new function named sumArray. In this method, accept the array as the parameter. Inside, you should sum together all values and then return that value back to the original method call. Finally, print that sum of values.
Computers and Technology
1 answer:
Gre4nikov [31]1 year ago
4 0

The code practice illustrates the following concepts:

  • Arrays or Lists
  • Methods or Functions

<h3>The program in Python</h3>

The program written in Python, where comments are used to explain each action is as follows:

#This imports the random module

import random

#This defines the sumArray method

def sumArray(myList):

   #This initializes the sum to 0

   isum = 0

   #This iterates through the list

   for i in myList:

       #This adds the array elements

       isum+=i

   #This returns the sum

   return isum

#This gets the number of values    

n = int(input("Number of values: "))

#This initializes the list

myList = []

#This iterates from 0 to n - 1

for i in range(n):

   #This populates the list

   myList.append(random.randint(0,100))

#This prints the list

print(myList)

#This calls the sumArray method

print(sumArray(myList))

   

Read more about Python programs at:

brainly.com/question/24833629

#SPJ1

You might be interested in
In an oligopolistic market, consumer choice is?
Alekssandra [29.7K]

Answer:

it's limited

Explanation:

I took the Test on Edgenuity

7 0
3 years ago
Read 2 more answers
How does this splitting wedge make work easier?
Pavlova-9 [17]
The believe that the best answer among the choices provided by the question is D) changes the direction and amount of applied force

Hope my answer would be a great help for you.    If you have more questions feel free to ask here at Brainly.
3 0
3 years ago
WILL GIVE BRAINLIEST TO FIRST AND BEST ANSWER!
sladkih [1.3K]

Answer:

1. Write to the Reader

2. Structure your report

3. Back up your report with data

4. Separate facts with opinions

Explanation:

1. Remember that you’re not writing the report for yourself. You’re probably writing for clients or management, so you need to know how familiar they are with the concepts and terminologies that your team uses. If they’re not well-acquainted with it, you may have to spend the first part of your report defining them so readers can follow along. Or, you might want to dumb it down a bit to layman’s terms and cut back on acronyms and jargon. A good way to practice this is to do the same with meeting notes.

2. One thing all reports should have in common is a form of structure. Ideally, you want to organize information into different segments so that your reader can identify relevant sections and quickly refer back to them later on. Common sections include a background or abstract to explain the project’s purpose, and a final summary of the document’s contents.

3. A good project report is going to have lots of data backing it up, whether it is defending the team’s performance or breaking down a successful project. Accurate charts, spreadsheets, and statistics are a must if the report is to have any degree of credibility when presented to clients. Many project management tools provide flexible project reporting features to help PM’s compile and present data in meaningful ways.

4. You should never confuse the two when writing a project report, especially if you are doing a post-mortem on a failed project. Opinions are subjective and should never be presented as absolutes. The report should be scrubbed of any personal views or preferences unless absolutely necessary. And if your opinion is required, be sure to clearly identify it as such. You may want to put it in an entirely different section, if possible.

Hope this helped

Kinda, really good at this stuff.

5 0
3 years ago
A 'array palindrome' is an array which, when its elements are reversed, remains the same (i.e., the elements of the array are sa
tia_tia [17]

Answer:

Here is the JAVA program:

class Main {    

static boolean isPalindrome(int array[], int starting, int ending) {  /*a boolean method that takes an integer-valued array, and a pair of integers representing the starting and ending indexes of the portion of the array to be tested for being a palindrome */

   if (starting >= ending) {  //base case

       return true;     }  //returns true

   if (array[starting] == array[ending]) {  //recursive case

       return isPalindrome(array, starting + 1, ending - 1);     }  //calls isPalindrome recursively to find out palindrome

   else {  

       return false;    }  }  //returns false if array is not palindrome

 

   public static void main (String[] args) {  //start of main function

   int array[] = { 1,2,3,2,1};  //creates an array

   int size = array.length;   //computes the size of array

 System.out.print(isPalindrome(array, 0, size - 1));    } } //calls method to test array for being  a palindrome

Explanation:

The program works as follows:

array = { 1,2,3,2,1}

starting = 0

ending = size-1 = 5-1 = 4

if (starting >= ending) condition evaluates to false because starting i.e. 0 is not greater or equal to ending i.e. 4. So the program moves to the next if part

if (array[starting] == array[ending])

This becomes:

if (array[0] == array[4])

The element at 0th index is the first element of the array i.e. 1 and the element at 4th index of array is the last element of array i.e. 1. So both these elements are equal so the following statement executes:

return isPalindrome(array, starting + 1, ending - 1);

Now the starting and ending become:

starting+1 = 0+1 = 1

ending-1 = 3

if (starting >= ending) base condition evaluates to false because starting  is not greater or equal to ending. So the program moves to the next if part

if (array[starting] == array[ending])

This becomes:

if (array[1] == array[3])

The element at 1st index is 2 and the element at 3rd index of array is 2. So both these elements are equal so the following statement executes:

return isPalindrome(array, starting + 1, ending - 1);

Now the starting and ending become:

starting+1 = 1+1 = 2

ending-1 = 2

if (starting >= ending) base condition evaluates to true because starting  is  equal to ending. So the following statement executes:

       return true;    

This means the function returns true and this shows that array is a palindrome.

The screenshot of the program and its output is attached.

8 0
3 years ago
Random.choice will choose a number between 1 and 100. True False​
DaniilM [7]

Answer: False.

Explanation: Random.choice can choose between any 2 numbers.

6 0
3 years ago
Other questions:
  • The exercise instructions here are LONG -- please read them all carefully. If you see an internal scrollbar to the right of thes
    8·1 answer
  • Write the definition of a function printAttitude , which hasan int parameter and returns nothing. The function prints amessage t
    13·1 answer
  • What is the name for the type of flash memory that is used by mobile devices to store their apps and data?
    6·1 answer
  • Enum Digits {0, 1};
    10·1 answer
  • When does MMF2 inactivate an Active object? A. When the score is higher than the game's previous high score B. When the player d
    15·1 answer
  • How do you invite someone to a conversation on brainly
    14·1 answer
  • The data type of 17.3 should be ________________.
    12·2 answers
  • Cual es la fiabilidad de la innovacion tecnologica
    15·1 answer
  • Escribe 10 ejemplos de lo que consideras un byte
    5·1 answer
  • Difference between centralized and decentralized processing in computer
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!