Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use Python Write a program that creates a dictionary from a vocabulary list (formatted in a file similar to vocablist.txt and myvocab.txt If the

Please use Pythonimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Write a program that creates a dictionary from a vocabulary list (formatted in a file similar to vocablist.txt and myvocab.txt If the user-entered file name does not exist, the program should catch the error and re-prompt for a file name. After the file is read in successfully, the program should use the "term" as the key and definition" as the value. The program should then ask the user if he/she would like to add additional terms and definitions, and how many if "Y" is the response. If the user enters a negative non-integer value, the program will prompt the user again for an integer value. The program should then prompt the user for as many terms and definitions as needed. The program should ask again if the user would like to add additional terms and definitions. Again, the program will ask "how many" if "Y" is the response. The program should loop between asking if the user would like to add additional terms and definitions, and how many, until the user types "N" for No. If a duplicate term (key) is entered, the program will notify the user that the term is already in the dictionary. It will ask if the user would like to update the definition BEFORE asking for a definition. The program should end by printing the list of terms and definitions before asking the user for a file name to save the new dictionary. DO NOT SAVE OVER THE ORIGINAL TEXT FILE UNLESS ENTERED BY THE USER. You may assume that the file will be a .txt file (with text separated by tabs "\t"). Below, you will find examples of what the program might look like, with red as the user input: term definition break Used to exit a for loop or a while loop. continue Used to skip the current block, and return to the "for" or "while" statement dictionary A mutable associative array (or dictionary) of key and value pairs. float An immutable floating point number. immutable Cannot be changed after its created. int An immutable integer of unlimited magnitude. pass Needed to create an empty code block set Unordered set, contains no duplicates string Can include numbers, letters, and various symbols and be enclosed by either double or single quotes while Executes a block of code as long as its condition is true. term definition stem produce a stem and leaf plot abline draw a straight line points draw points on the current plot print print output stripchart produce a strip chart sunflowerplot produce a sunflower plot qoline add a line to a QQ plot cor calculate the Pearson correlation coefficient Write a program that creates a dictionary from a vocabulary list (formatted in a file similar to vocablist.txt and myvocab.txt If the user-entered file name does not exist, the program should catch the error and re-prompt for a file name. After the file is read in successfully, the program should use the "term" as the key and definition" as the value. The program should then ask the user if he/she would like to add additional terms and definitions, and how many if "Y" is the response. If the user enters a negative non-integer value, the program will prompt the user again for an integer value. The program should then prompt the user for as many terms and definitions as needed. The program should ask again if the user would like to add additional terms and definitions. Again, the program will ask "how many" if "Y" is the response. The program should loop between asking if the user would like to add additional terms and definitions, and how many, until the user types "N" for No. If a duplicate term (key) is entered, the program will notify the user that the term is already in the dictionary. It will ask if the user would like to update the definition BEFORE asking for a definition. The program should end by printing the list of terms and definitions before asking the user for a file name to save the new dictionary. DO NOT SAVE OVER THE ORIGINAL TEXT FILE UNLESS ENTERED BY THE USER. You may assume that the file will be a .txt file (with text separated by tabs "\t"). Below, you will find examples of what the program might look like, with red as the user input: ##Example 1 Please enter a file name: vocablist.txt There are 10 terms in this vocabulary list. Would you like to add more terms (Y/N)? Y How many would you like to add? 2 Term #1: IDLE Definition #1: Integrated development environment Term #2: if Definition #2: Conditionally executes a block of code Would you like to add more terms (Y/N)? Y How many would you like to add? O Would you like to add more terms (Y/N)? N There are 12 terms in the new vocabulary list. break - Used to exit a for loop or a while loop. continue - Used to skip the current block, and return to the "for" or "while" statement dictionary - A mutable associative array (or dictionary) of key and value pairs. float - An immutable floating point number. immutable - Cannot be changed after its created. int - An immutable integer of unlimited magnitude. pass - Needed to create an empty code block set - Unordered set, contains no duplicates string - Can include numbers, letters, and various symbols and be enclosed by either double or single quotes while - Executes a block of code as long as its condition is true. IDLE - Integrated development environment if - Conditionally executes a block of code What would you like to save the file as? vocablist2.txt ##Example 2 Please enter a file name: vocablist.txt There are 10 terms in this vocabulary list. Would you like to add more (Y/N)? Y How many would you like to add? 1.5 Error. Please enter an integer. How many would you like to add? -4 Error. Please enter a positive number. How many would you like to add? one Error. Please enter an integer. How many would you like to add? 2 Term #1: break Warning! This term is already in the vocabulary list. Update definition (Y/N)? N Term #2: if Definition #2: Conditionally executes a block of code Would you like to add more terms (Y/N)? Y How many would you like to add? O Would you like to add more terms (Y/N)? N There are 11 terms in the new vocabulary list. break - Used to exit a for loop or a while loop. continue - Used to skip the current block, and return to the "for" or "while" statement dictionary - A mutable associative array (or dictionary) of key and value pairs. float - An immutable floating point number. immutable - Cannot be changed after its created. int - An immutable integer of unlimited magnitude. pass - Needed to create an empty code block set - Unordered set, contains no duplicates string - Can include numbers, letters, and various symbols and be enclosed by either double or single quotes while - Executes a block of code as long as its condition is true. if - Conditionally executes a block of code What would you like to save the file as? vocabulary.txt ##Example 3 Please enter a file name: vocablist.txt There are 10 terms in this vocabulary list. Would you like to add more (Y/N)? Y How many would you like to add? 1.5 Error. Please enter an integer. How many would you like to add? -4 Error. Please enter a positive number. How many would you like to add? one Error. Please enter an integer. How many would you like to add? 2 Term #1: break Warning! This term is already in the vocabulary list. Update definition (Y/N)? Y Definition #1: Used to exit a loop Term #2: if Definition #2: Conditionally executes a block of code Would you like to add more terms (Y/N)? Y How many would you like to add? O Would you like to add more terms (Y/N)? N There are 11 terms in the new vocabulary list. break - Used to exit a loop continue - Used to skip the current block, and return to the "for" or "while" statement dictionary - A mutable associative array (or dictionary) of key and value pairs. float - An immutable floating point number. immutable - Cannot be changed after its created. int - An immutable integer of unlimited magnitude. pass - Needed to create an empty code block set Unordered set, contains no duplicates string - Can include numbers, letters, and various symbols and be enclosed by either double or single quotes while - Executes a block of code as long as its condition is true. if - Conditionally executes a block of code What would you like to save the file as? mynewvocablist.txt

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

Recommended Textbook for

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago