SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Tony Gaddis
Chapter:
Decision Structures And Boolean Logic
Exercise:
Programming Exercises
Question:7 | ISBN:9780132576376 | Edition: 2

Question

Serendipity Booksellers has a book club that awards points to its customers based on the number of books purchased each month. The points are awarded as follows:

If a customer purchases 0 books, he or she earns 0 points.

If a customer purchases 1 book, he or she earns 5 points.

If a customer purchases 2 books, he or she earns 15 points.

If a customer purchases 3 books, he or she earns 30 points.

If a customer purchases 4 or more books, he or she earns 60 points.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

# Program to calculate the points earned by customers at Serendipity Booksellers

# Ask the user to input the number of books purchased
books = int(input("Enter the number of books purchased: "))

# Set the points earned to 0 initially
points = 0

# Check the number of books purchased and assign the points accordingly
if books == 0:
    points = 0
elif books == 1:
    points = 5
elif books == 2:
    points = 15
elif books == 3:
    points = 30
else:
    points = 60

# Print the points earned
print("You have earned", points, "points")

OUTPUT 1:

Enter the number of books purchased: 22
You have earned 60 points

OUTPUT 2:

Enter the number of books purchased: 2
You have earned 15 points

 

 

0 0

Discussions

Post the discussion to improve the above solution.