Rearrange the following lines so that the code properly reads a sequence of integers and computes...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Rearrange the following lines so that the code properly reads a sequence of integers and computes and prints their sum, using -1 as a sentinel. Not all lines are useful. Empty print statements are included for output formatting. How to use this tool Unused while value != 8: while value >= -1: value= int(input ("Enter a value or -1 to finish: ")) print() main.py total = 0 value = int(input ("Enter a value or -1 to finish: ")) print() while value != -1: total= total + 1 total= total value Load default template... print(total) Rearrange the following lines so that the code properly reads a sequence of integers and computes and prints their sum, using -1 as a sentinel. Not all lines are useful. Empty print statements are included for output formatting. How to use this tool Unused while value != 8: while value >= -1: value= int(input ("Enter a value or -1 to finish: ")) print() main.py total = 0 value = int(input ("Enter a value or -1 to finish: ")) print() while value != -1: total= total + 1 total= total value Load default template... print(total)
Expert Answer:
Related Book For
Introduction To Programming In Java An Interdisciplinary Approach
ISBN: 9780672337840
2nd Edition
Authors: Robert Sedgewick, Kevin Wayne
Posted Date:
Students also viewed these algorithms questions
-
Predictive text entry systems are familiar on touch screens and mobile phones. This question asks you to consider how the same principles might be used in a programming editor for creating Java code....
-
Let r and s be solutions to the quadratic equation x 2 b x + c = 0. For n N, define d0 = 0 d1 = r s dn = b dn1 c dn2 (n 2) Prove that dn = r n s n for all n N. [4 marks] (b) Recall that a commutative...
-
In Exercises use the Trapezoidal Rule and Simpson's Rule to approximate the value of the definite integral for the given value of n. Round your answer to four decimal places and compare the results...
-
Explain the advantages and disadvantages of fermentation to the human body
-
Management should be allowed to hire replacement workers immediately after a strike.
-
An electric eel develops a potential difference of \(450 \mathrm{~V}\), driving a current of \(0.80 \mathrm{~A}\) for a \(1.0 \mathrm{~ms}\) pulse. For this pulse, find (a) the power, (b) the total...
-
The text states, Over sufficiently long time periods, net income equals cash inflows minus cash outflows, other than cash flows with owners. Demonstrate the accuracy of this statement in the...
-
the pros and cons of coaching or mentoring as a management tool. Are coaching and mentoring effective training methods? Have you coached or been coached by someone in the workplace.
-
Tracey White, the owner of the Buzz Coffee Shop chain, has decided to expand her operations. Her 2012 financial statements follow. Tracey can buy two additional coffeehouses for $3 million, and she...
-
what are the advantages/importance of having an outstanding visual content in promoting unpopular or rising singer/artist in Instagram?
-
A pipe has two closed ends. We find resonance frequencies of 750Hz and 800Hz. The speed of sound is 343.1m/s. What is the length of the pipe (in m)?
-
Problem 6.1. The probability distribution of returns on stocks X and Y follows. Probabilit 0.2 0.3 0.3 0.2 y Rx -20 0% 20 40 % % % Ry 1% 3% 5% 7% Calculate the expected return and the standard...
-
Alonzo rented a truck for one day. There was a base fee of $18.99, and there was $151.02 when he returned the truck. For how many miles did he drive the truck?
-
You are sitting in your car at rest at a traffic light with a bicyclist at rest next to you in the adjoining bicycle lane. As soon as the traffic light turns green, your car speeds up from rest to...
-
Given the information below for HooYah! Corporation, compute the expected share price at the end of 2020 using price ratio analysis. Assume that the historical (arithmetic) average growth rates will...
-
Consider the following three alternatives with their cash flow tables. MARR=10% Alternative 2 0 1 2 3 4 5 6 7 8 Individual IRR Individual ERR when =4% Alternative 1 -20.000 4.000 6.000 5.000 3.500...
-
Integration is a vital concept when applied in one?s life. Integrating your life means making ideal choices. Perfect choices on the other go in line with quality decisions. Quality decisions lead to...
-
Write a static method sigmoid() that takes a double argument x and returns the double value obtained from the formula 1 / (1 + ex).
-
Spirographs. Write a program that takes three double command-line arguments R, r, and a and draws the resulting spirograph. A spirograph (technically, an epicycloid) is a curve formed by rolling a...
-
Fourier spikes. Write a program that takes a command-line argument n and plots the function for 500 equally spaced samples of t from -10 to 10 (in radians). Run your program for n = 5 and n = 500....
-
The magical elevator. There is a man who lives on the top floor of a very tall building. Every day he gets the elevator down to the ground floor to leave the building to go to work. Upon returning...
-
There are 5 different color houses, occupied by people of 5 different nationalities, who smoke 5 different cigar brands, drink 5 different types of alcohol, and have 5 different pets. The houses are...
-
A man went outside without an umbrella or a raincoat, yet did not get wet.
Study smarter with the SolutionInn App