Question 1[10 marks]
Oksana has created the following program in her computer science lesson. The aim of this program is to calculate the price after discount of a list of products bought by a customer.Here is her Python code:
#Discount Price Calculator
def calculateDiscount(price,percentageDiscount):
discount = price * percentageDiscount / 100
discount = round(discount,2)
return discount
#Main Program
item = input("Enter the name of the item to buy? or X to quit!")
while item!="X":
itemPrice=float(input("Enter a price for your item: £"))
percentageDiscount = int(input("Enter a percentage discount for your item: %"))
discount = calculateDiscount(itemPrice, percentageDiscount)
newPrice = itemPrice - discount
print("Discounter price: £" + str(newPrice))
item = input("Enter the name of another item to buy? or X to quit!")
To help Oksana use the right terminology when annotating and explaining what her code does, you will need to answer the following 10 questions:
- What is the identifier of the subroutine defined in this code?
- Is this subroutine a procedure or a function? Why?
- How many parameters does this subroutine take?
- What programming construct is this subroutine based on: sequencing, selection or iteration?
- Which line of code will be executed first by the computer when you run this code?
- What programming construct is the main program based on: sequencing, selection or iteration?
- Can you identify three variables used in the main program?
- What is the data type of item?
- What is the data type of discount?
- On which line of code is string concatenation used?
1)
2)
3)
4)
5)
6)
7)
8)
9)
10)
Question 2[4 marks]
Without rewriting the above code, explain how Oksana could improve this code further to calculate and output the total discounted cost of all the items being bought by a customer?

Solution...
The solution for this challenge is available to full members!Find out how to become a member:
➤ Members' Area






