Question

Here are the actual Canada Post postage rates for standard and non-standard or oversize envelopes to be delivered to the U.S.A. or Canada: USA $1.20 $1.80 USA $2.95 $5.15 Standard Letter Canada $0.85 $1.20 Canada $1.80 $2.95 $4.10 $4.70 $5.05 Up to 30g Over 30 g up to 50 g Other Letter Up to 100 g Over 100 g up to 200 g Over 200 g up to 300 g Over 300 g up to 400 g Over 400 g up to 500 g $10.30 The user must enter USA or Canada for the destination country - your program must treat any other entry as an error. The user can enter y, when prompted, if the envelope is of a standard size - any other entry means other. He can supply a number for the weight which must lie between O and 500 grams, unless the envelope is of standard size, where the weight must be less than or equal to 50 grams. If the user enters a weight over 50 grams for a standard envelope, change the envelope size to non-standard and continue on after telling the user that this is what you are doing Your program for this part must obtain these three pieces of information and thern output the postage rate.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is a code in python 3:

country = input("Enter country? ")
if country not in ['USA','Canada']:
    print("Postage only available for USA and Canada")
    exit(1)
size =''
cost = 0.0
choice = input("Enter 'y' for standard size: ")
weight = int(input("Enter weight? "))
if weight > 500:
    print("Weight cannot be greater than 500gms.")
    exit(1)
if choice is 'y':
    size = 'standard'
    if weight > 50:
        size = 'other'
        print("Since weight is above 50gms, the size has been changed to other")
else: size = 'other'

if country == 'Canada':
    if weight <= 30: cost = .85
    elif weight <= 50: cost = 1.2
    elif weight <= 100: cost = 1.8
    elif weight <= 200: cost = 2.95
    elif weight <= 300: cost = 4.1
    elif weight <= 400: cost = 4.7
    else: cost = 5.05
if country == 'USA':
    if weight <= 30: cost = 1.2
    elif weight <= 50: cost = 1.8
    elif weight <= 100: cost = 2.95
    elif weight <= 200: cost = 5.15
    else: cost = 10.3
print("Postage Rate: %.2f" %cost)

1 country input( Enter country? ) 2 やif country not in [USA 4exit(1) 6 Canada]: print(Postage only available for USA an

Sample Output:

nome/arka/Docüments/HomeworkLib/venv7bin/python /home/arka/Documents/che Enter country? Enter y for standard size: Canada Since w

Add a comment
Know the answer?
Add Answer to:
Here are the actual Canada Post postage rates for standard and non-standard or oversize envelopes to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the...

    SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the company's new line of single-serve coffee pods or to await results from the product's launch in the United States. Key strategic decisions include choosing the target market to focus on and determining the value proposition to emphasize. Important questions are also raised in regard to how the new product should be branded, the flavors to offer, whether Kraft should use traditional distribution channels or...

  • The following guidelines outline the basic template for a robot vacuum cleaner game. The game must be implemented in c programming language. It mimics a robotic vacuum cleaner. The code must only use...

    The following guidelines outline the basic template for a robot vacuum cleaner game. The game must be implemented in c programming language. It mimics a robotic vacuum cleaner. The code must only use the following libraries: #include <math.h> #include <stdlib.h> #include <string.h> #include <limits.h> and any .graphics and .timers libraries. The guidelines are outlined as follows: Terminal Set-up: you may assume that the terminal will be quite large, for example, on the order of 150×50, or more. Status Display: The...

  • The following guidelines outline the basic template for a robot vacuum cleaner game. The game must...

    The following guidelines outline the basic template for a robot vacuum cleaner game. The game must be implemented in c programming language. It mimics a robotic vacuum cleaner. The code must only use the following libraries: #include <math.h> #include <stdlib.h> #include <string.h> #include <limits.h> and any .graphics and .timers libraries. The guidelines are outlined as follows: Terminal Set-up: you may assume that the terminal will be quite large, for example, on the order of 150×50, or more. Status Display: The...

  • 10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated...

    10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT