Ask Question
3 September, 14:25

There are six items to be rung up in the cash register. The first item costs $15.00. Each item after that costs an additional $2.00. (item #2 costs $17, item #3 costs $19, etc.) Create Python program code using a for loop that will print the cost of each item, starting with the $15 item, and it will calculate and print the total cost. Your program should then use the sequence formula as an alternative way to calculate the total cost and print the result.

+2
Answers (1)
  1. 3 September, 15:31
    0
    Below is the python code:

    #using a for loop that will print the cost of each item

    #first item cost is $15.0

    item = [15.0]

    tcost = 0.0

    #for loop to print cost of each item and calculate total cost

    for i in range (6):

    tcost + = item[i]

    print ('Cost of item ', (i+1), ' : $', item[i], sep = '')

    item. append (item[i] + 2)

    #print total cost

    print ('Total cost: $', tcost, sep = '')

    print ()

    #Sequence formula to calculate the total cost

    #total cost = n * ((first + last) / 2)

    print ('Calculating total cost using sequence formula')

    tcost2 = 6 * ((15 + 25) / 2)

    print ('Total cost: $', tcost2, sep = ''
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “There are six items to be rung up in the cash register. The first item costs $15.00. Each item after that costs an additional $2.00. (item ...” in 📘 Engineering if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers