In: Computer Science
In Python Create customer information system as follows:
Python 3
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)
import random
#insertion sort
def insSort(a): 
    for i in range(1, len(a)): 
        k = a[i] 
        j = i-1
        while(j >=0 and k < a[j]): 
                a[j+1] = a[j] 
                j -= 1
        a[j+1] = k 
  
#binary search
def binary_search_alg(slist,sid):
        f = 0
        l= len(slist)-1
        ans = False
        while(f<=l and not ans):
                mid = (f + l)//2
                if(slist[mid]==sid):
                        ans=True
                else:
                        if(sid< slist[mid]):
                                l=mid-1
                        else:
                                f=mid+1 
        return ans
dic={}
i=0
cid=[]
while(i<10):
    name=(input("Enter name:"))
    phone=(int(input("Enter phonenumber:")))
    email=(input("Enter email:"))
    #here we are considering random values among 2digit numbers
    r=random.randint(10,100)
    if r not in cid: 
        dic.update({r:{'email':email,'phonenumber':phone,'name':name}})
        cid.append(r)
    i=i+1
print("\n")
print("Customer id's are:")
print(cid)
print("\n")
searchid=int(input("Enter customer id to search:"))
insSort(cid)
print("Sorted customer id's are:")
print(cid)
val=binary_search_alg(cid,searchid)
if(val==True):
    print("Customer id exist in the list")
else:
    print("Customer id doesn't exist in the list")
print("\n\n")
print("For verifying\n")
print("Dictionary values are:")    
print(dic)
print("\n")
Note: As no limit is given for random numbers, i'm cosidering random numbers between 10 and 100. This can be changed by modifying "random.randint(10,100)" in the code.

