We learned about the standard (i.e. not in place) ways to perform set operations. Using any of those as needed, create a small program to take the two dictionaries below and (1) finding all keys used in the two, and (2) finding which keys are in one dictionary but not the other. admissions_record 'first': 'Julia', 'last': 'Brown', 'id': 'AX012E4' student record = = 'admitted':'2020-05-15'} { " { 'first': 'Julia', 'last': 'Brown' " 'id': 'AX012E4', 'major': 'Data Science', 'minor': 'Mathematics' I 'advisor':'Franklin, Jack'}

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

Use Python to solve:

 

We learned about the standard (i.e. not in place) ways to perform set operations. Using any of
those as needed, create a small program to take the two dictionaries below and (1) finding all
keys used in the two, and (2) finding which keys are in one dictionary but not the other.
admissions record {
'first': 'Julia',
'last': 'Brown' /
'id': 'AX012E4',
admitted':'2020-05-15'}
1
student record
=
{
'first': 'Julia',
'last': 'Brown',
'id': 'AX012E4',
'major':'Data Science',
'minor': 'Mathematics',
'advisor':'Franklin, Jack'}
Transcribed Image Text:We learned about the standard (i.e. not in place) ways to perform set operations. Using any of those as needed, create a small program to take the two dictionaries below and (1) finding all keys used in the two, and (2) finding which keys are in one dictionary but not the other. admissions record { 'first': 'Julia', 'last': 'Brown' / 'id': 'AX012E4', admitted':'2020-05-15'} 1 student record = { 'first': 'Julia', 'last': 'Brown', 'id': 'AX012E4', 'major':'Data Science', 'minor': 'Mathematics', 'advisor':'Franklin, Jack'}
Expert Solution
Step 1: The Algorithm of the code:-

1. Input: Two dictionaries `admissions_record` and `student_record`.
2. Initialize an empty set `all_keys` to store all keys used in both dictionaries.
3. Initialize two empty sets `keys_in_admissions_record` and `keys_in_student_record` to store the keys specific to each dictionary.
4. Loop through the keys in `admissions_record`:
   - Add each key to the `keys_in_admissions_record` set.
   - Add each key to the `all_keys` set.
5. Loop through the keys in `student_record`:
   - Add each key to the `keys_in_student_record` set.
   - Add each key to the `all_keys` set.
6. Calculate the keys that are only in `admissions_record` by subtracting `keys_in_student_record` from `keys_in_admissions_record`. Store the result in `keys_only_in_admissions`.
7. Calculate the keys that are only in `student_record` by subtracting `keys_in_admissions_record` from `keys_in_student_record`. Store the result in `keys_only_in_student`.
8. Print the following results:
   - "All keys used in both dictionaries:" followed by the `all_keys` set.
   - "Keys only in admissions_record:" followed by the `keys_only_in_admissions` set.
   - "Keys only in student_record:" followed by the `keys_only_in_student` set.
9. End.

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Mergesort
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.
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