Write a program that prompts for an integer-lets call it

Assignment Help Computer Engineering
Reference no: EM132173781

USING PYTHON IDLE

Sum of consecutive integers

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. That 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 sums of consecutive numbers:

1 = 1

1+2 = 3

1+2+3 = 6

1+2+3+4 = 10

1+2+3+4+5 = 15

Print only each sum, not the arithmetic expression.

c) Modify your program again to only print sums if the sum is divisible by the number of operands. For example, with the sum 1 + 2 + 3 + 4 + 5 = 15, there are five operands and the sum, 15, is divisible by 5, so that sum will be printed.

1 = 1

1 + 2 + 3 = 6

1 + 2 + 3 + 4 + 5 = 15

Reference no: EM132173781

Questions Cloud

Decrease in confidence affect the sample size required : Suppose the doctor would be content with 90% confidence. How does the decrease in confidence affect the sample size required?
Print the number of words in the sentence that contains : Suppose the user has been asked to enter a sentence. print the number of words in the sentence that contains two or more uppercase letters.
Draw a rectangle of specified dimensions : Write a function name rectangle that uses turtle graphics to draw a rectangle of specified dimensions, the function takes 3 parameters.
What is the expected number of inmates serving time : What is the expected number of inmates serving time for drug dealing? (Round your answer to one decimal place.)
Write a program that prompts for an integer-lets call it : 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.
Calculate the value of z : Assume that z is the test statistic. (Give your answers correct to two decimal places.)
Create a class called employee : Create a class called Employee. Constructor that accepts 5 parameters (for each of the attributes)
Question the accuracy of study : You read an article that states that the average male college student spends 3 hours per week playing video games.
Display the generated linked list items : Delete the replicate items in the linked list (i.e. leave one occurrence only of each item in the linked list).

Reviews

Write a Review

Computer Engineering Questions & Answers

  Why the static and dynamic links have same value for blocks

Discuss a SIMPLESEM abstract implementation using dynamic allocation for C4' nested blocks. Explain why the static and dynamic links have same value for blocks.

  Find and output the largest element and its index

Output the array and the address of each element. Find and output the largest element and its index. Find and output the smallest element and its index.

  Develop a gantt chart illustrating the project tasks

Develop a Gantt chart illustrating the project tasks (use Microsoft Project or a similar project management program).

  What is the time for main memory to transfer a block

What is the time for main memory to transfer a block of size 64 to main memory.

  Write a program that asks the user for a year

Write a program that asks the user for a year and computes whether that year is a leap year. Use a single if statement and Boolean operators.

  Cmg is also considering expansion into other markets

CMG's IT department consists of about 70 people. The department is broken up into the Technical Services group and an Application Development group. Project managers, business analysts, and application developers are within the application develop..

  Coose one of the system development approaches structured

select one of the system development approaches structured information engineering and object-oriented and give an

  Calculate the accumulated sample error for one character

Suppose that a remote transmitter sends a message at 2500 Baud and the receiver is expecting the data rate to be 2400 Baud.

  Why must the mouse press listener class supply five methods

Why must the Mouse Press Listener class supply five methods? How could you change the behavior of the program so that a new rectangle is added?

  Installing the new network

You have been hired as an IT Consultant in order to assist Good Nature food market with developing and implementing the new network. They have hired you to find what type of network they required and to install the network.

  Determine the mean and median household income

Write a program into which a village statistician can enter each of the 75 household income values, and determine the mean and median household income.

  Write a search method to determine if a word is in the list

Write a search method to determine if a word is in the list or not and a separate insert method. You will need a print method as well.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd