pass def dialByName(names,numbers): '''Function to handle dial by name command which prompts the user for the name checks if the name is present in names list (make the comparison case-insensitive) if not present prints "Name not found." else prints "Calling name ....xxx-xxx-xxxx" E.g. If slot number 3 (values at index 2 in above lists) had name = "Susan" and number 4255551212, and user enters "susan" dialByName() will print "Calling Susan ........425-555-1212" ''' #Implement this function pass def main(): print('''Welcome to the Speed Dialer. Commands: p for print \tn dial by name u for update\ts dial by slot e for exit''') # The dialer is initialized with empty data. dialerNames = ["Empty", "Empty", "Empty", "Empty", "Empty"] dialerNumbers = ["Empty", "Empty", "Empty","Empty", "Empty"] command = input('''Please enter command(p/n/u/e): ''').lower() while (not command.startswith('e')): if (command.startswith('p')): printList(dialerNames, dialerNumbers) elif (command.startswith('n')): dialByName(dialerNames, dialerNumbers)               elif (command.startswith('u')): updateSlot(dialerNames, dialerNumbers) command = input("Please enter command(p/n/u/e): ").lower() print("Goodbye!") if __name__ == "__main__": main()

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
100%

How do I make a program that keeps track of a phone speed dialer directory which has 5 fixed slots, without changing the starter code.

# Program to simulate a speed dialer
# Complete the functions listed below that work with
# two lists that manage a dialer with 5 fixed slots.
def printList(names,numbers):
'''function to show the current dialer data as shown in sample runs
'''
#Implement this function
pass



def updateSlot(names,numbers):
'''Function to handle update by slot number command which
prompts the user for the slot number to be updated
Uses try-except to handle error cases:
if slot number not within valid range
if user enters non-integer input
If slot number is valid, then
prompts the user for the new name and new number
and updates entries for the slot number.
prints "Updated slot number X" where X is the slot number user entered.
'''
#Implement this function

pass
def dialByName(names,numbers):
'''Function to handle dial by name command which
prompts the user for the name
checks if the name is present in names list (make the comparison
case-insensitive)
if not present prints "Name not found."
else prints "Calling name ....xxx-xxx-xxxx"
E.g. If slot number 3 (values at index 2 in above lists)
had name = "Susan" and number 4255551212, and user enters "susan"
dialByName() will print
"Calling Susan ........425-555-1212"
'''
#Implement this function
pass
def main():
print('''Welcome to the Speed Dialer.
Commands:
p for print \tn dial by name
u for update\ts dial by slot
e for exit''')
# The dialer is initialized with empty data.
dialerNames = ["Empty", "Empty", "Empty", "Empty", "Empty"]
dialerNumbers = ["Empty", "Empty", "Empty","Empty", "Empty"]

command = input('''Please enter command(p/n/u/e): ''').lower()
while (not command.startswith('e')):
if (command.startswith('p')):
printList(dialerNames, dialerNumbers)
elif (command.startswith('n')):
dialByName(dialerNames, dialerNumbers)

 
 
 
 
 
 
 
elif (command.startswith('u')):
updateSlot(dialerNames, dialerNumbers)
command = input("Please enter command(p/n/u/e): ").lower()
print("Goodbye!")
if __name__ == "__main__":
main()
2 IDLE Shell 3.9.2
File Edit Shell Debug Options Window Help
Welcome to the Speed Dialer.
Commands :
p for print
u for update
e for exit
n dial by name
s dial by slot
Please enter command (p/n/u/e) : p
Empty
Empty
Empty
Empty
Empty
Please enter command (p/n/u/e) : n
1
Empty
Empty
2
3
Empty
Empty
Empty
4
Enter the name: Molly
Name not found.
Please enter command (p/n/u/e) : u
Enter the slot number: 2
Enter new name: Molly
Enter ner
number: 4255551212
Updated slot number
Please enter command (p/n/u/e): p
1
Empty
Molly
Empty
Empty
Empty
Empty
2
4255551212
3
Empty
Empty
Empty
4
Please enter command (p/n/u/e): n
Enter the name: molly
Calling Molly...
Please enter command (p/n/u/e) : e
Goodbye!
>>> |
....425-555-1212
Ln: 35 Col: 4
Transcribed Image Text:2 IDLE Shell 3.9.2 File Edit Shell Debug Options Window Help Welcome to the Speed Dialer. Commands : p for print u for update e for exit n dial by name s dial by slot Please enter command (p/n/u/e) : p Empty Empty Empty Empty Empty Please enter command (p/n/u/e) : n 1 Empty Empty 2 3 Empty Empty Empty 4 Enter the name: Molly Name not found. Please enter command (p/n/u/e) : u Enter the slot number: 2 Enter new name: Molly Enter ner number: 4255551212 Updated slot number Please enter command (p/n/u/e): p 1 Empty Molly Empty Empty Empty Empty 2 4255551212 3 Empty Empty Empty 4 Please enter command (p/n/u/e): n Enter the name: molly Calling Molly... Please enter command (p/n/u/e) : e Goodbye! >>> | ....425-555-1212 Ln: 35 Col: 4
2 IDLE Shell 3.9.2
File Edit Shell Debug Options Window Help
p for print
u for update
e for exit
Please enter command (p/n/u/e) : u
n dial by name
s dial by slot
Enter the slot number: 1
Enter new name: Jolly
Enter new number: 2065551212
Updated slot number
Please enter command (p/n/u/e) : u
1
Enter the slot number: 9
<class 'ValueError'> Invalid slot number.
Please enter command (p/n/u/e) : u
Enter the slot number: twO
<class 'ValueError'> invalid literal for int () with base 10:
Please enter command (p/n/u/e) : u
'two'
Enter the slot number: 2
Enter new name: Molly
Enter ner
number: 4251112222
Updated slot number
Please enter command (p/n/u/e) : p
2
1
2065551212
Jolly
Molly
Empty
Empty
Empty
2
4251112222
3
Empty
Empty
Empty
4
Please enter command (p/n/u/e) : n
Enter the name: jolly
Calling Jolly..
Please enter command (p/n/u/e) : e
Goodbye!
....206-555-1212
>>>
Ln: 69 Col: 4
Transcribed Image Text:2 IDLE Shell 3.9.2 File Edit Shell Debug Options Window Help p for print u for update e for exit Please enter command (p/n/u/e) : u n dial by name s dial by slot Enter the slot number: 1 Enter new name: Jolly Enter new number: 2065551212 Updated slot number Please enter command (p/n/u/e) : u 1 Enter the slot number: 9 <class 'ValueError'> Invalid slot number. Please enter command (p/n/u/e) : u Enter the slot number: twO <class 'ValueError'> invalid literal for int () with base 10: Please enter command (p/n/u/e) : u 'two' Enter the slot number: 2 Enter new name: Molly Enter ner number: 4251112222 Updated slot number Please enter command (p/n/u/e) : p 2 1 2065551212 Jolly Molly Empty Empty Empty 2 4251112222 3 Empty Empty Empty 4 Please enter command (p/n/u/e) : n Enter the name: jolly Calling Jolly.. Please enter command (p/n/u/e) : e Goodbye! ....206-555-1212 >>> Ln: 69 Col: 4
Expert Solution
steps

Step by step

Solved in 4 steps with 4 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