FIX THE PROGRAM BELOW.     #Function to get the key value ind dictionary def get_key(val):     for key, value in result.items():          if val == value:              return key       return "key doesn't exist"   #Function definition to find the tallest height def tall(list_height):          return max(list_height)   #Function to find the shortest height def short(list_height):          return min(list_height)     # creating an empty list list_names list_names = []    # Get the number of baby names as input from user num1 = int(input("Enter number of baby names : "))    # iterating till the range for i in range(0, num1):     name = input()     list_names.append(name) # adding the element        print("list of baby names : ",list_names)   # creating an empty list list_height list_height = []    # iterating till the range for i in range(0, num1):     height = int(input())     list_height.append(height) # adding the element        print("list of baby heights : ", list_height)   # using dictionary comprehension to convert lists to dictionary result = {list_names[i]: list_height[i] for i in range(len(list_names))}    letter=input("Enter T to find tallest baby and S to find the shortest baby : ")   #If the entered letetr is S, find the shortest baby if (letter=="S"):     #call the function short(), to find the smallest height     short=short(list_height)          # printing the minimum height     print("Minimum height : ", short)          #call the function get_key(short) to find the baby name corersponding to the number     print("Shortest baby is:", get_key(short))        #if the letter entered is elif (letter=="T"):     tall=tall(list_height)       # printing the maximum height     print("Maximum height : ", tall)       #call the function get_key(tall) to find the baby name corersponding to the number     print("Tallest baby is:", get_key(tall))   else:     print("Invalid letter")

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

FIX THE PROGRAM BELOW.

 

 

#Function to get the key value ind dictionary

def get_key(val):

    for key, value in result.items():

         if val == value:

             return key

 

    return "key doesn't exist"

 

#Function definition to find the tallest height

def tall(list_height):

    

    return max(list_height)

 

#Function to find the shortest height

def short(list_height):

    

    return min(list_height)

 

 

# creating an empty list list_names

list_names = []

  

# Get the number of baby names as input from user

num1 = int(input("Enter number of baby names : "))

  

# iterating till the range

for i in range(0, num1):

    name = input()

    list_names.append(name) # adding the element

      

print("list of baby names : ",list_names)

 

# creating an empty list list_height

list_height = []

  

# iterating till the range

for i in range(0, num1):

    height = int(input())

    list_height.append(height) # adding the element

      

print("list of baby heights : ", list_height)

 

# using dictionary comprehension to convert lists to dictionary

result = {list_names[i]: list_height[i] for i in range(len(list_names))}

  

letter=input("Enter T to find tallest baby and S to find the shortest baby : ")

 

#If the entered letetr is S, find the shortest baby

if (letter=="S"):

    #call the function short(), to find the smallest height

    short=short(list_height)

    

    # printing the minimum height

    print("Minimum height : ", short)

    

    #call the function get_key(short) to find the baby name corersponding to the number

    print("Shortest baby is:", get_key(short))  

    

#if the letter entered is

elif (letter=="T"):

    tall=tall(list_height)

 

    # printing the maximum height

    print("Maximum height : ", tall)

      #call the function get_key(tall) to find the baby name corersponding to the number

    print("Tallest baby is:", get_key(tall))

 

else:

    print("Invalid letter")

Expert Solution
Step 1

The correct code is given below.

Sample Response:

#Function to get the key value ind dictionary
def get_key(val):
    for key, value in result.items():
         if val == value:
             return key
    return "key doesn't exist"

#Function definition to find the tallest height
def tall(list_height):
    max=list_height[0]
    for i in range(len(list_height)):
        if max<list_height[i]:
            max=list_height[i]
    return max

#Function to find the shortest height
def short(list_height):
    min=list_height[0]
    for i in range(len(list_height)):
        if min>list_height[i]:
            min=list_height[i]
    return min
 
# creating an empty list list_names
list_names = []
# Get the number of baby names as input from user
num1 = int(input("Enter number of baby names : "))
print("Please enter the baby names.")
# iterating till the range
for i in range(0, num1):
    name = input()
    list_names.append(name) # adding the element
print("list of baby names : ",list_names)

# creating an empty list list_height
list_height=[]
print("Please enter the baby heights.")
# iterating till the range
for i in range(0, num1):
    height=int(input())
    list_height.append(height) # adding the element
print("list of baby heights : ",list_height)

# using dictionary comprehension to convert lists to dictionary
result={list_names[i]: list_height[i] for i in range(len(list_names))}
letter=input("Enter T to find tallest baby and S to find the shortest baby : ")
#If the entered letter is S, find the shortest baby
if (letter=="S"):
    #call the function short(), to find the smallest height
    short=short(list_height)
    # printing the minimum height
    print("Minimum height : ",short)
    #call the function get_key(short) to find the baby name corresponding to the number
    print("Shortest baby is:",get_key(short)) 
#if the letter entered is

elif (letter=="T"):
    tall=tall(list_height)
    # printing the maximum height
    print("Maximum height : ", tall)
    #call the function get_key(tall) to find the baby name corersponding to the number
    print("Tallest baby is:", get_key(tall))
else:
    print("Invalid letter")

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

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