Question: Draw a flowchart for this Python code. def main ( ) : # declare the variables averagevalue = 0 modevalue = 0 maxtomin = [

Draw a flowchart for this Python code.
def main() :
# declare the variables
averagevalue =0
modevalue =0
maxtomin =[]
specificValue =0
totalvalue =0
values =[0]*10
values = getvalues(values)
totalvalue = getTotal(totalvalue,values)
averagevalue = getAverage(totalvalue,averagevalue)
modevalue = getMode(modevalue,values)
specificValue = getspecific(specificValue, values)
maxtomin = sortMaxTomin(maxtomin,values)
displayInfo(averagevalue,modevalue,maxtomin,specificValue)
# the getValues function
def getvalues(values) :
counter =0
while counter <10 :
values[counter]= int(input("Enter a value: "))
counter +=1
return values
# the getTotal function
def getTotal(totalvalue,values) :
counter =0
while counter <10 :
totalvalue += values[counter]
counter +=1
return totalvalue
# the getAverage function
def getAverage(totalvalue,averagevalue):
averagevalue = totalvalue /10
return averagevalue
# the getMode function
def getMode(modevalue,values):
#mode of numbers
# number which occurs most time
dict ={}
counter =0
while counter <10 :
if values[counter] not in dict.keys():
dict [ values[counter]]=1
else :
dict[ values[counter]]+=1
counter+=1
modevalue =0
count =0
for val,cnt in dict.items():
if cnt > count:
modevalue = val
count = cnt
return modevalue
# the getsortmaxmin function
def sortMaxTomin(maxtomin , values) :
# sort the list using insertion sort
maxtomin = values
counter =1
while counter <10 :
temp = maxtomin[counter]
j = counter -1
while j>=0 and temp > maxtomin[j]:
maxtomin[j+1]= maxtomin[j]
j -=1
maxtomin[j+1]= temp
counter +=1
return maxtomin
# the getspecific function
def getspecific (specificvalue,values) :
# this function which search the value in original list not sorted list
# return the index of the value to be search
# if not present return -1
val = int(input("Search the value: "))
specificvalue =-1
counter =0
while counter <10 :
if values[counter]== val:
specificvalue = counter
break
counter +=1
return specificvalue
# the displayInfo function
def displayInfo(averageValue,modeValue , maxtomin , specificValue ) :
print("The average is: ", averageValue)
print("The mode is: ", modeValue)
print("The numbers from largest to smallest are: ",maxtomin)
print("The specific value is exist at index: ",specificValue)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!