Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Solution the dictionary for storing provinces provinceANewfoundlandBNova ScotiaCPrince Edward ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Managerial Decision Modeling With Spreadsheets

Authors: Nagraj Balakrishnan, Barry Render, Jr. Ralph M. Stair

3rd Edition

136115837, 978-0136115830

More Books

Students also viewed these Programming questions

Question

Discuss the scope of Human Resource Management

Answered: 1 week ago

Question

Discuss the different types of leadership

Answered: 1 week ago

Question

Write a note on Organisation manuals

Answered: 1 week ago

Question

Define Scientific Management

Answered: 1 week ago

Question

Explain budgetary Control

Answered: 1 week ago

Question

List some advantages of using spreadsheets for decision modeling.

Answered: 1 week ago