Question

In: Computer Science

Address Labeller Simple databases normally store address information as single line of data. In our database,...

Address Labeller Simple databases normally store address information as single line of data. In our database, fields are delimited by the percent sign '%' and can be placed in any order. Each field starts with a label "Street:", "City:", "State:", and "Zipcode:". Write an address labeller that extracts the fields from a database record entered by the user and prints a label if all fields are present. The program will report on any missing fields.

Sample runs: Enter an address database entry: State:New York%Street:12 Primrose Lane%Zipcode:11564%City:ValleyStream% 12 Primrose Lane ValleyStream, New York 11564

Enter an address database entry: Street:12 Primrose Lane%Zipcode:11564%State:New York%City:ValleyStream% 12 Primrose Lane ValleyStream, New York 11564

Enter an address database entry: Street:12 Primrose Lane%State:New York%City:ValleyStream% Error: Address does not contain zipcode

Solutions

Expert Solution

address = input('Enter an address database entry: ')
if address[-1] == '%':
    address = address[:-1]
a = address.split('%')
keys = {'State','Street','City','Zipcode'}
di = {}
new = []
for i in a:
    new.append((i.split(':')))
not_found = []
for i in new:
    k = i[0]
    v = i[-1]
    di[k] = v
flag = 1
new_set = set()
for key in di.keys():
    new_set.add(key)
for k,v in di.items():
    if v == '':
        print(f'Key {k} does not have a value')
        exit()
      
  
if new_set == keys:
    print(f'{di["Street"]} {di["City"]}, {di["State"]} {di["Zipcode"]}')
else:
    not_in = [i for i in list(keys.difference(new_set))]
    print(f'Error: Address does not contain', end = ' ')
    for i in not_in:
        print(i, end = ' ' )
print()

  


Related Solutions

Describe the importance of databases and database management systems in managing organizational data and information. Include...
Describe the importance of databases and database management systems in managing organizational data and information. Include in your discussion the types and some examples of database management systems. Also, address the advantages and disadvantages of using a DBMS.
The government now requires physicians to store patient information in databases that are accessible in multiple...
The government now requires physicians to store patient information in databases that are accessible in multiple locations by multiple people if they want to qualify for certain reimbursements. The rationale is that this will enable healthcare providers the ability to better serve their patients, as all will have access to the patients’ medical history. Many patients worry about compromised privacy and security, especially since these databases are accessible via the Internet. Should patients be allowed to opt out of these...
Develop a simple MIS (Management Information System) that consists of a simple database (a text file)....
Develop a simple MIS (Management Information System) that consists of a simple database (a text file). The system manages to dynamically input record/data into the database. The data from the database can be sorted, searched and updated. User also should be able to add new records/data, remove any data and etc. Here are some ideas of MIS that can be developed: 1. Hotel reservation system. 2. Students management system. 3. Payroll management system. 4. Bus/Railway/Plane ticketing system. 5. Clinic record...
Explain the differences between data, Information, and a database. Describe the purpose of a database in...
Explain the differences between data, Information, and a database. Describe the purpose of a database in health care and provide an example of one utilized locally, statewide, and nationally.
For each of the following research cases, search the FASB ASC database for information to address...
For each of the following research cases, search the FASB ASC database for information to address the issues. Copy and paste the FASB ASC paragraphs that support your responses. Then summarize briefly what your responses are, citing the paragraphs used to support your responses. • FASB ASC 1-3 Accounting for the Investment Tax Credit The accounting alternative treatments for the investment tax credit originally outlined in APB Opinions 2 and 4 are still considered GAAP. Find and cite the FASB...
Part 1Write a narrative that describes what information you will store in a database. Be as...
Part 1Write a narrative that describes what information you will store in a database. Be as descriptive as you can be. Part 2Create an E-R diagram that corresponds to yournarrative. If you have fewer than three entities in your E-R diagram, revise your narrative!Remember that foreign key values should not be in your entities.Make sure that you include maximum and minimum cardinalities for your relationships.You can use a tool to create the E-R diagram or draw it by hand and...
You are interested in analyzing some hard-to-obtain data from two separate databases. Each database contains n...
You are interested in analyzing some hard-to-obtain data from two separate databases. Each database contains n numerical values -so there are 2n values total - and you may assume that no two values are the same. You’d like to determine the median of this set of 2n values, which we will define here to be the nth smallest value. However, the only way you can access these values is through queries to the databases. In a single query, you can...
Database reports provide us with the ability to further analyze our data, and provide it in...
Database reports provide us with the ability to further analyze our data, and provide it in a format that can be used to make business decisions. Discuss the steps that you would take to ensure that we create an effective report. What questions would you ask of the users?
Database design of cothing Online Shopping System. Schema represents minimal information required to store information of...
Database design of cothing Online Shopping System. Schema represents minimal information required to store information of a shop and products to sell. Cart information can be stored in session or if wish-list / watchlist is needed, the schema can be simply extended. Enjoy. SQL and methodology.
A company database needs to store information about employees (identified by ssn, with salary and phone...
A company database needs to store information about employees (identified by ssn, with salary and phone as attributes), departments (identified by dno, with dname and budget as attributes), and children of employees (with name, age, and relationship to the employee as attributes). Employees work in departments; each department is managed by an employee; a child must be identified uniquely by name when the parent (who is an employee; assume that only one parent works for the company) is known. We...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT