Your program should be made of this following steps: Step 1: Create a list of user actions, consisting of five (5) actions. The five actions will be stored as five strings "add", "remove", "count", "display", "quit", within the list. Step 2: Create a new variable as a dictionary to be used. This dictionary will work as a database and will be used throughout the code. Step 3: Ask the user for an action to do. The expectation is that the user-selected action will be a single word, with all characters in lowercase. Once you run your program, the questions for the user-selected actions should be formatted as follows: What operation would you like to do: quit, add, remove, count, or display: I Step 4: Now, create a loop that works until the user decides to quit (aka, user-selected action selected matches "quit"). any of Step 4a (add operation): Check if the user-selected action, entered in step 3, matches the words defined in step 1. If it does not, show an output saying this is not a valid option. It should show: This is not a valid option, please try again Step 4b: Check if the user-selected action indicates adding NBA championship information (aka, user-selected action matches "add"). If it is, request the user to add a team name. Please enter a team name: Step 4c-a: If the team name is not in the dictionary, ask the user which year this team won the championship (don't worry! You don't actually have to know this!!). You can expect only one year as user input. What year did the team_name win the NBA championship: Step 4c-b: Create a new list with the year this team has won. Now, store the values in the dictionary, using team name as key and list of winning year as value in the dictionary. Step 4c-c: If the team name was already in the dictionary (due to entry in a previous code run), ask the user which year this team won the championship additionally. Again, You can expect only one year as user input. What additional year did the team_name win the NBA championship: Step 4c-d: Now, add this new year, using the team name as key in the dictionary. (hint: Think of a way to add values to an existing list?!) Step 4c-e: Irrespective of how the team information was added, print the action in the console. team_name was added to the dictionary Step 4d-a (remove operation): Check if the user-selected action indicates removing NBA championship information (aka, user-selected action matches "remove"). If it is, request the user to add a team name, use the same prompt as step 4b. Also, print the confirmation of removal action in the console. team_name was removed from the dictionary Step 4d-b: If the team name was already in the dictionary (due to entry in a previous code run), remove the entry from the dictionary. If the name is not in the dictionary, print an error report. This team is not valid, please try again Step 4e (display option): Check if the user-selected action indicates displaying NBA championship information (aka, user-selected action matches "display"). If it is, print the dictionary. Step 4f (count option): Check if the user-selected action indicates counting teams of NBA championship information (aka, user-selected action matches "count"). If it is, report the count of teams in the dictionary. 1 teams have won the NBA championship Step 4g: Complete the loop by asking for user action input again (similar to step 3). This input initiates the whole set of step 4 again. Overall note: This input process is case-sensitive, meaning, it does differentiate between lowercase letters, uppercase letters, and symbols.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

How will this project be solved in Python? Thanks.

There are example outputs in the picture.

