(WRITE IN PYTHON) For this program you will be writing a program that will use i
ID: 3743561 • Letter: #
Question
(WRITE IN PYTHON) For this program you will be writing a program that will use if-else or if-elif-else statements.
Read-It-All bookstore has a book sales club where customers can earn reward points that can be used for their next purchase.
If a customer purchases 0 books, he/she earns 0 points.
If a customer purchases 1-2 books, he/she earns 5 points.
If a customer purchases 3-4 books, he/she earns 10 points.
If a customer purchases 5-6 books, he/she earns 15 points.
If a customer purchases 7-8 books, he/she earns 20 points.
If a customer purchases 9 or more books, he/she earns 25 points.
Write a program that asks the user to enter their name (First and last name), and the number of books that he or she has purchased this month and displays their name and the number of points they have earned for the month.
REMEMBER to put your name on the lab with comments, and write comments in the program to tell what the program is doing.
Data for the program:
Mary Smith 5 books
John Franklin 1 book
Stewart Jones 0 books
Marvin Applegate 7 books
Ernestine Miller 8 books
Francis Butterworth 3 books
Arlene Cooper 0 books
Maryanne Fisher 2 books
Andrea Martin 10 books
Larry Andrews 9 books
Explanation / Answer
name = input("Enter your name:")
books = int(input("Enter the number of books you have purchased this month:"))
points = 0
if(books >= 9):
points = 25
elif(books >= 7):
points = 20
elif(books >= 5):
points = 15
elif(books >= 3):
points = 10
elif(books >= 1):
points = 5
print(name, "earned", points,"this month")
''' SAMPLE OUTPUT
Enter your name: Mary Smith
Enter the number of books you have purchased this month: 5
Mary Smith earned 15 this month
Enter your name: Larry Andrews
Enter the number of books you have purchased this month: 9
Larry Andrews earned 25 this month
'''
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.