Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7506743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:20:34+00:00 2026-05-29T22:20:34+00:00

Continuously ask the user to enter numbers until the user enters a number that

  • 0

Continuously ask the user to enter numbers until the user enters a number that is greater than 100. Then print the average value of the numbers before the last input.

Here is what i have so far

def main():
 sum = 0.0
 coum = 0
 num = input("Enter a Number")
 while num <= 100:
   sum = sum + num
   coum = count
   num = input("Enter a Number")
   ave = sum/count
 print ave
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:20:35+00:00Added an answer on May 29, 2026 at 10:20 pm

    To test this, you should think of cases which you can walk through your code and see if the requirements are satisfied. Start with the simplest case in the beginning and work your way up to more complex cases.

    Consider the case where the first number is greater than 100 at the start. What lines get executed?

    sum = 0.0
    coum = 0
    num = input("Enter a Number") # say: num = 200
    while num <= 100:             # false, break out
    print ave                     # oops, what is `ave`?
    

    The calculation of ave should be done outside of the loop. But even then, you still have to worry about the division by zero problem as coum would be zero. I’ll leave that for you to think about. Let’s assume that for the rest of this walkthrough, that calculation is moved out of the loop.

    Next consider the case where the numbers are entered in this order: 100, 200. What lines get executed this time?

    sum = 0.0
    coum = 0
    num = input("Enter a Number") # num = 100
    while num <= 100:             # true, let's keep going
    sum = sum + num               # ok, 0.0 + 100 = 100.0
        # You probably would have seen a failure there,
        # depending on what version of Python you're using.
        # I will assume you're using Python 2.x.
    coum = count                  # oops, what is `count`
    

    There is no count variable here. So you can’t assign some unknown variable to another. Though since we’re trying to calculate the average of the numbers, a crucial number we need is the “count” of numbers that we are averaging. The coum variable really should have been count. At this point, you would want to be incrementing count by 1. Figure out how to do that. Let’s continue.

    num = input("Enter a Number") # num = 200
    while num <= 100:             # false, break out
    ave = sum/count               # ave = 100.0 / 1 = 100.0
    print ave
    

    Try the same thing for the numbers: 100, 50, 200. What lines get executed then? Figure that out and see if it still satisfies your requirements. If it does, then great, try the next case. If not, find out what’s wrong and try to fix it. If you’re stumped, ask about it. I hope you do a better job at that next time you ask a question here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to continuously sample from my PC's audio line in using C# (then
I have a strange phenomenon while continuously instantiating a com-wrapper and then letting the
It's a simple case of a javascript that continuously asks are there yet? Like
I have a simple .exe that needs to be running continuously. Unfortunately, sometimes it
I have here a piece of code that record the number of bottles collected
I continuously find myself having to write timed windows services that poll outside queues
I have a python script that runs continuously. It outputs 2 lines of info
I'm using mongoose in a script that is not meant to run continuously, and
I have a node.js script that continuously requests a page, sort of like a
I'm writing an accompaniment application that continuously needs to play specific notes (or even

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.