Question: Must be completed in PYTHON only Question 2: [Dictionary. Postal codes] In a Canadian postal code, the first, third and fifth characters are letters while
Must be completed in PYTHON only
Question 2: [Dictionary. Postal codes] In a Canadian postal code, the first, third and fifth characters are letters while the second, fourth and sixth characters are numbers. The province can be determined from the first character of a postal code, as shown in the following table. No valid postal codes currently begin with D, F, I, O, Q, U, W, or Z Province Newfoundland Nova Scotia Prince Edward Island New Brunswick Quebec Ontario Manitoba Saskatchewan Alberta British Columbia Nunavut Northwest Territories Yukon First character(s) c G, Hand J K, M, N and p x x The second character in a postal code identifies whether the address is rural or urban. If that character is a O then the address is rural. Otherwise it is urban. Create a program that reads a postal code from the user and displays the province associated with it, along with whether the address is urban or rural. For example, if the user enters T2N IN4 then your program should indicate that the postal code is for an urban address in Alberta. If the user enters XOA 1B2 then your program should indicate that the postal code is for a rural address in Nunavut or Northwest Temitories. Use a dictionary to map from the first character of the postal code to the province name. Display a meaningful error message if the postal code begins with an invalid character.
Step by Step Solution
3.56 Rating (149 Votes )
There are 3 Steps involved in it
To address the problem we need a Python program that reads a postal code and determines the correspo... View full answer
Get step-by-step solutions from verified subject matter experts
