python: answer in one line of code if possible, please def traditions_dict(adict):     """     Question 6     Given a dictionary that maps a person to a list of their favorite     GT traditions, return a dictionary with the value being     the list sorted by the last letter of each tradition. If two     traditions have the same last letter, sort by the first letter.     HINT: This will require the use of lambda functions     Args:         adict (dict)     Returns:         dict     >>> traditions_dict({"Jacob": ["The Horse", "Stealing the t", "Midnight Bud"],                    "Athena": ["Mini Five-Hundred", "Freshman Cake Race", "Buzzweiser Song"],                    "Liv": ["Freshman Cake Race", "George P. Burdell", "Buzzweiser Song"]})     {'Jacob': ['Midnight Bud', 'The Horse', 'Stealing the t'],     'Athena': ['Mini Five-Hundred', 'Freshman Cake Race', 'Buzzweiser Song'],     'Liv': ['Freshman Cake Race', 'Buzzweiser Song', 'George P. Burdell']}     >>> traditions_dict({"Madison": ["The Horse", "Midnight Bud", "Buzzweiser Song"],                    "Anna": ["Mini Five-Hundred", "Buzzweiser Song", "Freshman Cake Race"],                    "Ashok": ["The Horse", "Freshman Cake Race", "Stealing the t", "Midnight Bud"]})     {'Madison': ['Midnight Bud', 'The Horse', 'Buzzweiser Song'],     'Anna': ['Mini Five-Hundred', 'Freshman Cake Race', 'Buzzweiser Song'],     'Ashok': ['Midnight Bud', 'Freshman Cake Race', 'The Horse', 'Stealing the t']} print(traditions_dict({"Jacob": ["The Horse", "Stealing the t", "Midnight Bud"], "Athena": ["Mini Five-Hundred", "Freshman Cake Race", "Buzzweiser Song"], "Liv": ["Freshman Cake Race", "George P. Burdell", "Buzzweiser Song"]})) print(traditions_dict({"Madison": ["The Horse", "Midnight Bud", "Buzzweiser Song"], "Anna": ["Mini Five-Hundred", "Buzzweiser Song", "Freshman Cake Race"],"Ashok": ["The Horse", "Freshman Cake Race", "Stealing the t", "Midnight Bud"]}))

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

python: answer in one line of code if possible, please

def traditions_dict(adict):
    """
    Question 6
    Given a dictionary that maps a person to a list of their favorite
    GT traditions, return a dictionary with the value being
    the list sorted by the last letter of each tradition. If two
    traditions have the same last letter, sort by the first letter.

    HINT: This will require the use of lambda functions

    Args:
        adict (dict)
    Returns:
        dict

    >>> traditions_dict({"Jacob": ["The Horse", "Stealing the t", "Midnight Bud"],
                   "Athena": ["Mini Five-Hundred", "Freshman Cake Race", "Buzzweiser Song"],
                   "Liv": ["Freshman Cake Race", "George P. Burdell", "Buzzweiser Song"]})

    {'Jacob': ['Midnight Bud', 'The Horse', 'Stealing the t'],
    'Athena': ['Mini Five-Hundred', 'Freshman Cake Race', 'Buzzweiser Song'],
    'Liv': ['Freshman Cake Race', 'Buzzweiser Song', 'George P. Burdell']}

    >>> traditions_dict({"Madison": ["The Horse", "Midnight Bud", "Buzzweiser Song"],
                   "Anna": ["Mini Five-Hundred", "Buzzweiser Song", "Freshman Cake Race"],
                   "Ashok": ["The Horse", "Freshman Cake Race", "Stealing the t", "Midnight Bud"]})

    {'Madison': ['Midnight Bud', 'The Horse', 'Buzzweiser Song'],
    'Anna': ['Mini Five-Hundred', 'Freshman Cake Race', 'Buzzweiser Song'],
    'Ashok': ['Midnight Bud', 'Freshman Cake Race', 'The Horse', 'Stealing the t']}

print(traditions_dict({"Jacob": ["The Horse", "Stealing the t", "Midnight Bud"], "Athena": ["Mini Five-Hundred", "Freshman Cake Race", "Buzzweiser Song"], "Liv": ["Freshman Cake Race", "George P. Burdell", "Buzzweiser Song"]}))
print(traditions_dict({"Madison": ["The Horse", "Midnight Bud", "Buzzweiser Song"], "Anna": ["Mini Five-Hundred", "Buzzweiser Song", "Freshman Cake Race"],"Ashok": ["The Horse", "Freshman Cake Race", "Stealing the t", "Midnight Bud"]}))

def classes(adict, major):
    """
    Question 7
    - Given a dict that maps a class number to a major identifiers
      where you could find that class number, return the set of numbers that
      one could take for a specific major!

    - For an extra challenge, try doing this in one line (Optional).

    Args:
        adict (dict)
        major (str)
    Returns:
        set

    >>> classes_dict = {4232: ["ISYE", "MATH", "HTS"],
                         2316: ["CS", "CX", "MGT"],
                         3000: ["ISYE", "MGT", "ECE"],
                         2027: ["ISYE", "PSYC", "HTS"]}

    >>> classes(classes_dict, "ISYE")
    {4232, 2027, 3000}

    >>> classes(classes_dict, "CS")
    {2316}

    """

classes_dict = {4232: ["ISYE", "MATH", "HTS"], 2316: ["CS", "CX", "MGT"], 3000: ["ISYE", "MGT", "ECE"], 2027: ["ISYE", "PSYC", "HTS"]}

print(classes(classes_dict, "ISYE"))
print(classes(classes_dict, "CS"))

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

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