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
I am a you tuber that does videos on the rob lox myth community, I have over 250+ subscribers. I was wondering if any of y'all w
Marina86 [1]

Answer:

I will for sure subscribe!!!!

Explanation:

:)

7 0
3 years ago
What is a required device(s) used to connect to an ISP Network?
Whitepunk [10]
A .switch isp connect network
8 0
3 years ago
Read 2 more answers
Soft skills are similar to personality traits like being compassionate, having patience, and working well in groups.
ikadub [295]

The answer is A. True


Because soft skills are:

1) Good communication skills

2) Team work

3) Positive attitude

4) Self confidence

5) Ability to learn from criticism

6) problem solving skills

7) patience

8) leadership quality


I hope the answer is clear

8 0
4 years ago
Read 2 more answers
Write a recursive method to return the number of uppercase letters in a String. You need to define the following two methods. Th
satela [25.4K]

Answer:

<u>Recursive function with two parameters that return the number of uppercase letters in a String</u>

public static int count(String str,int h)//Defining function

{

      if(str.charAt(0)>='A' && str.charAt(0)<='Z')//Checking the characters from A to Z

{

          h++; //incrementing the counter

          if(str.length()>=2){

              return count(str.substring(1),h);//recalling function

          }

      }

      if(str.length()>=2){

              return count(str.substring(1),h); //recalling function

      }

      return h;

  }

This is the recursive function with the name count of return type integer,having parameters str of string type and h of integer type.In this we are checking the characters at a particular position from A to Z.

<u>Recursive function with one parameter that return the number of uppercase letters in a String</u>

public static int count(String str)//Defining function

{

      if(str.charAt(0)>='A' && str.charAt(0)<='Z')//Checking the characters from A to Z

{

          count++; //incrementing the counter

          if(str.length()>=2){

              return count(str.substring(1));//recalling function

          }

      }

      if(str.length()>=2){

              return count(str.substring(1)); //recalling function

      }

      return count;

  }

This is the recursive function with the name count of return type integer,having parameters str of string type .In this we are checking the characters at a particular position from A to Z.

<u>Java program that return the number of uppercase letters in a String</u>

import java.util.*;

public class Myjava{

static int count =0;//Defining globally  

 

public static int count(String str,int h)//Defining function

{

      if(str.charAt(0)>='A' && str.charAt(0)<='Z')//Checking the characters from A to Z

{

          h++;

//incrementing the counter

          if(str.length()>=2){

              return count(str.substring(1),h);//recalling function

          }

      }

      if(str.length()>=2){

              return count(str.substring(1),h);

//recalling function

      }

      return h;

 

  }

  public static void main(String[] args)//driver function

  {

      System.out.println("Enter a string");//taking input

      Scanner scan = new Scanner(System.in);

      String s = scan.nextLine();

      int h =0;

      System.out.println("Counting the Uppercase letters: "+count(s,h));

  }

}

<u>Output</u>

Enter a string  WolFIE

Counting the Uppercase letters: 4

4 0
3 years ago
Windows OS and Mac OS are examples of which type of operating system?
german
Windows OS and Mac OS are examples of single user, multi tasking Operating Systems.
5 0
4 years ago
Read 2 more answers
Other questions:
  • A___________ is a person who can give information to potential employers about your character and your abilities. Employer emplo
    7·1 answer
  • The refresh or reload button is in the browser toolbar and usually looks like a pair of curved arrows. Clicking it will ________
    14·2 answers
  • A relational database is different from a simple database because it has more than one _____.
    13·1 answer
  • You wish to use a file system that creates a record or log of to-be-committed changes in the system so that if the system crashe
    14·1 answer
  • How to do a linear equations
    8·1 answer
  • Attach 2 screen shots demonstrating an understanding of file management tools, such as keyboard shortcuts, copy, paste, delete,
    8·1 answer
  • Please help it’s timed
    5·1 answer
  • By itself, the human eye cannot see anything in three dimensions. What does the passage say enables us to see the world in 3-D?
    11·2 answers
  • Could anyone help me with this assignment please?
    6·1 answer
  • When creating an html document, what do we use to set aside space for content?.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!