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
What command utilizes the limpel-ziv (lz77) compression algorithm and achieves a compression ratio of 60-70 percent?
AURORKA [14]

The limpel-ziv (lz77) compression technique is used by the GNU zip (gzip) tool to produce a compression ratio of 60–70%.

<h3>How do methods for data compression function? Describe the LZW algorithm.</h3>

Compression methods lower the amount of memory needed to hold pictures and the number of bytes needed to represent data. Compression improves the amount of data that can be delivered over the internet and enables the storage of more photos on a given media.

Abraham Lempel, Jacob Ziv, and Terry Welch developed the table-based lookup technique known as LZW compression to compress a file into a smaller file. The TIFF image format and the GIF image format are two frequently used file formats that employ LZW compression.

To know more about limpel-ziv (lz77) compression algorithm, Visit:

<u>brainly.com/question/19878993</u>

#SPJ4

4 0
1 year ago
The Save command saves your changes silently without additional prompts, using the same save settings; the Save As command reope
kirza4 [7]

The "Save command" saves your changes <u>silently</u> without additional prompts and it uses the same save settings while the "Save As command" <u>reopens</u> the Save screen: True.

What is the Save command?

A Save command can be defined as a type of command associated with the file menu of a software application and it causes a copy of the current file to be created and stored to a specific location on a computer system.

<h3>What is the Save as command?</h3>

A Save command can be defined as a type of command associated with the file menu of a software application and it causes a copy of the current file to be created and stored to a different location, file name, and/or file type.

In conclusion, the "Save command" saves your changes <u>silently</u> without additional prompts and it uses the same save settings while the "Save As command" <u>reopens</u> the Save screen, so as to enable you make different choices.

Read more on Save command here: brainly.com/question/16852455

5 0
2 years ago
How to upgrade brainly membership
rjkz [21]

Answer:

Go on account settings, go to subscription, and upgrade.

Explanation:

7 0
3 years ago
Read 2 more answers
modify hw 02 c.c to use envp instead of environ. be sure that you understand how the code works. provide liberal comments to exp
rjkz [21]

With the aid of pointer-based arithmetic operations and the usage of pointers in comparison operations, address arithmetic is a technique for determining the address of an object. Pointer arithmetic is another name for address arithmetic.

The pointers can be used for mathematical operations like addition, subtraction, etc. The outcome of an arithmetic operation on the pointer, however, will likewise be a pointer if the other operand is of type integer because we know that the pointer includes the address. These operations are addition and subtraction. In C++, a pointer's value can be increased or decreased. It signifies that we can change the pointer's value by adding or removing integer values. A pointer arithmetic can be subtracted (or added) from another in a manner similar to this.

Learn more about arithmetic here-

brainly.com/question/11424589

#SPJ4

4 0
1 year ago
1. Ce este o baza de date? (1p)
lesya [120]

Answer:

would you mind telling me what this says im still learning my spanish

Explanation:

6 0
2 years ago
Read 2 more answers
Other questions:
  • After an informative session, you find yourself with several pages of notes. For maximum retention and understanding, you should
    6·1 answer
  • Which of the following identifies the patterns used for each data series in a chart?
    13·1 answer
  • Which of the following is not a metamorphic agent?
    8·2 answers
  • If you are inserting an address block with the Address Block dialog box and the fields do not connect automatically, what can yo
    6·2 answers
  • Discuss how 3D modeling enhances animation.
    13·1 answer
  • Which skill type refers to the ability to interact and communicate effectively with people? skills refer to the ability to inter
    8·2 answers
  • Please help I will mark brainliest
    11·2 answers
  • GRAND THEFT AUTO 5 LOLLL
    15·2 answers
  • Explain how mobile phone production could be more sustainable​
    8·2 answers
  • Deirdre has a hearing disability. One of her friends advised her to use real-time text or RTT on her phone. In which of these
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!