Counter = 0 S = 0 number = input ("please enter number: ") while (number != ''): s = float (number) counter +- 1 number input ("please enter number: ") print ("Sum of the number is if s>0: : ", str(s)) print ("Average of the number is: ", str (s /counter)) 1|
Counter = 0 S = 0 number = input ("please enter number: ") while (number != ''): s = float (number) counter +- 1 number input ("please enter number: ") print ("Sum of the number is if s>0: : ", str(s)) print ("Average of the number is: ", str (s /counter)) 1|
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
100%
Please! I really need help Writing the Pseudocode and flowchart of this image codes below

Transcribed Image Text:## Python Program to Calculate Sum and Average of Numbers
This Python script is designed to continuously prompt the user for numbers, calculate the sum of these numbers, and then determine their average.
### Source Code
```python
counter = 0
s = 0
number = input("please enter number: ")
while(number != ''):
s += float(number)
counter += 1
number = input("please enter number: ")
print("Sum of the number is : ", str(s))
if s > 0:
print("Average of the number is: ", str(s / counter))
```
### Explanation
1. **Initialization**:
- `counter` is initialized to 0. This variable is used to keep track of the number of inputs.
- `s` is initialized to 0. This variable is used to store the cumulative sum of the numbers.
2. **User Input**:
- The script begins by asking the user to input a number with `number = input("please enter number: ")`.
3. **Loop to Collect Numbers**:
- A while loop continues as long as the user provides an input (`while(number != ''):`).
- Inside the loop:
- The input number is converted to a float and added to `s`.
- The `counter` is incremented by 1.
- The script then prompts the user to enter another number.
4. **Calculating Sum**:
- Once the user stops providing input (by pressing Enter without typing anything), the loop exits.
- The script prints the sum of the entered numbers using `print("Sum of the number is : ", str(s))`.
5. **Calculating Average**:
- If the sum `s` is greater than 0, it calculates the average.
- This is done by dividing the sum `s` by the `counter` (number of inputs) and printing the result with `print("Average of the number is: ", str(s / counter))`.
### Usage
To use this script:
1. Run the script in a Python environment.
2. Enter as many numbers as you like, pressing Enter after each one.
3. When finished, simply press Enter without typing a number to see the total sum and the average of the numbers entered.
This script is a basic introduction to handling user input, loops, and conditional statements in Python, and demonstrates how to perform
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY