print("Char count:\t\t", char_count) # Print alphanumeric characters count alphanum_count = sample.get_alphanum_count() print("Alphanum count:\t\t", alphanum_count) # Print average word length of sample object's data avg_word_len = sample.get_avg_word_len() print("Average word length:\t %.2f" % avg_word_len) # Print percentage of alphanumeric characters alphanum_percentage = sample.get_alphanum_percentage() print("Alphanum percentage:\t", round(alphanum_percentage, 2), "%") # Print blank line percentageo blank_count = sample.get_char_appearances('\n\n') lines_count = sample.get_char_appearances('\n') blank_percentage = blank_count / lines_count * 100 print("Blank line percentage:\t", round(blank_percentage, 2), "%") """ # Print letter frequencies ordered alphabetically dict = sample.get_letter_frequencies() for item in sorted(dict): print(item," - ", round((dict[item]/alphanum_count)*100, 2), "%") # Print letter frequencies ordered by popularity dict = sample.get_letter_frequencies() for item in sorted(dict.items(), key=lambda x: x[1], reverse=True): print(item[0]," - ", round(item[1]/alphanum_count*100, 2), "%")