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
dmitriy555 [2]
2 years ago
6

a) Write a program that prompts for an integer—let’s call it X—and then finds the sum of X consecutive integers starting at 1. T

hat is, if X=5, you will find the sum of 1+2+3+4+5=15.b) Modify your program by enclosing your loop in another loop so that you can find consecutive sums. For example , if 5 is entered, you will find five sum of consecutive numbers:1 = 11+2 = 31+2+3 =61+2+3+4 =101+2+3+4+5 =15Print only each sum, not the arithmetic expression.
Computers and Technology
1 answer:
Alex73 [517]2 years ago
7 0

Answer:

<u>Solution a</u>

  1. n = int(input("Enter an integer: "))
  2. sum = 0
  3. for x in range(1, n+1):
  4.    sum += x  
  5. print(sum)

<u>Solution b</u>

  1. n = int(input("Enter an integer: "))
  2. for a in range(1, n + 1):
  3.    sum = 0
  4.    for x in range(1, a+1):
  5.        sum += x
  6.    print(sum)

Explanation:

Solution code is written in Python 3.

<u>Solution a</u>

First get the user input for an integer (Line 1).

Create a variable sum and initialize it with zero value (Line 3).

Create a for loop to traverse through the number from 1 to integer n (inclusive) and sum up the current number x (Line 5-6).

Print the sum to terminal (Line 8).

<u>Solution b</u>

Create an outer for loop that traverse through the number from 1 to integer n (inclusive) (Line 3).

Create an inner loop that traverse through the number from 1 to current a value from the outer loop and sum up the current x value (Line 5-6).

Print the sum to terminal (Line 7) and proceed to next iteration and reset the sum to zero (Line 4).

You might be interested in
Write an application of computer in robotics?​
MariettaO [177]

Answer:

In robotics, one use the computer has is to help program the robots.

4 0
3 years ago
Create a scenario of a hypothetical company that needs an information system. This scenario should include the following informa
Effectus [21]

A  hypothetical company that needs an information system is Memphis drilling and construction company.

<h3>What is the size of a project?</h3>

This is known to be the  the number of firms taking part in the project and thus in the case above, it is small project.

In terms of Staff/experts availability, there are experts from the mining industry with years of experience, soil survey analyst as well as other minor staff.

In terms of System level of criticality, it is big because the extent to drilling will make use of the information system and other major decisions made.

Learn more about  information system from

brainly.com/question/14688347

#SPJ1

6 0
1 year ago
The number of colors available in a graphic is referred to as color what?
Drupady [299]
With 8<span> bits used to represent each color value, one pixel requires </span>24<span> bits. The number of colors available in a graphic is referred to as color depth. I hope you understand! :-)</span>
5 0
2 years ago
Ellen wants to find out what her median monthly spending is.The monthly totals for her spending appear in the range A10:L10.Whic
Fed [463]

Answer:

B

Explanation:

B. Select the range A1:L10, click the Quick Analysis button, click TOTALS, and then click Median.

Found it here might help with other questions on your test.

https://quizlet.com/386793520/cit105-excel-quiz-3-flash-cards/

3 0
3 years ago
Is there an ethically acceptable reason to study and use the various attack methods described in this chapter? Can you think of
avanturin [10]

Answer:

Please see below  

Explanation:

Yes, there indeed is ethical justification for hacking certain computer systems. Since computer scientists are required to keep the system secure from external threats, so they make use of it when testing the network for potential loopholes that could make it vulnerable. It is beneficial in that it can help manifest the weaknesses present in the system, which can then be corrected for.

6 0
3 years ago
Other questions:
  • The major difference between a calculator and a computer, when performing calculations, is that a
    10·1 answer
  • What program controls the hardware and software in a computer?
    10·1 answer
  • All java classes must contain a main method which is the first method executed when the java class is called upon.
    10·1 answer
  • What happens of the gamers dont follow the age ratings
    14·2 answers
  • When you sustain program implementation by staying true to the original design, it is termed A. Goals and objectives B. Program
    10·1 answer
  • Question 3
    13·1 answer
  • Discuss five domains of Instructional technology​
    7·1 answer
  • Why backup system of data and software is necessary. ​
    12·1 answer
  • Write a q basic program to find the sum of all the even numbers from 1 to 50​
    14·1 answer
  • Kim is writing a sql query that will pull a list of customers with outstanding orders and the sales rep for each order. What sho
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!