Question: create a flowchart for the following program #!/bin/python import sys,csv import matplotlib.pyplot as plt CSV_FILE = address.csv def parse_csv(): csvFile = open(CSV_FILE) csvReader = csv.reader(csvFile,
create a flowchart for the following program
#!/bin/python import sys,csv import matplotlib.pyplot as plt
CSV_FILE = "address.csv"
def parse_csv(): csvFile = open(CSV_FILE) csvReader = csv.reader(csvFile, delimiter=',') #escaping first line next(csvReader) return csvReader
def totalChildren(): csvReader = parse_csv()
row_count = 0 totalTeeth = 0 children = 0 childrenNoLoss = 0 expend = 1 for row in csvReader : row_count = row_count+1 totalTeeth = totalTeeth + int(row[6]) if int(row[6]) == 0: children = children + 1 if int(row[6]) == 28: children = children + 1 if int(row[6]) == 1: expend = expend + int(row[6]) * 1 if int(row[6]) > 1: expend = expend + (int(row[6])-1) * 0.5
print ("Total children %s" %row_count) print ("Average teeth %s" %(totalTeeth/row_count))
print ("Number of children who have never lost a tooth %s" %children)
print ("Number of children who have lost all teeth %s" %children)
print ("Total expenditure %s" %expend)
def fileName(): filename = input("Enter filename to save data\t") csvReader = parse_csv() with open(filename,'w') as fd: for row in csvReader : if int(row[6]) == 0: fd.write(row[0]) print("Write complete")
def claimsState(): d = {} csvReader = parse_csv() for row in csvReader : if row[4] not in d : d[row[4]] = 1 else: d[row[4]] = d[row[4]]+1 tik_label = list(d.keys()) ht = list(d.values()) print (tik_label,ht) left = range(len(d)) plt.bar(left, height = ht, tick_label = tik_label) plt.show()
caseDict = {1:"totalChildren",2:"averageTeeth",3:"noLoss", 4:"allLoss", 5:"totalExp", 6:"fileName", 7:"claimsState"}
if __name__ == "__main__": print("Please enter your name") name = input() print("Please enter your student_id") studentId = input() print ("Welcome %s %s to %s" %(name, studentId, __file__)) print("Please select from options :") print("1. Total no of children") print("2. Average no of teeth claim over the year") print("3. No of children never lost a tooth") print("4. No of children lost all baby teeth") print("5. Total Expenditure of the year") print("6. Print list of children name who did not lose a tooth") print("7. Display claims per state") option = int(input())
globals()[caseDict[option]]()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
