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]
2 years 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]2 years 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
Give several reasons why Python is such a great programming language. Explain how Python is related to flowcharts.
luda_lava [24]

Answer:

Python is the current language of choice in schools because it helps people build good coding techniques very quickly, and it has a robust range of uses. Code presentation is also an increasingly important distinction between the two languages. In the past, developers used code largely to create applications.

Explanation:

Python is related to flowcharts. because You write a program by setting up a flowchart. When you run the flowchart the software compiles to python byte-code so that you can easily import modules you write in Flowchart Python into standard Python programs.

sorry if i'm wrong

4 0
3 years ago
COMPUTER SCIENCE HELP!!!!!
maw [93]
1.( I need to know what program this is for to answer this one)
2.Explain a game you played for this one and include a interactive element it had like a Side-quest/Npc/Cool Background ect.
3.For 3D games you have to worry about smoothing and lighting, as for 2D you have to worry about keeping the objects within the players POV as they are usually locked to character and stuck facing one direction.
4.???(need progam name)
5.If the game is based in a snow biome you would use snow landscape textures.
8 0
4 years ago
Why did some people not like the arrival of machines?
Ahat [919]
People are concerned about losing their jobs. The industrial revolution introduced machines that removed the need for humans to be involved in highly repetitive tasks.
3 0
4 years ago
How many passes will it take to find the four in this list?
Vaselesa [24]
I don’t know what the heck is it true
3 0
3 years ago
Read 2 more answers
What's the best way to change the font size of all your notes pages at once?
defon
On which os? mac os windows linux?
7 0
3 years ago
Other questions:
  • _____ performs a real-time lookup of a digital certificate’s status. Group of answer choices Certificate Revocation List (CRL) R
    6·1 answer
  • A TCP entity opens a connection and uses slow start. Approximately how many round-trip times are required before TCP can send N
    11·1 answer
  • Convert the binary (base-2) number 1001 to decimal (base-10).
    9·1 answer
  • Which is a popular IRC chat service?
    8·1 answer
  • A "credit score" is a three-digit number which rates how much a company likes you personally. True. False.
    15·2 answers
  • In the Mouse Properties window, you can?
    8·1 answer
  • Match the elements of a web page with their description
    15·2 answers
  • Is pseudocode obtained from Algorithm or is Algorithm obtained from pseudocode?
    8·1 answer
  • Is a mainframe computer portable?​
    10·1 answer
  • 2
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!