lab8.py - CS 177 lab8.py Lindsey Kumfer 0027660682...

This preview shows page 1 - 2 out of 2 pages.

# # CS 177 - lab8.py # Lindsey Kumfer 0027660682 # Following coding standards and guidelines # This program reads a file, and analyzes the characters to produce a # graphics window with the statistics. # # import graphics library from graphics import * # define a stats function def stats(filename=input()): # accept the filename to be analyzed as a String argument # create a 400x250 graphics window, "Character Analysis", lightgrey win = GraphWin("Character Analysis",400,250) win.setBackground('lightgrey') # call the readData() assigning returned variables readdata = readData(filename) # call the calc() assigning the new dictionary dictionary = calc(readdata) # using the entries in Dictionary, calculate the character statistics characters = 0 #total number of occurences each entry in the dictionary for key in dictionary: characters += dictionary[key] vowels = 0 #total of the occurences for each of the vowels (entries within the dictionary) vowel_list = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"] for key,value in dictionary.items(): if key in vowel_list: vowels += value

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture