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
vova2212 [387]
3 years ago
12

3. Write a function named sum_of_squares_until that takes one integer as its argument. I will call the argument no_more_than. Th

e function will add up the squares of consecutive integers starting with 1 and stopping when adding one more would make the total go over the no_more_than number provided. The function will RETURN the sum of the squares of those first n integers so long as that sum is less than the limit given by the argument
Computers and Technology
1 answer:
kenny6666 [7]3 years ago
6 0

Answer:

Following are the program to this question:

def sum_of_squares(no_more_than):#defining a method sum_of_squares that accepts a variable

   i = 1#defining integer variable  

   t = 0#defining integer variable

   while(t+i**2 <= no_more_than):#defining a while loop that checks t+i square value less than equal to parameter value  

       t= t+ i**2#use t variable to add value

       i += 1#increment the value of i by 1

   return t#return t variable value

print(sum_of_squares(12))#defining print method to call sum_of_squares method and print its return value

Output:

5

Explanation:

In the program code, a method "sum_of_squares" is declared, which accepts an integer variable "no_more_than" in its parameter, inside the method, two integer variable "i and t" are declared, in which "i" hold a value 1, and "t" hold a value that is 0.

In the next step, a while loop has defined, that square and add integer value and check its value less than equal to the parameter value, in the loop it checks the value and returns t variable value.

You might be interested in
In short and brave what is technology?
emmainna [20.7K]

Answer:

technology is a whole means to provide goods needed for the survival and comfort of human life

8 0
3 years ago
Read 2 more answers
Write a method called removeInRange that accepts four parameters: an ArrayList of integers, an element value, a starting index,
Murrr4er [49]

Answer:

public static void removeInRange(List<Integer> list, int value, int start, int end) {

       for (int i = end - 1; i >= start; i--) {

           if (list.get(i) == value) {

               list.remove(i);

           }

       }

       System.out.println(list);

   }

Explanation:

- Create a method named <em>removeInRange</em> that takes four parameters, a list, an integer number, a starting index and an ending index

- Inside the method, initialize a <u>for loop</u> that iterates between starting index and ending index

- If any number between these ranges is equal to the given <em>value</em>, then remove that value from the list, using <u>remove</u> method

- When the loop is done, print the new list

7 0
3 years ago
Where can I find information regarding different career choices in AZCIS?
Vadim26 [7]
I think Internet is the best way to search career choices. You can get a lot information.

4 0
4 years ago
You are opening a store, and having a working website is an important part of your project plan. The company that started creati
Murljashka [212]
A should be the answer... not having the website will cause you to have to everything by call and things like that ... plz brainliest.
6 0
4 years ago
Read the sentence from the first paragraph of Silent
kakasveta [241]

Answer:

B, Peaceful

Explanation:

Trust me, im 1000% sure that it is B.

I know hat you are probably already done with the test, but here you go anyway!

PLEASE mark me most brainly?!

3 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following is a Microsoft solution that runs on a Microsoft Terminal Services server but appears, to end users, as i
    10·1 answer
  • When you use the mvc pattern for a java web application, you often add ________________________ to the request object before you
    7·1 answer
  • The 2 main types of copyright relevant to the recording industry?
    5·2 answers
  • During the ________ phase of the systems development life cycle process, developers construct, install, and test the components
    13·1 answer
  • Write a MIPS assembly language program that accomplishes the following tasks:The program will prompt the user to enter an intege
    7·1 answer
  • Netflix uses ________ analytics to suggest which movies we should watch as well as to develop new content that it is confident w
    7·1 answer
  • Haley is helping to choose members for a customer satisfaction team. Which
    6·1 answer
  • Suppose a company A decides to set up a cloud to deliver Software as a Service to its clients through a remote location. Answer
    8·1 answer
  • Dennis would like to include a video in a presentation. The source of the video is on the internet, but he would like to ensure
    10·2 answers
  • The higher the ____________________, the faster the ____________________.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!