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()
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)
updateSlot(dialerNames, dialerNumbers)
command = input("Please enter command(p/n/u/e): ").lower()
print("Goodbye!")
if __name__ == "__main__":
main()
Step by step
Solved in 4 steps with 4 images