Write a program in Python that asks the user to enter their premier qualifying flights (PQF) and Premier qualifying points (PQP). The program should display the benefits the user qualifies for. Write the following functions in the program:
determine_status: This function should accept the PQF and PQP as arguments and return the customer's status.
display_benefits: This function should accept a status as an argument and print out the benfits the user has earned:
Here’s a breakdown of what you’ll need to reach each status level:
Silver : 12 PQF and (4,000 PQP or 5,000 PQP)
Gold: 24 PQF and (8,000 PQP or 10,000 PQP)
Platinum: 36 PQF and (12,000 PQP or 15,000 PQP)
Diamond: 54 PQF and (18,000 PQP or 24,000 PQP)
The benefits earned are as follows:
Silver : 1 complimentary checked bag and 7x miles earned on every flight
Gold: 2 complimentary checked bags and 8x miles earned on every flight
Platinum: 3 complimentary checked bags and 9x miles earned on every flight
Diamond: 3 complimentary checked bags, 11x miles earned on every flight, preboarding, and 1 free drink and snack (in ecomony)
Here is what I have:
#ALGORITHM: Ask the user for inputs to be used as the variables
"flights" and "points". Add them together to make the variable
"total". Define main with two functions
#that determine the status and benefits of the user. In the
determine_status function the total is checked against the
associated values of each status then returns
#the status. The display_benefits function gets the status from the
determine_status function then and displays the benefits based on
the status. Then the statement is
#printed.
#flight variable
flights = int(input("Please enter the amount of your qualifying
flights? "))
#point variable
points = int(input("Please enter the amount of your points? "))
#total variable
total = flights + points
def main():
determine_status(total)
display_benefits()
print ("As a", determine_status(total), "member, you have
earned", display_benefits(),"!")
#Checking the total to give the associated status to be used in
display_benefits function.
def determine_status(total):
if total == 4012 or 5012:
return ("silver")
if total == 8024 or 10024:
return ("gold")
if total == 12036 or 15036:
return ("platinum")
if total == 18054 or 24054:
return ("diamond")
#Checking the determine_status function to return the benefits
for the associated status.
def display_benefits():
if determine_status(total) == "silver":
return ("1 complimentary checked bag and 7x miles earned on every
flight")
if determine_status(total) == "gold":
return ("2 complimentary checked bags and 8x miles earned on every
flight")
if determine_status(total) == "platinum":
return ("3 complimentary checked bags and 9x miles earned on every
flight")
if determine_status(total) == "diamond":
return ("3 complimentary checked bags, 11x miles earned on every
flight, preboarding, and 1 free drink and snack (in ecomony)")
main()
It keeps returning silver. Please don't try to make it too fancy. I want to just understand what I have messed up on in my code.
Thank you.
The mistake is in the determine_status function.Just change the if statements from (if if total == 4012 or 5012) to (if total == 4012 or total == 5012)
Because the or operator in python on operands returns the first operand if they are non zeros.
for example 5 or 6 returns 5
0 or 6 return 6
so in the determine_status function the if total == 4012 or 5012 always executes and return silver.
CODE:
Output:
Raw Code:
def determine_status(total):
if total == 4012 or total == 5012:
return ("silver")
if total == 8024 or total == 10024:
return ("gold")
if total == 12036 or total == 15036:
return ("platinum")
if total == 18054 or total == 24054:
return ("diamond")
def display_benefits():
if determine_status(total) == "silver":
return ("1 complimentary checked bag and 7x miles earned on every
flight")
if determine_status(total) == "gold":
return ("2 complimentary checked bags and 8x miles earned on every
flight")
if determine_status(total) == "platinum":
return ("3 complimentary checked bags and 9x miles earned on every
flight")
if determine_status(total) == "diamond":
return ("3 complimentary checked bags, 11x miles earned on every
flight, preboarding, and 1 free drink and snack (in
ecomony)")
flights = int(input("Please enter the amount of your qualifying
flights? "))
points = int(input("Please enter the amount of your points? "))
total = flights + points
def main():
determine_status(total)
display_benefits()
print ("As a", determine_status(total), "member, you have earned", display_benefits(),"!")
main()
Hope you have understand.if you have any doubts or if you want any modifications.please comment.
Thank you.rate my answer.
Write a program in Python that asks the user to enter their premier qualifying flights (PQF)...
Project 1, Program Design 1. Write a C program replace.c that asks the user to enter a three-digit integer and then replace each digit by the sum of that digit plus 6 modulus 10. If the integer entered is less than 100 or greater than 999, output an error message and abort the program. A sample input/output: Enter a three-digit number: 928 Output: 584 2. Write a C program convert.c that displays menus for converting length and calculates the result....