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
modevalue
maxtomin
specificValue
totalvalue
values
values getvaluesvalues
totalvalue getTotaltotalvaluevalues
averagevalue getAveragetotalvalueaveragevalue
modevalue getModemodevaluevalues
specificValue getspecificspecificValue values
maxtomin sortMaxTominmaxtominvalues
displayInfoaveragevaluemodevalue,maxtomin,specificValue
# the getValues function
def getvaluesvalues :
counter
while counter :
valuescounter intinputEnter a value:
counter
return values
# the getTotal function
def getTotaltotalvaluevalues :
counter
while counter :
totalvalue valuescounter
counter
return totalvalue
# the getAverage function
def getAveragetotalvalueaveragevalue:
averagevalue totalvalue
return averagevalue
# the getMode function
def getModemodevaluevalues:
#mode of numbers
# number which occurs most time
dict
counter
while counter :
if valuescounter not in dict.keys:
dict valuescounter
else :
dict valuescounter
counter
modevalue
count
for val,cnt in dict.items:
if cnt count:
modevalue val
count cnt
return modevalue
# the getsortmaxmin function
def sortMaxTominmaxtomin values :
# sort the list using insertion sort
maxtomin values
counter
while counter :
temp maxtomincounter
j counter
while j and temp maxtominj:
maxtominj maxtominj
j
maxtominj temp
counter
return maxtomin
# the getspecific function
def getspecific specificvaluevalues :
# 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
val intinputSearch the value:
specificvalue
counter
while counter :
if valuescounter val:
specificvalue counter
break
counter
return specificvalue
# the displayInfo function
def displayInfoaverageValuemodeValue maxtomin specificValue :
printThe average is: averageValue
printThe mode is: modeValue
printThe numbers from largest to smallest are: maxtomin
printThe 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
