Add your code here to return the decimal equivalent of the roman string

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 do I make sure that my code sorts in an ascending order for both roman numerical and decimal equivalent? Here is what I have so far. 

def roman_to_decimal (roman : str):
    # Add your code here to return the decimal equivalent of the roman string
    decimal_conversion = [('I', 1), ('V', 5), ('X', 10), ('L', 50), ('C', 100), ('D', 500), ('M', 1000)]
    decimal = 0
    prev_value = 0
    
    for i in reversed(roman.strip()):
        if not any(item[0] == i for item in decimal_conversion):
            return 0

        value = next(item[1] for item in decimal_conversion if item[0] == i)
        if value < prev_value:
            decimal -= value
        else:
            decimal += value
        prev_value = value    
        
    return decimal

filename = "superbowl_games.txt"
with open(filename, "r", encoding="utf-8") as file:
    data = [line.strip().split('|') for line in file]
    counts = [[element.strip() for element in row] for row in data if row]
    
    sort_medals = lambda row: (roman_to_decimal(row[0]))
    sorted_data = sorted (counts , key=sort_medals)
for row in sorted_data:
     print("{:10}{:20}{:20}  {:10}{:10} {:10}".format(*row))

XVI January 24, 1982 San Francisco 49ers |26-21 | Cincinnati Bengals | Pontiac
Silverdome Pontiac, Michigan | 81,270 | Pat Haggerty
IV January 11, 1978 |Kansas City Chiefs | 23-7 | Minnesota Vikings | Tulane
Stadium New Orleans, Louisiana | 80,562 80,562
XXXXXIX February 6, 2005 |New England Patriots | 24-21 | Philadelphia
Eagles Alltel Stadium Jacksonville, Florida | 78,125 | Terry McAulay
XXXXII January 25, 1998 Denver Broncos | 31-24 Green Bay Packers Qualcomm
Stadium San Diego, California | 68,912 | Ed Hochuli
LVIII February 11, 2024 |Kansas City Chiefs | 25-22 | San Francisco
49ers Allegiant Stadium | Paradise, Nevada | 61,629 | Bill Vinovich
XXXX January 28, 1996 Dallas Cowboys 27-17 | Pittsburgh Steelers | Sun Devil
Stadium Tempe, Arizona | 76,347 Red Cashion
XLI February 4, 2007 |Indianapolis Colts | 29-17 | Chicago Bears Dolphin
Stadium Miami Gardens, Florida | 74,512 | Tony Corrente
XLIV February 7, 2010 | New Orleans Saints | 31-17| Indianapolis Colts | Sun
Life Stadium Miami Gardens, Florida | 74,059 | Scott Green
50 February 7, 2016 |Denver Broncos | 24-10 | Carolina Panthers | Levi's
Stadium Santa Clara, California | 71,888 | Clete Blakeman
XIV January 20, 1980 |Pittsburgh Steelers | 31-19 | Los Angeles Rams | Rose
Bowl Pasadena, California | 103,985 | Fred Silva
III January 12, 1969 |New York Jets 16-7 | Baltimore Colts | Miami Orange
Bowl Miami, Florida | 75,389 | Tom Bell
XXIII January 22, 1989 |San Francisco 49ers 20-16 | Cincinnati Bengals | Joe
Robbie Stadium | Miami, Florida | 75,129 | Jerry Seeman
LI February 5, 2017 New England Patriots |34-28 | Atlanta Falcons | NRG
Stadium Houston, Texas 70,807 | Carl Cheffers
IX January 12, 1975 |Pittsburgh Steelers | 16-6 | Minnesota Vikings | Tulane
Stadium New Orleans, Louisiana | 80,997 | Bernie Ulman
VIII January 13, 1974
Stadium Houston, Texas
XXXXXV January 28, 2001
Stadium Tampa, Florida
|Miami Dolphins | 24-7 | Minnesota Vikings | Rice
71,882 | Ben Dreith
Baltimore Ravens | 34-7 | New York Giants | Raymond James
71,921 | Gerry Austin
LV February 7, 2021 Tampa Bay Buccaneers | 31-9 | Kansas City Chiefs | Raymond
James Stadium Tampa, Florida | 24,835 | Carl Cheffers
XLVIII February 2, 2014 |Seattle Seahawks |43-8 | Denver Broncos | MetLife
Stadium East Rutherford, New Jersey 82,529 | Terry McAulay
VII January 14, 1973 | Miami Dolphins | 14-7 | Washington Redskins | Los Angeles
Memorial Coliseum | Los Angeles, California 90,182 | Tom Bell
XIX January 20, 1985 |San Francisco 49ers |38-16 | Miami Dolphins | Stanford
Stadium Stanford, California | 84,059 | Pat Haggerty
XXXXIV January 30, 2000 |St. Louis Rams | 23-16|Tennessee Titans | Georgia
Dome | Atlanta, Georgia | 72,625 | Bob McElwee
XXVI January 26, 1992 Washington Redskins | 37-24| Buffalo
Bills | Metrodome | Minneapolis, Minnesota | 63,130 | Jerry Markbreit
XLII February 3, 2008 |New York Giants |17-14| New England
Patriots | University of Phoenix Stadium Glendale, Arizona |71,101 | Mike Carey
XXXXI January 26, 1997 |Green Bay Packers | 35-21| New England
Patriots Louisiana Superdome New Orleans, Louisiana 72,301 | Gerry Austin
XXXXXVII January 26, 2003 Tampa Bay Buccaneers |48-21 | Oakland
Raiders Qualcomm Stadium San Diego, California | 67,603 | Bill Carollo
V|January 17, 1971 Baltimore Colts 16-13 | Dallas Cowboys | Miami Orange
Bowl Miami, Florida | 79,204 | Norm Schachter
XXIX January 29, 1995 San Francisco 49ers |49-26|San Diego Chargers | Joe
Robbie Stadium | Miami, Florida | 74,107 | Jerry Markbreit
XXXXXVIII February 1, 2004 |New England Patriots | 32-29 | Carolina
Panthers | Reliant Stadium Houston, Texas 71,525 Ed Hochuli
XXIV January 28, 1990 |San Francisco 49ers 55-10 | Denver Broncos | Louisiana
Superdome New Orleans, Louisiana 72,919 Dick Jorgensen
Transcribed Image Text:XVI January 24, 1982 San Francisco 49ers |26-21 | Cincinnati Bengals | Pontiac Silverdome Pontiac, Michigan | 81,270 | Pat Haggerty IV January 11, 1978 |Kansas City Chiefs | 23-7 | Minnesota Vikings | Tulane Stadium New Orleans, Louisiana | 80,562 80,562 XXXXXIX February 6, 2005 |New England Patriots | 24-21 | Philadelphia Eagles Alltel Stadium Jacksonville, Florida | 78,125 | Terry McAulay XXXXII January 25, 1998 Denver Broncos | 31-24 Green Bay Packers Qualcomm Stadium San Diego, California | 68,912 | Ed Hochuli LVIII February 11, 2024 |Kansas City Chiefs | 25-22 | San Francisco 49ers Allegiant Stadium | Paradise, Nevada | 61,629 | Bill Vinovich XXXX January 28, 1996 Dallas Cowboys 27-17 | Pittsburgh Steelers | Sun Devil Stadium Tempe, Arizona | 76,347 Red Cashion XLI February 4, 2007 |Indianapolis Colts | 29-17 | Chicago Bears Dolphin Stadium Miami Gardens, Florida | 74,512 | Tony Corrente XLIV February 7, 2010 | New Orleans Saints | 31-17| Indianapolis Colts | Sun Life Stadium Miami Gardens, Florida | 74,059 | Scott Green 50 February 7, 2016 |Denver Broncos | 24-10 | Carolina Panthers | Levi's Stadium Santa Clara, California | 71,888 | Clete Blakeman XIV January 20, 1980 |Pittsburgh Steelers | 31-19 | Los Angeles Rams | Rose Bowl Pasadena, California | 103,985 | Fred Silva III January 12, 1969 |New York Jets 16-7 | Baltimore Colts | Miami Orange Bowl Miami, Florida | 75,389 | Tom Bell XXIII January 22, 1989 |San Francisco 49ers 20-16 | Cincinnati Bengals | Joe Robbie Stadium | Miami, Florida | 75,129 | Jerry Seeman LI February 5, 2017 New England Patriots |34-28 | Atlanta Falcons | NRG Stadium Houston, Texas 70,807 | Carl Cheffers IX January 12, 1975 |Pittsburgh Steelers | 16-6 | Minnesota Vikings | Tulane Stadium New Orleans, Louisiana | 80,997 | Bernie Ulman VIII January 13, 1974 Stadium Houston, Texas XXXXXV January 28, 2001 Stadium Tampa, Florida |Miami Dolphins | 24-7 | Minnesota Vikings | Rice 71,882 | Ben Dreith Baltimore Ravens | 34-7 | New York Giants | Raymond James 71,921 | Gerry Austin LV February 7, 2021 Tampa Bay Buccaneers | 31-9 | Kansas City Chiefs | Raymond James Stadium Tampa, Florida | 24,835 | Carl Cheffers XLVIII February 2, 2014 |Seattle Seahawks |43-8 | Denver Broncos | MetLife Stadium East Rutherford, New Jersey 82,529 | Terry McAulay VII January 14, 1973 | Miami Dolphins | 14-7 | Washington Redskins | Los Angeles Memorial Coliseum | Los Angeles, California 90,182 | Tom Bell XIX January 20, 1985 |San Francisco 49ers |38-16 | Miami Dolphins | Stanford Stadium Stanford, California | 84,059 | Pat Haggerty XXXXIV January 30, 2000 |St. Louis Rams | 23-16|Tennessee Titans | Georgia Dome | Atlanta, Georgia | 72,625 | Bob McElwee XXVI January 26, 1992 Washington Redskins | 37-24| Buffalo Bills | Metrodome | Minneapolis, Minnesota | 63,130 | Jerry Markbreit XLII February 3, 2008 |New York Giants |17-14| New England Patriots | University of Phoenix Stadium Glendale, Arizona |71,101 | Mike Carey XXXXI January 26, 1997 |Green Bay Packers | 35-21| New England Patriots Louisiana Superdome New Orleans, Louisiana 72,301 | Gerry Austin XXXXXVII January 26, 2003 Tampa Bay Buccaneers |48-21 | Oakland Raiders Qualcomm Stadium San Diego, California | 67,603 | Bill Carollo V|January 17, 1971 Baltimore Colts 16-13 | Dallas Cowboys | Miami Orange Bowl Miami, Florida | 79,204 | Norm Schachter XXIX January 29, 1995 San Francisco 49ers |49-26|San Diego Chargers | Joe Robbie Stadium | Miami, Florida | 74,107 | Jerry Markbreit XXXXXVIII February 1, 2004 |New England Patriots | 32-29 | Carolina Panthers | Reliant Stadium Houston, Texas 71,525 Ed Hochuli XXIV January 28, 1990 |San Francisco 49ers 55-10 | Denver Broncos | Louisiana Superdome New Orleans, Louisiana 72,919 Dick Jorgensen
superbowl_games
File
Edit
View
+
Same Date/Season | Winning team | Score | Losing
team Venue | City | Attendance | Referee
XXXXVI February 3, 2002 |New England Patriots | 20-17 | St. Louis
Rams | Louisiana Superdome | New Orleans, Louisiana 72,922 | Bernie Kukar
XLIX February 1, 2015 | New England Patriots |28-24| Seattle
Seahawks University of Phoenix Stadium Glendale, Arizona |70,288 Bill
Vinovich
LII February 4, 2018 | Philadelphia Eagles | 41-33 | New England Patriots | U.S.
Bank Stadium Minneapolis, Minnesota | 67,612 | Gene Steratore
XXII January 31, 1988 Washington Redskins |42-10 | Denver Broncos | San Diego-
Jack Murphy Stadium | San Diego, California | 73,302 Bob McElwee
XVIII January 22, 1984 | Los Angeles Raiders |38-9 | Washington Redskins | Tampa
Stadium Tampa, Florida | 72,920 | Gene Barth
LIV February 2, 2020 |Kansas City Chiefs | 31-20 San Francisco 49ers | Hard
Rock Stadium Miami Gardens, Florida | 62,417 | Bill Vinovich
I January 15, 1967 | Green Bay Packers | 35-10 | Kansas City Chiefs | Los Angeles
Memorial Coliseum | Los Angeles, California | 61,946 | Norm Schachter
LVII February 12, 2023 Kansas City Chiefs | 38-35 Philadelphia Eagles | State
Farm Stadium Glendale, Arizona | 67,827 | Carl Cheffers
XX|January 26, 1986 Chicago Bears 46-10 | New England Patriots | Louisiana
Superdome New Orleans, Louisiana 73,818 | Red Cashion
XXVIII January 30, 1994 |Dallas Cowboys|30-13|Buffalo Bills | Georgia
Dome | Atlanta, Georgia | 72,817 | Bob McElwee
XVII January 30, 1983 Washington Redskins | 27-17 | Miami Dolphins | Rose
Bowl Pasadena, California | 103,667 | Jerry Markbreit
XIII January 21, 1979 |Pittsburgh Steelers | 35-31 | Dallas Cowboys | Miami
Orange Bowl Miami, Florida | 79,484 | Pat Haggerty
XLVII February 3, 2013 | Baltimore Ravens 34-31 | San Francisco
49ers | Mercedes-Benz Superdome | New Orleans, Louisiana |71,024 Jerome Boger
XI January 9, 1977 Oakland Raiders | 32-14 | Minnesota Vikings | Rose
Bowl Pasadena, California | 103,438|Jim Tunney
VI January 16, 1972 |Dallas Cowboys | 24-3 | Miami Dolphins | Tulane Stadium | New
Orleans, Louisiana | 81,023 | Jim Tunney
XXXXIII January 31, 1999 Denver Broncos |34-19 | Atlanta Falcons | Pro Player
Stadium Miami, Florida 74,803 | Bernie Kukar
XII January 15, 1978 |Dallas Cowboys | 27-10 | Denver Broncos | Louisiana
Superdome | New Orleans, Louisiana 76,400 Jim Tunney
XLVI February 5, 2012 | New York Giants | 21-17 | New England Patriots | Lucas
Oil Stadium Indianapolis, Indiana | 68,658 | John Parry
LVI February 13, 2022 |Los Angeles Rams | 23-20 | Cincinnati Bengals | Sofi
Stadium Inglewood, California 70,048 | Ron Torbert
XXV January 27, 1991 | New York Giants | 20-19 | Buffalo Bills | Tampa
Stadium Tampa, Florida | 73,813|Jerry Seeman
XV January 25, 1981 Oakland Raiders | 27-10 | Philadelphia Eagles | Louisiana
Superdome New Orleans, Louisiana 76,135 | Ben Dreith
II January 14, 1968 |Green Bay Packers | 33-14 | Oakland Raiders | Miami Orange
Bowl Miami, Florida | 75,546|75,546
XXVII January 31, 1993 Dallas Cowboys | 52-17 | Buffalo Bills | Rose
Bowl Pasadena, California | 98,374 Dick Hantak
LIII February 3, 2019 |New England Patriots 13-3|Los Angeles
Rams | Mercedes-Benz Stadium | Atlanta, Georgia | 70,081 | John Parry
XXI January 25, 1987 |New York Giants | 39-20 | Denver Broncos | Rose
Bowl Pasadena, California | 101,063 | Jerry Markbreit
XL| February 5, 2006 |Pittsburgh Steelers | 21-10 | Seattle Seahawks | Ford
Field Detroit, Michigan | 68,206 | Bill Leavy
X|January 18, 1976 Pittsburgh Steelers | 21-17 | Dallas Cowboys | Miami Orange
Bowl Miami, Florida | 80,187 | Norm Schachter
XLIII February 1, 2009 |Pittsburgh Steelers | 27-23 | Arizona
Cardinals | Raymond James Stadium | Tampa, Florida | 70,774 | Terry McAulay
XLV February 6, 2011 | Green Bay Packers | 31-25 | Pittsburgh Steelers | Cowboys
Stadium Arlington, Texas | 103,219 | Walt Anderson
Transcribed Image Text:superbowl_games File Edit View + Same Date/Season | Winning team | Score | Losing team Venue | City | Attendance | Referee XXXXVI February 3, 2002 |New England Patriots | 20-17 | St. Louis Rams | Louisiana Superdome | New Orleans, Louisiana 72,922 | Bernie Kukar XLIX February 1, 2015 | New England Patriots |28-24| Seattle Seahawks University of Phoenix Stadium Glendale, Arizona |70,288 Bill Vinovich LII February 4, 2018 | Philadelphia Eagles | 41-33 | New England Patriots | U.S. Bank Stadium Minneapolis, Minnesota | 67,612 | Gene Steratore XXII January 31, 1988 Washington Redskins |42-10 | Denver Broncos | San Diego- Jack Murphy Stadium | San Diego, California | 73,302 Bob McElwee XVIII January 22, 1984 | Los Angeles Raiders |38-9 | Washington Redskins | Tampa Stadium Tampa, Florida | 72,920 | Gene Barth LIV February 2, 2020 |Kansas City Chiefs | 31-20 San Francisco 49ers | Hard Rock Stadium Miami Gardens, Florida | 62,417 | Bill Vinovich I January 15, 1967 | Green Bay Packers | 35-10 | Kansas City Chiefs | Los Angeles Memorial Coliseum | Los Angeles, California | 61,946 | Norm Schachter LVII February 12, 2023 Kansas City Chiefs | 38-35 Philadelphia Eagles | State Farm Stadium Glendale, Arizona | 67,827 | Carl Cheffers XX|January 26, 1986 Chicago Bears 46-10 | New England Patriots | Louisiana Superdome New Orleans, Louisiana 73,818 | Red Cashion XXVIII January 30, 1994 |Dallas Cowboys|30-13|Buffalo Bills | Georgia Dome | Atlanta, Georgia | 72,817 | Bob McElwee XVII January 30, 1983 Washington Redskins | 27-17 | Miami Dolphins | Rose Bowl Pasadena, California | 103,667 | Jerry Markbreit XIII January 21, 1979 |Pittsburgh Steelers | 35-31 | Dallas Cowboys | Miami Orange Bowl Miami, Florida | 79,484 | Pat Haggerty XLVII February 3, 2013 | Baltimore Ravens 34-31 | San Francisco 49ers | Mercedes-Benz Superdome | New Orleans, Louisiana |71,024 Jerome Boger XI January 9, 1977 Oakland Raiders | 32-14 | Minnesota Vikings | Rose Bowl Pasadena, California | 103,438|Jim Tunney VI January 16, 1972 |Dallas Cowboys | 24-3 | Miami Dolphins | Tulane Stadium | New Orleans, Louisiana | 81,023 | Jim Tunney XXXXIII January 31, 1999 Denver Broncos |34-19 | Atlanta Falcons | Pro Player Stadium Miami, Florida 74,803 | Bernie Kukar XII January 15, 1978 |Dallas Cowboys | 27-10 | Denver Broncos | Louisiana Superdome | New Orleans, Louisiana 76,400 Jim Tunney XLVI February 5, 2012 | New York Giants | 21-17 | New England Patriots | Lucas Oil Stadium Indianapolis, Indiana | 68,658 | John Parry LVI February 13, 2022 |Los Angeles Rams | 23-20 | Cincinnati Bengals | Sofi Stadium Inglewood, California 70,048 | Ron Torbert XXV January 27, 1991 | New York Giants | 20-19 | Buffalo Bills | Tampa Stadium Tampa, Florida | 73,813|Jerry Seeman XV January 25, 1981 Oakland Raiders | 27-10 | Philadelphia Eagles | Louisiana Superdome New Orleans, Louisiana 76,135 | Ben Dreith II January 14, 1968 |Green Bay Packers | 33-14 | Oakland Raiders | Miami Orange Bowl Miami, Florida | 75,546|75,546 XXVII January 31, 1993 Dallas Cowboys | 52-17 | Buffalo Bills | Rose Bowl Pasadena, California | 98,374 Dick Hantak LIII February 3, 2019 |New England Patriots 13-3|Los Angeles Rams | Mercedes-Benz Stadium | Atlanta, Georgia | 70,081 | John Parry XXI January 25, 1987 |New York Giants | 39-20 | Denver Broncos | Rose Bowl Pasadena, California | 101,063 | Jerry Markbreit XL| February 5, 2006 |Pittsburgh Steelers | 21-10 | Seattle Seahawks | Ford Field Detroit, Michigan | 68,206 | Bill Leavy X|January 18, 1976 Pittsburgh Steelers | 21-17 | Dallas Cowboys | Miami Orange Bowl Miami, Florida | 80,187 | Norm Schachter XLIII February 1, 2009 |Pittsburgh Steelers | 27-23 | Arizona Cardinals | Raymond James Stadium | Tampa, Florida | 70,774 | Terry McAulay XLV February 6, 2011 | Green Bay Packers | 31-25 | Pittsburgh Steelers | Cowboys Stadium Arlington, Texas | 103,219 | Walt Anderson
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

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