Ch.9 Dictionaries
The theme of this activity is to learn the use of Dictionaries in Python. The goal of this activity
is to create a database of NBA champion teams over years, stored in a Python Dictionary.
Additionally, you will create five (5) user actions that utilise the Dictionary and print the
outcomes. Point to note, all the user-selected actions as input and output are case-sensitive.
Be sure to create a header comment with the title of this program, your name, the current
date, and a short summary about the purpose of the program (in your own words).
Your program should be made of this following steps:
Step 1: Create a list of user actions, consisting of five (5) actions. The five actions will be
stored as five strings "add", "remove", "count", "display", "quit", within the list.
Step 2: Create a new variable as a dictionary to be used. This dictionary will work as a
database and will be used throughout the code.
Step 3: Ask the user for an action to do. The expectation is that the user-selected action will
be a single word, with all characters in lowercase. Once you run your program, the questions
for the user-selected actions should be formatted as follows:
What operation would you like to do: quit, add, remove, count, or display:
Step 4: Now, create a loop that works until the user decides to quit (aka, user-selected action
selected matches "quit").
Step 4a (add operation): Check if the user-selected action, entered in step 3, matches any of
the words defined in step 1. If it does not, show an output saying this is not a valid option. It
should show:
This is not a valid option, please try again.
Step 4b: Check if the user-selected action indicates adding NBA championship information
(aka, user-selected action matches "add"). If it is, request the user to add a team name.
Please enter a team name:
Step 4c-a: If the team name is not in the dictionary, ask the user which year this team won the
championship (don't worry! You don't actually have to know this!!). You can expect only one
year as user input.
What year did the team_name win the NBA championship:
Step 4c-b: Create a new list with the year this team has won. Now, store the values in the
dictionary, using team name as key and list of winning year as value in the dictionary.
Step 4c-c: If the team name was already in the dictionary (due to entry in a previous code
run), ask the user which year this team won the championship additionally. Again, You can
expect only one year as user input.
What additional year did the team_name win the NBA championship:
Step 4c-d: Now, add this new year, using the team name as key in the dictionary. (hint: Think
of a way to add values to an existing list?!)
Step 4c-e: Irrespective of how the team information was added, print the action in the
console.
team_name was added to the dictionary
Step 4d-a (remove operation): Check if the user-selected action indicates removing NBA
championship information (aka, user-selected action matches "remove"). If it is, request the
user to add a team name, use the same prompt as step 4b. Also, print the confirmation of
removal action in the console.
team_name was removed from the dictionary
Step 4d-b: If the team name was already in the dictionary (due to entry in a previous code
run), remove the entry from the dictionary. If the name is not in the dictionary, print an error
report.
This team is not valid, please try again
Step 4e (display option): Check if the user-selected action indicates displaying NBA
championship information (aka, user-selected action matches "display"). If it is, print the
dictionary.
Step 4f (count option): Check if the user-selected action indicates counting teams of NBA
championship information (aka, user-selected action matches "count"). If it is, report the
count of teams in the dictionary.
1 teams have won the NBA championship
Step 4g: Complete the loop by asking for user action input again (similar to step 3). This
input initiates the whole set of step 4 again.
Overall note: This input process is case-sensitive, meaning, it does differentiate between
lowercase letters, uppercase letters, and symbols.
Example Test Case 1:
What operation would you like to do: quit, add, remove, count, or display: add
Please enter a team name: bucks
What year did the bucks win the NBA championship: 2021
bucks was added to the dictionary
What operation would you like to do: quit, add, remove, count, or display: display
{'bucks': ['2021']}
What operation would you like to do: quit, add, remove, count, or display: quit
Example Test Case 2:
What operation would you like to do: quit, add, remove, count, or display: add
Please enter a team name: bucks
What year did the bucks win the NBA championship: 2021
bucks was added to the dictionary
What operation would you like to do: quit, add, remove, count, or display: add.
Please enter a team name: lakers
What year did the lakers win the NBA championship: 2020
lakers was added to the dictionary
What operation would you like to do: quit, add, remove, count, or display: add
Please enter a team name: raptors
What year did the raptors win the NBA championship: 2019
raptors was added to the dictionary
What operation would you like to do: quit, add, remove, count, or display: warriors
This is not a valid option, please try again
What operation would you like to do: quit, add, remove, count, or display: 2018
This is not a valid option, please try again
What operation would you like to do: quit, add, remove, count, or display: add
Please enter a team name: warriors
What year did the warriors win the NBA championship: 2017
warriors was added to the dictionary
What operation would you like to do: quit, add, remove, count, or display: add
Please enter a team name: warriors
What additional year did the warriors win the NBA championship: 2015
warriors was added to the dictionary
What operation would you like to do: quit, add, remove, count, or display: count
4 teams have won the NBA championship
What operation would you like to do: quit, add, remove, count, or display: display
{'bucks': ['2021'], 'lakers': ['2020'], 'raptors': ['2019'], 'warriors': ['2017', '2015']}
What operation would you like to do: quit, add, remove, count, or display: remove
Please enter a team name: raptors
raptors was removed from the dictionary
What operation would you like to do: quit, add, remove, count, or display: remove
Please enter a team name: random
This team is not valid, please try again.
What operation would you like to do: quit, add,
3 teams have won the NBA championship
remove, count, or display: count
What operation would you like to do: quit, add, remove, count, or display: display
{'bucks': [¹2021'], 'lakers': ['2020'], 'warriors': ['2017', '2015']}
What operation would you like to do: quit, add, remove, count, or display: quit
Transcribed Image Text:Ch.9 Dictionaries The theme of this activity is to learn the use of Dictionaries in Python. The goal of this activity is to create a database of NBA champion teams over years, stored in a Python Dictionary. Additionally, you will create five (5) user actions that utilise the Dictionary and print the outcomes. Point to note, all the user-selected actions as input and output are case-sensitive. Be sure to create a header comment with the title of this program, your name, the current date, and a short summary about the purpose of the program (in your own words). Your program should be made of this following steps: Step 1: Create a list of user actions, consisting of five (5) actions. The five actions will be stored as five strings "add", "remove", "count", "display", "quit", within the list. Step 2: Create a new variable as a dictionary to be used. This dictionary will work as a database and will be used throughout the code. Step 3: Ask the user for an action to do. The expectation is that the user-selected action will be a single word, with all characters in lowercase. Once you run your program, the questions for the user-selected actions should be formatted as follows: What operation would you like to do: quit, add, remove, count, or display: Step 4: Now, create a loop that works until the user decides to quit (aka, user-selected action selected matches "quit"). Step 4a (add operation): Check if the user-selected action, entered in step 3, matches any of the words defined in step 1. If it does not, show an output saying this is not a valid option. It should show: This is not a valid option, please try again. Step 4b: Check if the user-selected action indicates adding NBA championship information (aka, user-selected action matches "add"). If it is, request the user to add a team name. Please enter a team name: Step 4c-a: If the team name is not in the dictionary, ask the user which year this team won the championship (don't worry! You don't actually have to know this!!). You can expect only one year as user input. What year did the team_name win the NBA championship: Step 4c-b: Create a new list with the year this team has won. Now, store the values in the dictionary, using team name as key and list of winning year as value in the dictionary. Step 4c-c: If the team name was already in the dictionary (due to entry in a previous code run), ask the user which year this team won the championship additionally. Again, You can expect only one year as user input. What additional year did the team_name win the NBA championship: Step 4c-d: Now, add this new year, using the team name as key in the dictionary. (hint: Think of a way to add values to an existing list?!) Step 4c-e: Irrespective of how the team information was added, print the action in the console. team_name was added to the dictionary Step 4d-a (remove operation): Check if the user-selected action indicates removing NBA championship information (aka, user-selected action matches "remove"). If it is, request the user to add a team name, use the same prompt as step 4b. Also, print the confirmation of removal action in the console. team_name was removed from the dictionary Step 4d-b: If the team name was already in the dictionary (due to entry in a previous code run), remove the entry from the dictionary. If the name is not in the dictionary, print an error report. This team is not valid, please try again Step 4e (display option): Check if the user-selected action indicates displaying NBA championship information (aka, user-selected action matches "display"). If it is, print the dictionary. Step 4f (count option): Check if the user-selected action indicates counting teams of NBA championship information (aka, user-selected action matches "count"). If it is, report the count of teams in the dictionary. 1 teams have won the NBA championship Step 4g: Complete the loop by asking for user action input again (similar to step 3). This input initiates the whole set of step 4 again. Overall note: This input process is case-sensitive, meaning, it does differentiate between lowercase letters, uppercase letters, and symbols. Example Test Case 1: What operation would you like to do: quit, add, remove, count, or display: add Please enter a team name: bucks What year did the bucks win the NBA championship: 2021 bucks was added to the dictionary What operation would you like to do: quit, add, remove, count, or display: display {'bucks': ['2021']} What operation would you like to do: quit, add, remove, count, or display: quit Example Test Case 2: What operation would you like to do: quit, add, remove, count, or display: add Please enter a team name: bucks What year did the bucks win the NBA championship: 2021 bucks was added to the dictionary What operation would you like to do: quit, add, remove, count, or display: add. Please enter a team name: lakers What year did the lakers win the NBA championship: 2020 lakers was added to the dictionary What operation would you like to do: quit, add, remove, count, or display: add Please enter a team name: raptors What year did the raptors win the NBA championship: 2019 raptors was added to the dictionary What operation would you like to do: quit, add, remove, count, or display: warriors This is not a valid option, please try again What operation would you like to do: quit, add, remove, count, or display: 2018 This is not a valid option, please try again What operation would you like to do: quit, add, remove, count, or display: add Please enter a team name: warriors What year did the warriors win the NBA championship: 2017 warriors was added to the dictionary What operation would you like to do: quit, add, remove, count, or display: add Please enter a team name: warriors What additional year did the warriors win the NBA championship: 2015 warriors was added to the dictionary What operation would you like to do: quit, add, remove, count, or display: count 4 teams have won the NBA championship What operation would you like to do: quit, add, remove, count, or display: display {'bucks': ['2021'], 'lakers': ['2020'], 'raptors': ['2019'], 'warriors': ['2017', '2015']} What operation would you like to do: quit, add, remove, count, or display: remove Please enter a team name: raptors raptors was removed from the dictionary What operation would you like to do: quit, add, remove, count, or display: remove Please enter a team name: random This team is not valid, please try again. What operation would you like to do: quit, add, 3 teams have won the NBA championship remove, count, or display: count What operation would you like to do: quit, add, remove, count, or display: display {'bucks': [¹2021'], 'lakers': ['2020'], 'warriors': ['2017', '2015']} What operation would you like to do: quit, add, remove, count, or display: quit
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Binary Search Algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education