Question

In: Computer Science

##### answer in python #####picture of output and input Create customer information system as follows: Ask...

##### answer in python

#####picture of output and input

  1. Create customer information system as follows:

Ask the user to enter name, phonenumber, email for each customer. Build a dictionary of dictionaries to hold 10 customers with each customer having a unique customer id. (random number generated)

  1. Take the keys of the above mentioned dictionary which are customer ids and make a list. Ask the use to enter a customer id and do a binary search to find if the customer exist in the list.
  2. Sort the above mentioned list by insertion sort. (Write insertion sort code)

Solutions

Expert Solution

# The code for the problem is given below for indentation refer to pictures below and if have any problem then feel free to ask:

# importing random for generating random integers

import random

# making dictionary for details of each customer

dict = {}

# making dictionary for details of every customer with id

dictMajor = {}

idLis = []

# list for saving the keys of the dictionary

keyList = []

# making a dictionary of dictionaries with random generated id

# from 0 to 9 for 10 customers

def dictAssign(dictMajor, dict):

while 1:

d = random.randint(0, 10)

if d not in idLis:

idLis.append(d)

dictMajor[d] = dict

return

# function for sorting the keys using insertion sort

def insertSort(keyList, n):

for i in range(1, n):

temp = keyList[i]

j = i-1

while j >= 0 and temp < keyList[j]:

keyList[j+1] = keyList[j]

j = j - 1

keyList[j+1] = temp

# using binary search for searching the required id

def binarySearchId(keyList, first, last, id):

if last >= first:

mid = first+(last-first)//2

if keyList[mid] == id:

return mid

elif keyList[mid] < id:

return binarySearchId(keyList, mid+1, last, id)

else:

return binarySearchId(keyList, first, mid-1, id)

return -1

# asking the user to enter the data for the 10 custormer

for i in range(10):

print("\nEnter the details of Customer", i+1)

name = input("Enter the name: ")

phoneNumber = input("Enter the phone number: ")

email = input("Enter the Email: ")

dict['Name'] = name

dict['Phone Number'] = phoneNumber

dict['Email'] = email

dictAssign(dictMajor, dict)

# extracting the keys into a list

for value in dictMajor.keys():

keyList.append(value)

# calling the function insertion sort

n = len(keyList)

insertSort(keyList, n)

# asking the user to enter the id to search and searching the id in keylist

# using binarySearchId() function

id = int(input("Enter the customer id to search: "))

index = binarySearchId(keyList, 0, n-1, id)

# giving the result of search to user

if index == -1:

print("Customer with entered id not found!!")

else:

print("Customer with id:", id,

"is found\nThe details of customer are:", dictMajor[id])

OUTPUT:


Related Solutions

In Python Create customer information system as follows: Python 3 Create customer information system as follows:...
In Python Create customer information system as follows: Python 3 Create customer information system as follows: Ask the user to enter name, phonenumber, email for each customer. Build a dictionary of dictionaries to hold 10 customers with each customer having a unique customer id. (random number generated) Take the keys of the above mentioned dictionary which are customer ids and make a list. Ask the use to enter a customer id and do a binary search to find if the...
In Python Create customer information system as follows: Ask the user to enter name, phonenumber, email....
In Python Create customer information system as follows: Ask the user to enter name, phonenumber, email. Create a file by his name and save it in the hard disk. Do this repeatedly until all the users are entered. (for example, if the user enters 10 customers’s information, there should be 10 different files created.) Now build the customer value for a retail company as follows: Ask the customer to enter his name. If you have his information already stored, then...
Create a SIPOC (Supply, Input, Process, Output, Customer) Diagram for Netflix to define the key players...
Create a SIPOC (Supply, Input, Process, Output, Customer) Diagram for Netflix to define the key players and processes in their business model. Under the “Process” category, define the high-level steps of continuous improvement for the Netflix app platform.
Create a small program that contains the following. ask the user to input their name ask...
Create a small program that contains the following. ask the user to input their name ask the user to input three numbers check if their first number is between their second and third numbers
Create a program (Python) YourFirstnameLastnameA06b.py to ask the user to create a password: The user will...
Create a program (Python) YourFirstnameLastnameA06b.py to ask the user to create a password: The user will first enter a password, then enters the same password again; If the second input is the same as first one, the user successfully creates the password. Print “Well done.”; Otherwise, the user will be directed to repeat the whole process (go to step 1.)
python: ask the user to input a sequence of positive numbers. the end of the sequence...
python: ask the user to input a sequence of positive numbers. the end of the sequence is determined when the user enters a negative number. print out the maximum number from the sequence. output: keep entering positive numbers. to quit, input a negative number. enter a number: 67 enter a number: 5 enter a number: 8 enter a number: -3 largest number entered: 67 (note: i do not want to ask the user how many numbers they will input)
Write a program in C, that uses standard input and output to ask the user to...
Write a program in C, that uses standard input and output to ask the user to enter a sentence of up to 50 characters, the ask the user for a number between 1 & 10. Count the number of characters in the sentence and multiple the number of characters by the input number and print out the answer. Code so far: char sentence[50]; int count = 0; int c; printf("\nEnter a sentence: "); fgets(sentence, 50, stdin); sscanf(sentence, %s;    for(c=0;...
Ask the user to input a series of numbers, write a C# program to output the...
Ask the user to input a series of numbers, write a C# program to output the sum, max, and min. Be sure to do error checking if the user input is not a number.
Create a program that ask to input two users and the result will vary on their...
Create a program that ask to input two users and the result will vary on their name with similar digits. In a game of F.L.A.M.E.S , it will count and repeat depends on their name that has a similar digit. For an Example (JOE RIZAL) and (JACKLYN BRACKEN) - JOE RIZAL has - 5 similar digits , while JACKLYN BRACKEN has 6 similar digits so a total of 11. F - Friends - 1,7 L - Lover - 2,8 A...
Q1 Create a program that asks the user to input their budget. Then, it will ask...
Q1 Create a program that asks the user to input their budget. Then, it will ask the user to input each of their purchase until their entire budget is used up. What kind of loop do you think is the most appropriate? You don't have to create the entire program. Part of it has already been created for you (see code below). Note: Assume that the user always uses up their budget to the last cent and they don't over...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT