Answer:
def calculateAverage(sum, count):
#defining variable
avg=0
try:
avg=sum/count
except ZeroDivisionError:
print("Average can'nt be calculated for 0 numbers");
return avg
#variables
count=0
sum=0
av=0
#infinite loop
while True:
try:
#getting the user input and checking the value
val=(int)(input("Enter a positive number to toal or a negative number to calculate the average: "))
if (val<0):
av=calculateAverage(sum,count)
break;
else:
sum=sum+val
count += 1
except ValueError:
print("Entered value is incorrect");
continue
#printing the average of the numbers
print("The sum is "+str(sum))
print("The Average is "+str(av))
Step-by-step explanation: