Python function script using this function: def cadProvince(postal,shortForm): Convert a valid Canadian Postal Code to a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Python function script using this function: def cadProvince(postal,shortForm): Convert a valid Canadian Postal Code to a Canadian Province The first letter of a Postal Code tells us which province the Postal Code is from. Here's the list of Provinces/Territories, their 2-letter short form, and the first letter(s) of the Postal Code that matches it: Province Name Short Form First Letter of Postal Code K, L, M, N, P G, H, J B Ontario Quebec Nova Scotia New Brunswick Manitoba British Columbia Prince Edward Island Saskatchewan Alberta ON ас NS NB MB BC PE SK AB Newfoundland and Labrador NL Nunavut, Northwest Territories NT Yukon YT E R V C T A X Y The toProvince() function converts a valid postal code to a province name. Use your isPostalCodeValid() function from the previous problem to validate the postalCode argument first. If it is invalid, return 'null'. If the useShortForm argument is true, the province's short-form is returned instead of the full name. For example: - to Province('M5W 1E6', Flase) returns 'Ontario' - to Province('M5W 1E6', Flase) returns 'Ontario' - to Province('M5W 1E6', true) returns 'ON' - to Province('M5W', Flase) returns null Python function script using this function: def cadProvince(postal,shortForm): Convert a valid Canadian Postal Code to a Canadian Province The first letter of a Postal Code tells us which province the Postal Code is from. Here's the list of Provinces/Territories, their 2-letter short form, and the first letter(s) of the Postal Code that matches it: Province Name Short Form First Letter of Postal Code K, L, M, N, P G, H, J B Ontario Quebec Nova Scotia New Brunswick Manitoba British Columbia Prince Edward Island Saskatchewan Alberta ON ас NS NB MB BC PE SK AB Newfoundland and Labrador NL Nunavut, Northwest Territories NT Yukon YT E R V C T A X Y The toProvince() function converts a valid postal code to a province name. Use your isPostalCodeValid() function from the previous problem to validate the postalCode argument first. If it is invalid, return 'null'. If the useShortForm argument is true, the province's short-form is returned instead of the full name. For example: - to Province('M5W 1E6', Flase) returns 'Ontario' - to Province('M5W 1E6', Flase) returns 'Ontario' - to Province('M5W 1E6', true) returns 'ON' - to Province('M5W', Flase) returns null
Expert Answer:
Answer rating: 100% (QA)
Heres a Python script that defines the cadProvinceunction as described python Define a dictionary to map postal code prefixes to province names and sh... View the full answer
Related Book For
Financial Reporting Financial Statement Analysis and Valuation a strategic perspective
ISBN: 978-1337614689
9th edition
Authors: James M. Wahlen, Stephen P. Baginski, Mark Bradshaw
Posted Date:
Students also viewed these programming questions
-
Discuss the factors of career adaptability and how career adaptability links with a protean career.?
-
The following table lists the median family incomes for 13 Canadian provinces and territories in 2000 and 2006. Compute the mean and median for each year and then compare the two measures of central...
-
In problem 3.8, you computed mean and median income for 13 Canadian provinces and territories in two separate years. Now compute the standard deviation and range for each year, and taking account of...
-
You would like to buy a house in in 16 years and estimate that you will need a deposit of $73,014. You plan to make bi-weekly deposits into an account that you hope will earn 7.05%. How much do you...
-
A particle of mass m slides down and inclined plane under the influence of gravity. If the motion is resisted by a force ∫ = kmv2, show that the time required to move a distance d after starting...
-
The asymmetric bar shown has a weight of 7.6 N and a centre of gravity that is 0.040 m from the wider end, on which there is a load of 3.3 N. It is pivoted a distance of 0.060 m from its centre of...
-
The following table gives the vapor pressure of water for various temperatures a. Plot a scatter diagram. Does it seem likely that a straight-line model will be adequate? b. Fit the straight-line...
-
Heller Manufacturing has two production facilities that manufacture baseball gloves. Production costs at the two facilities differ because of varying labor rates, local property taxes, type of...
-
Write a Brute force algorithm to find all the common elements in two lists of integer numbers. (e.g., the output for the lists [1, 3, 4, 7] and [1, 2, 3, 4, 5, 6] should be 1, 3, 4). Show the time...
-
Suppose your tax rate is 23% and you want to purchase a municipal bond of $1,750 for 9% interest. At what interest rate on a for-profit bond , before tax, would you be indifferent between the two...
-
The ABC Company employs 20 janitors in three locations in any Ontario city. The janitor's job duties include lifting 22 kilograms (50 pounds) containers that contain 4 pails of cleaner and wax to...
-
LP has application in many fields. The planning of consumer surveys can be a tool in the area of a. operation analysis. b. media optimisation. c. portfolio risk assessment. d. marketing research. e....
-
What benefits do airlines attempt to obtain through an alliance? Why doesnt an airline simply add the new destinations it wishes to serve instead of entering an alliance?
-
Among the assumptions for the formulation of an LP problem, there is linearity. What does it mean in practice, and why it is important?
-
Provide an example of a domestic alliance and an international alliance.
-
What is sensitivity analysis? Why should sensitivity analysis consider all possible consequences?
-
8. Describe each of the following types of isomerism (i) geometrical isomerism (2 marks) (ii) solavate isomerism (2 marks) (iii) coordination isomerism (2 amrks)
-
Ashlee, Hiroki, Kate, and Albee LLC each own a 25 percent interest in Tally Industries LLC, which generates annual gross receipts of over $10 million. Ashlee, Hiroki, and Kate manage the business,...
-
Kentucky Gold (KG) holds 10,000 gallons of whiskey in inventory on October 31, 2017, that costs $225 per gallon. KG contemplates selling the whiskey on March 31, 2018, when it completes the aging...
-
Explain residual ROCE (return on common shareholders equity). What does residual ROCE represent? What does residual ROCE measure?
-
Suppose the following hypothetical data represent total assets, book value, and market value of common shareholders equity (dollar amounts in millions) for Abbott Labs, IBM, and Target Stores. Abbott...
-
As problems 5.18 and 5.19 reflect, the air temperature in the test section of conventional hypersonic wind tunnels is low. In reality, air liquefies at a temperature of about \(50 \mathrm{~K}\)...
-
The reservoir temperature calculated in problem 5.20 is beyond the capabilities of heaters in the reservoir of continuous-flow wind tunnels using air. This is why you do not see a Mach 20...
-
Write the \(y\) component of Eq. (6.7), and use it to derive Eq. (6.12). Equation 6.12: \(\frac{\partial(ho v)}{\partial t}+abla \cdot(ho v \mathbf{V})=-\frac{\partial p}{\partial y}+ho f_y\) V pfd7...
Study smarter with the SolutionInn App