Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using python While Statements While statements provide a mechanism that allows repeated computations to be performed. The while statement has the form: while condition: body_code

Using python

While Statements

While statements provide a mechanism that allows repeated computations to be performed. The while statement has the form:

while condition: body_code 

image text in transcribed

where condition is a boolean valued expressions and body code is a sequences of statements. 2 number-of-entries int( input ('Please enter the number of numbers: . )) = body_code is repeatedly evaluated until condition becomes false and in which case computation continues with the statement following the while statement. When writing a while loop there are a few things that you need to consider. Typically, you will need to initialize one or more variables before the while statement. The condition (test) of the while statement will usually become false eventually (otherwise the loop won't terminate). . The body code typically changes one or more variables in such a way that the condition will become false. For example, the following code, when executed, will output a countdown. The variable count is first initialized, the condition tests if count has reached O, and in the body of the loop count is decremented (and will eventually become O) count = 5 while count 0 print (count) count count -1 print( Thunderbirds are Go) Write a program that first prompts the user to enter the number of numbers to be entered and then uses a while loop to repeatedly prompt the user for those numbers and adds the numbers to a running total. When the correct number of numbers have been entered, the program should print the average You can assume the number of numbers entered is an integer greater than zero and that each subsequent number is a float

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

Step: 3

blur-text-image

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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions