Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I do not want -10 count in total value, but I want t0 enter -10 that calculate sum and average without -10 in total. I
I do not want -10 count in total value, but I want t0 enter -10 that calculate sum and average without -10 in total. I should run progrem like what on the second picture, but I do not know what I do wrong in the first one. Python. And also I want to enter -2 that only print You did not enter any number to average that break.
1.py - /Users/huanganqi/Desktop/1.py (3.7.0) Python 3.7.0 Shell def calculateAverage(sum, count) Python 3.7.0 (v3.7.8:1bf9cc5093, Jun 26 2018, 23:26:24) [Clang 6.0 Cclang-600.0.57)] on darwin Type "copyright", "credits" or "license" for more information if(nc-0): print( You did not enter any number to average") else: avg-sum/count return avg RESTART: /Users/huanganqi/Desktop/1.py Enter a positive number to total or a negative number to average 1e The sun of the number is 0 You did not enter any number to average The average of the numbers is None sum-0 count-0 n-0 while(n-8): RESTART: /Users/huanganqi/Desktop/1.py try: Enter a positive number to total or a negative number to average 1e n-int(input("Enter a positive number to total or a negative number to calculate average : ..)) | Enter a positive number to total or a negative number to average : 29 except ValueError: Enter a positive number to total or a negative number to average up That was no valid number. Try again Enter a positive number to total or a negative number to average 38 Enter a positive number to total or a negative number to average 40 Enter a positive number to total or a negative number to average-10 The sun of the number is 110 The average of the numbers is 18.333333333333332 print("What you entered was not a valid number. Try again.) count-count+ print(" The sun of the number is, sum) print The average of the numbers is :", calculateAverage(sum, count)) RESTART: /Users/huanganqi/Desktop/1.py Enter a positive number to total or a negative number to average-2 The sun of the number is 2 The average of the numbers is -2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started