Ask Question
6 May, 15:45

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.

+4
Answers (1)
  1. 6 May, 16:12
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers