To Home Page

IT 212 -- Lab 3

Suggestions from Working on Lab3

  1. The import statements on top of your script should be
    from urllib.request import urlopen
    import json
    import sqlite3
    import sys
    
  2. Use input statements to input these items:
    name (str)  date (str)  source_currency (str) 
    
    target_currency (str)  source_amount (float)
    
  3. You must use the dictionary twice, once to obtain the source currency srand the second time to obtain the target currency tc. Use sys.exit to directly exit your script if an illegal currency code is entered at the keyboard:
    if sc in d:
        sr = d[sc]
    else:
        print("Code for source currency not found.")
        sys.exit( )
        
    if tc in d
        tr = d[tc]
    else:
        print("Code for target currency not found.")
        sys.exit( )
    
  4. Use this statement to create the output database:
    conn = sqlite3.connect('lab3transactions.db')
  5. Modify the kids table to create a table named transactions with these columns:
    Column Datatype
    name varchar(15)
    source_currency varchar(3)
    target_currency varchar(3)
    source_amount float
    source_exchange_rate float
    target_exchange_rate float
    target_amount float
  6. When you modify the insert statement
    # Insert values into database.
    cur.execute(f'''insert into kids values(
      '{name}', '{gender}', {age});''')
    
    remember that in SQL, string values need single quotes, but numeric values (int and float) do not use single quotes.

Pseudocode for Lab 3

Grading Criteria: