Robust and secure programming

EasyMediumHard
123456789101112131415161718
Question 13
Easy

Figure 1 shows a Python program that calculates the total ticket cost for an event.

# Figure 1
def compute_total(quantity, base_price, option):
    if option == 0:
        return quantity * base_price
    else:
        return (quantity * base_price) + (quantity * 12)

tickets = int(input("Enter number of tickets: "))
price = int(input("Enter price per ticket: "))
vip_option = int(input("Enter 1 for VIP, 0 for Standard: "))

final_bill = compute_total(tickets, price, vip_option)
print("Total price is: £" + str(final_bill))

Describe one way that the program in Figure 1 could be made more robust.

[1]

Robust and secure programming Questions

  1. GCSE
  2. /Computer Science
  3. /Robust and secure programming