Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

It is one question(A+B+C) and have to be on single.py file. Only use turtle module not matplotlib!!!! Write a Python3 program to draw a pie

It is one question(A+B+C) and have to be on single.py file. Only use turtle module not matplotlib!!!!image text in transcribed

Write a Python3 program to draw a pie chart of n most frequent characters in a text file named Word.txt. n is the user input. A. Import Python module tkinter to create a window to collect n from the user along with 'proceed' and 'quit' buttons. When clicked on 'proceed' button the program should draw the chart. And when clicked on 'quit' the program should terminate. B. Have a module that calculates the probability of the letters in the text file named Word.txt and then import it to your main program. (You need to write a separate script, (.py) file to calculate the probabilities of each of the characters) The probabilities can be calculated as follows: Probabilityofthecharacter=frequenciesofallcharactersfrequencyofthecharacter where the frequency of the character is the number of occurrences of the character. You need to use a dictionary to keep track of the number of occurrences of the characters. C. Import turtle module of Python to draw the chart. - The area of each segment of the pie chart is proportional to the probability of the corresponding character as follows: Probabilityofthecharacter=2centralangleofsegment - Each segment of the pie chart has a different color. 1 - Each segment has a label (legend) showing the character along with its probability. - The last segment shows 'All other characters' and their cumulative probability. - All non-alphabetical characters should be considered as one character named 'nonalphabetical' (this includes all the symbols and whitespace characters too) - The program is not case-sensitive therefore all alphabetical characters need to be either converted to lowercase, or uppercase characters. The example below is the pie chart drawn using turtle module, showing n=3 most frequent characters, e, s, i, along with all other characters(non-alphabetical characters), with probabilities; 0.1182,0.0959,0.0857 and 0.7002 respectively. Probabilityofnon-alphabeticalcharacters=1Probabilityofe,s,i That is the probability of all other characters (non-alphabetical characters) is 1 minus the sum of n most frequent characters

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions