Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q3: Sum fun! (Loop algorithms: Sum of values) Instructions This week we will step through some common loop algorithms. To start us off, we will

Q3: Sum fun! (Loop algorithms: Sum of values)

Instructions

This week we will step through some common loop algorithms. To start us off,

we will obtain a sum of values.

Your task is to fix the code so that it does what is expected/described below.

Details

Input

The program reads in the following:

an integer values (unknown quantity, each on their own line)

followed by one empty line (empty string )

Processing

Sum of values algorithm:

Initialize total to 0

Read in a value (make sure to convert it to proper data type)

Use while loop with looking for sentinel, each time through loop:

Add entered value to total

Read in another value (make sure to convert it to proper data type)

Output

Output the sum of the values.

Sample input/output:

Input Output
3 4 5 The sum of the values is 12.

image text in transcribed

\# Input total =0.0 inputString = input("Enter value: ) while inputString !=" value=int(inputString)inputString=input("Entervalue: )total+=valueprint(Thesumofthevaluesis+str(total)+)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

What does the optimal scale of operation mean?

Answered: 1 week ago

Question

What kitchen appliance do you use every day?

Answered: 1 week ago