Description
Q1. Popular Programming Languages (10 points)
Ask user to enter a student name and the languages (case-insensitive) that student prefers separated by comma.
User will enter ‘done’ when all students’ information has been entered.
After that, the program will display all the programming languages sorted in descending order of popularity.
Q2. Synonyms Dictionary (15 points)
The following contains a list of synonyms for 15 keywords (5 verbs, 5 nouns, 5 adjectives). Feel free to use your own set of keywords and synonyms.In Notepad or another text editing software, copy and paste the text above into the file and save the file as synonyms.txt in the same folder as your Jupyter notebook file.
Write a script that will read each keyword (key) and its synonyms (value) and store them in a synonyms dictionary.
Q3. Membership Manager (20 points) – List of Dictionaries
Write a program to manage Cost Plus membership list.
Assume that the names, phone numbers, membership type, total purchase amount in 2022, total cash back amount in 2022 of all members are stored in the text file members.txt
Part of the file is as follows (however, as a programmer, you do not know the exact number of members in this text file):
Judy Langley,301-141-1902,Gold,12398.09,190.23
Fred Morgan,301-215-2972,Silver,23098.01,90.88
Mike Nixon,301-903-3413,Gold,8374.47,87.03
Herbert Norton,301-220-4444,Silver,2907.82,32.52
Carol Preiss,301-895-2355,Gold,45971.23,280.78
Wendy Brown,301-987-2512,Silver,35070.55,118.72
In Notepad or another text editing software, copy and paste the text above into the file and save the file as members.txt in the same folder as your Jupyter notebook file
The code in the main function has been written for you (copy and paste the code below into your Jupyter notebook file. It will show the menu choices to the user and ask the user to choose an option. It will then call the appropriate function based on the option selected. It will continue asking for user’s choice until 7 is entered. You will complete each function as indicated in the comments.
Q4.
For question 3 above, add another menu option that allows the user to delete a member’s information. The program will show a list of all members’ names and prompt the user to enter the name to delete. It will then delete that specific member and his/her associated information from the list of tuples based on name. If the member is deleted, show “Member deleted”. Otherwise, if the member is not found, show a message “The member is not found. No change was made.”
Unformatted Attachment Preview
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
Instructions:
–
Please include comments (single line and multiline comments as necessary)
Test your programs thoroughly to ensure they execute and produce the correct outputs
Develop the programs in Jupyter notebook and save solutions to all questions in one .ipynb file. Submit
this .ipynb file on Canvas
Q1. Popular Programming Languages (10 points)
Ask user to enter a student name and the languages (case-insensitive) that student prefers separated by comma.
User will enter ‘done’ when all students’ information has been entered.
After that, the program will display all the programming languages sorted in descending order of popularity.
Hint: Refer to the word count practice question (slide 24 of Dictionaries powerpoint)
Sample output:
1
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
Q2. Synonyms Dictionary (15 points)
The following contains a list of synonyms for 15 keywords (5 verbs, 5 nouns, 5 adjectives). Feel free to use your
own set of keywords and synonyms.
find,learn,discover,notice
know,realize,understand,recognize
think,believe,suppose,expect
see,understand,realize,recognize
organize,assemble,arrange,sort out
world,earth,planet,globe
place,site,location,spot
problem,difficulty,trouble,issue
task,duty,job,mission
health,fitness,strength,well-being
good,fine,satisfactory,superior
important,main,key,crucial
popular,desired,liked,favored
difficult,tough,challenging,demanding
simple,easy,effortless,not difficult
In Notepad or another text editing software, copy and paste the text above into the file and save the file as
synonyms.txt in the same folder as your Jupyter notebook file.
Write a script that will read each keyword (key) and its synonyms (value) and store them in a synonyms
dictionary.
The script will also offer the following options:
•
•
•
•
•
Option 1: Display the dictionary’s contents as a table (see sample output below)
Option 2: Display a list of all the keywords (all the keys in the dictionary). Then ask the user to enter a
sentence that contains at least one of the words listed and rephrase the sentence with one synonym of the
word
Option 3: Ask the user to add a keyword and its 3 synonyms, add this key-value pair to the dictionary,
then add this information to the text file
Option 4: Refresh (reread the information from the file)
Option 5: Quit
2
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
Use the following code as a template:
def readData():
#add your code
def rewriteSentence():
#add your code
def displayContent():
#add your code
def addWord():
#add your code
def main():
import random
syno = {}
#dictionary storing each word and its synonyms
readData() #read all the information and stored them in syno
#input prompt
menu_string = ‘Please select an option: n1 – Diplay all words and synonymsn’
menu_string += ‘2 – Rewrite a sentence using a synonym’
menu_string += ‘n3 – Add a keyword and its synonymsn4 – Refresh data’
menu_string += ‘n5 – Quitnn’
choice = int(input(menu_string))
#menu choice actions
while choice != 5:
if choice == 1:
displayContent()
elif choice== 2:
rewriteSentence()
elif choice == 3:
addWord()
elif choice == 4:
readData()
choice = int(input(menu_string))
main()
#get the next selection from user
#entry point of the program
Fill in the code for readData, rewriteSentence, displayContent, and addWord functions.
3
MIS 532 – Fall 2023
Assignment 4
Outputs of the program:
4
Due: 11:59PM November 10, 2023
MIS 532 – Fall 2023
Assignment 4
5
Due: 11:59PM November 10, 2023
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
Q3. Membership Manager (20 points) – List of Dictionaries
Write a program to manage Cost Plus membership list.
Assume that the names, phone numbers, membership type, total purchase amount in 2022, total cash back amount
in 2022 of all members are stored in the text file members.txt
Part of the file is as follows (however, as a programmer, you do not know the exact number of members in this
text file):
Judy Langley,301-141-1902,Gold,12398.09,190.23
Fred Morgan,301-215-2972,Silver,23098.01,90.88
Mike Nixon,301-903-3413,Gold,8374.47,87.03
Herbert Norton,301-220-4444,Silver,2907.82,32.52
Carol Preiss,301-895-2355,Gold,45971.23,280.78
Wendy Brown,301-987-2512,Silver,35070.55,118.72
a. In Notepad or another text editing software, copy and paste the text above into the file and save the
file as members.txt in the same folder as your Jupyter notebook file
b. The code in the main function has been written for you (copy and paste the code below into your
Jupyter notebook file. It will show the menu choices to the user and ask the user to choose an option.
It will then call the appropriate function based on the option selected. It will continue asking for
user’s choice until 7 is entered. You will complete each function as indicated in the comments.
def readData():
#read all data from members.txt and store in a list of
#tuples members_list
#your code goes here
def displayAll(): #display all members’ information
#your code goes here
def displayByType(): #display members’ information for a membership type
#your code goes here
def displayPurchaseStats(): #display all purchase stats
#your code goes here
def displayCashbackStats():
#your code goes here
#display cashback stats
def findMember():
#your code goes here
6
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
def addMember():
#your code goes here
def saveData():
#your code goes here
def main():
readData()
#calling this function to load data from file to list
menu = ‘nnSelect a menu choice below: ‘
menu += ‘n1. Display all membersn2. Display by membership type’
menu += ‘n3. Display purchase amount statistics’
menu += ‘n4. Display cashback amount statistics’
menu += ‘n5. Add new member n6. Save all data n7. Quitnn’
choice = int(input(menu))
#menu choice actions
while choice != 7:
if choice == 1:
displayAll()
elif choice== 2:
displayByType()
elif choice == 3:
displayPurchaseStats()
elif choice == 4:
displayCashbackStats()
elif choice == 5:
addMember()
elif choice == 6:
saveData()
choice = int(input(menu))
#get the next selection from user
import random
from operator import itemgetter
members_list = []
main()
7
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
c. Define the function readData that will read all the information from this text file and store it in a list
of tuples.
d. Complete displayAll function – Display all members’ information in a table format (see output
below).
e. Complete displayByType function – Display only the information about those members of a
specific membership type that the user selected.
f.
Complete displayPurchaseStats function – Compute and display the total amount, maximum,
minimum, and average amount of all members’ purchase amount in 2022. Display a simplified
horizontal bar chart of these amounts together with the member name and purchase amount in 2022
(see slide 33 of Chapter 5 Lists powerpoint)
8
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
g. Complete displayCashbackStats function – Compute and display the total amount, maximum,
minimum, and average amount of all members’ cash back amount in 2022. Display a simplified
horizontal bar chart of these amounts (see slide 33 of Chapter 5 Lists powerpoint)
9
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
h. Complete addMember function – Add a new member and all the associated information (purchase
amount is assumed to be 0, cashback amount is assumed to be 0 – no need to ask the user to enter
these amounts), then display “Member added”. After this, when you select 1 to view all members
again, you should be able to see the new member’s information.
i.
Complete saveData function – Save all information in the current list of tuples to the text file
members.txt, overwriting the previous content. Make sure all the data about a member are separated
by comma (same format as the original text file).
For example, after the step above (adding “Jim Jordan” to the list), the content of the text file should
look like:
10
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
Extra Credit – Optional (5 points)
For question 3 above, add another menu option that allows the user to delete a member’s information. The
program will show a list of all members’ names and prompt the user to enter the name to delete. It will then delete
that specific member and his/her associated information from the list of tuples based on name. If the member is
deleted, show “Member deleted”. Otherwise, if the member is not found, show a message “The member is not
found. No change was made.”
11
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
Instructions:
–
Please include comments (single line and multiline comments as necessary)
Test your programs thoroughly to ensure they execute and produce the correct outputs
Develop the programs in Jupyter notebook and save solutions to all questions in one .ipynb file. Submit
this .ipynb file on Canvas
Q1. Popular Programming Languages (10 points)
Ask user to enter a student name and the languages (case-insensitive) that student prefers separated by comma.
User will enter ‘done’ when all students’ information has been entered.
After that, the program will display all the programming languages sorted in descending order of popularity.
Hint: Refer to the word count practice question (slide 24 of Dictionaries powerpoint)
Sample output:
1
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
Q2. Synonyms Dictionary (15 points)
The following contains a list of synonyms for 15 keywords (5 verbs, 5 nouns, 5 adjectives). Feel free to use your
own set of keywords and synonyms.
find,learn,discover,notice
know,realize,understand,recognize
think,believe,suppose,expect
see,understand,realize,recognize
organize,assemble,arrange,sort out
world,earth,planet,globe
place,site,location,spot
problem,difficulty,trouble,issue
task,duty,job,mission
health,fitness,strength,well-being
good,fine,satisfactory,superior
important,main,key,crucial
popular,desired,liked,favored
difficult,tough,challenging,demanding
simple,easy,effortless,not difficult
In Notepad or another text editing software, copy and paste the text above into the file and save the file as
synonyms.txt in the same folder as your Jupyter notebook file.
Write a script that will read each keyword (key) and its synonyms (value) and store them in a synonyms
dictionary.
The script will also offer the following options:
•
•
•
•
•
Option 1: Display the dictionary’s contents as a table (see sample output below)
Option 2: Display a list of all the keywords (all the keys in the dictionary). Then ask the user to enter a
sentence that contains at least one of the words listed and rephrase the sentence with one synonym of the
word
Option 3: Ask the user to add a keyword and its 3 synonyms, add this key-value pair to the dictionary,
then add this information to the text file
Option 4: Refresh (reread the information from the file)
Option 5: Quit
2
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
Use the following code as a template:
def readData():
#add your code
def rewriteSentence():
#add your code
def displayContent():
#add your code
def addWord():
#add your code
def main():
import random
syno = {}
#dictionary storing each word and its synonyms
readData() #read all the information and stored them in syno
#input prompt
menu_string = ‘Please select an option: n1 – Diplay all words and synonymsn’
menu_string += ‘2 – Rewrite a sentence using a synonym’
menu_string += ‘n3 – Add a keyword and its synonymsn4 – Refresh data’
menu_string += ‘n5 – Quitnn’
choice = int(input(menu_string))
#menu choice actions
while choice != 5:
if choice == 1:
displayContent()
elif choice== 2:
rewriteSentence()
elif choice == 3:
addWord()
elif choice == 4:
readData()
choice = int(input(menu_string))
main()
#get the next selection from user
#entry point of the program
Fill in the code for readData, rewriteSentence, displayContent, and addWord functions.
3
MIS 532 – Fall 2023
Assignment 4
Outputs of the program:
4
Due: 11:59PM November 10, 2023
MIS 532 – Fall 2023
Assignment 4
5
Due: 11:59PM November 10, 2023
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
Q3. Membership Manager (20 points) – List of Dictionaries
Write a program to manage Cost Plus membership list.
Assume that the names, phone numbers, membership type, total purchase amount in 2022, total cash back amount
in 2022 of all members are stored in the text file members.txt
Part of the file is as follows (however, as a programmer, you do not know the exact number of members in this
text file):
Judy Langley,301-141-1902,Gold,12398.09,190.23
Fred Morgan,301-215-2972,Silver,23098.01,90.88
Mike Nixon,301-903-3413,Gold,8374.47,87.03
Herbert Norton,301-220-4444,Silver,2907.82,32.52
Carol Preiss,301-895-2355,Gold,45971.23,280.78
Wendy Brown,301-987-2512,Silver,35070.55,118.72
a. In Notepad or another text editing software, copy and paste the text above into the file and save the
file as members.txt in the same folder as your Jupyter notebook file
b. The code in the main function has been written for you (copy and paste the code below into your
Jupyter notebook file. It will show the menu choices to the user and ask the user to choose an option.
It will then call the appropriate function based on the option selected. It will continue asking for
user’s choice until 7 is entered. You will complete each function as indicated in the comments.
def readData():
#read all data from members.txt and store in a list of
#tuples members_list
#your code goes here
def displayAll(): #display all members’ information
#your code goes here
def displayByType(): #display members’ information for a membership type
#your code goes here
def displayPurchaseStats(): #display all purchase stats
#your code goes here
def displayCashbackStats():
#your code goes here
#display cashback stats
def findMember():
#your code goes here
6
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
def addMember():
#your code goes here
def saveData():
#your code goes here
def main():
readData()
#calling this function to load data from file to list
menu = ‘nnSelect a menu choice below: ‘
menu += ‘n1. Display all membersn2. Display by membership type’
menu += ‘n3. Display purchase amount statistics’
menu += ‘n4. Display cashback amount statistics’
menu += ‘n5. Add new member n6. Save all data n7. Quitnn’
choice = int(input(menu))
#menu choice actions
while choice != 7:
if choice == 1:
displayAll()
elif choice== 2:
displayByType()
elif choice == 3:
displayPurchaseStats()
elif choice == 4:
displayCashbackStats()
elif choice == 5:
addMember()
elif choice == 6:
saveData()
choice = int(input(menu))
#get the next selection from user
import random
from operator import itemgetter
members_list = []
main()
7
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
c. Define the function readData that will read all the information from this text file and store it in a list
of tuples.
d. Complete displayAll function – Display all members’ information in a table format (see output
below).
e. Complete displayByType function – Display only the information about those members of a
specific membership type that the user selected.
f.
Complete displayPurchaseStats function – Compute and display the total amount, maximum,
minimum, and average amount of all members’ purchase amount in 2022. Display a simplified
horizontal bar chart of these amounts together with the member name and purchase amount in 2022
(see slide 33 of Chapter 5 Lists powerpoint)
8
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
g. Complete displayCashbackStats function – Compute and display the total amount, maximum,
minimum, and average amount of all members’ cash back amount in 2022. Display a simplified
horizontal bar chart of these amounts (see slide 33 of Chapter 5 Lists powerpoint)
9
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
h. Complete addMember function – Add a new member and all the associated information (purchase
amount is assumed to be 0, cashback amount is assumed to be 0 – no need to ask the user to enter
these amounts), then display “Member added”. After this, when you select 1 to view all members
again, you should be able to see the new member’s information.
i.
Complete saveData function – Save all information in the current list of tuples to the text file
members.txt, overwriting the previous content. Make sure all the data about a member are separated
by comma (same format as the original text file).
For example, after the step above (adding “Jim Jordan” to the list), the content of the text file should
look like:
10
MIS 532 – Fall 2023
Assignment 4
Due: 11:59PM November 10, 2023
Extra Credit – Optional (5 points)
For question 3 above, add another menu option that allows the user to delete a member’s information. The
program will show a list of all members’ names and prompt the user to enter the name to delete. It will then delete
that specific member and his/her associated information from the list of tuples based on name. If the member is
deleted, show “Member deleted”. Otherwise, if the member is not found, show a message “The member is not
found. No change was made.”
11
Purchase answer to see full
attachment