Skip to content

Course home

Robust and secure programming

Robust and secure programming

EasyMediumHard
123456789101112131415161718
Question 1

Figure 1 shows a Python program that calculates the total cost of a hotel stay.

# Figure 1
def calculate_stay(nights, room_rate, meal_plan):
    if meal_plan == 0:
        return nights * room_rate
    else:
        return (nights * room_rate) + (nights * 25)

num_nights = int(input("Enter number of nights: "))
rate = int(input("Enter room rate per night: "))
breakfast = int(input("Enter 1 for breakfast, 0 for room only: "))

total_cost = calculate_stay(num_nights, rate, breakfast)
print("Total cost of stay is: £" + str(total_cost))

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

[1]
Markscheme

Robust and secure programming Questions

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

27 exam-style questions on AQA GCSE Computer Science Robust and secure programming. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank