Now You Code 1: Address

Write a Python program to input elements of your postal address and then output them as if they were an address label. The program should use a dictionary to store the address and complete two function defintions one for inputting the address and one for printing the address.

NOTE: While you most certainly can write this program without using dictionaries or functions, the point of the exercise is to get used to using them!!!

Sample Run:

Enter Street: 314 Hinds Hall
Enter City: Syracuse
Enter State: NY
Enter Postal Zip Code: 13244
Mailing Address:
314 Hinds Hall
Syracuse , NY 13244

Step 1: Problem Analysis input_address function

This function should get input from the user at run time and return the input address.

Inputs: None (gets input from user)

Outputs: a Python dictionary of address info (street, city, state, postal_code)

Algorithm (Steps in Program):


In [2]:
## Step 2: Write input_address_ function
#input: None (inputs from console)
#output: dictionary of the address
def input_address():
    address= {}
    # todo: write code here to input the street, city, state and zip code and add to dictionary at runtime and store in a dictionary

    return address

Step 3: Problem Analysis print_address function

This function should display a mailing address using the dictionary variable

Inputs: dictionary variable of address information (street, city, state, postal_code)

Outputs: None (prints to screen)

Algorithm (Steps in Program):


In [ ]:
## Step 4: write code
# input: address dictionary
# output: none (outputs to console)
def print_address(address):
    # todo: write code to print the address (leave empty return at the end
    
    return

Step 5: Problem Analysis main program

Should be trivial at this point.

Inputs:

Outputs:

Algorithm (Steps in Program):


In [ ]:
## Step 6: write main program, use other 2 functions you made to solve this problem.
    
# main program
# todo: call input_address, then print_address

Step 7: Questions

  1. Explain a strategy for a situation when an expected dictionary key, like 'state' for example does not exist?

Answer:

  1. The program as it is written is not very useful. How can we make it more useful?

Answer:

Step 8: Reflection

Reflect upon your experience completing this assignment. This should be a personal narrative, in your own voice, and cite specifics relevant to the activity as to help the grader understand how you arrived at the code you submitted. Things to consider touching upon: Elaborate on the process itself. Did your original problem analysis work as designed? How many iterations did you go through before you arrived at the solution? Where did you struggle along the way and how did you overcome it? What did you learn from completing the assignment? What do you need to work on to get better? What was most valuable and least valuable about this exercise? Do you have any suggestions for improvements?

To make a good reflection, you should journal your thoughts, questions and comments while you complete the exercise.

Keep your response to between 100 and 250 words.

--== Write Your Reflection Below Here ==--