Using Python: I can't get it to loop and then add the total. Here is my code. What am I doing wrong and how would you code this. see attachemnt
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
Using Python:
I can't get it to loop and then add the total. Here is my code. What am I doing wrong and how would you code this. see attachemnt
#Create a variable to control the loop.
total_amount = 0
#Calculate a series of price items.
while total_amount != '0':
#Get the input from the user for the price of the ticket.
ticket_price = float(input("Enter the ticket price of the item or zero to quit: "))
#Get the input from the user for the reduced item.
reduced_item = input("Is this item reduced y/n? ")
#Get the input from the user for the taxable item.
tax_item = input("Is this item taxable y/n? ")
#Display the outputs
print("Bill for this item")
print("Original price $", format(ticket_price, ",.2f"), sep="")
#Check the reduced item.
#If item is reduced, then calculate the reduced price.
reduced = (ticket_price *25) / 100
#Display the reduction
print("Reduction during the event $", format(reduced, ",.2f"), sep="")
#Display the outputs for the final price.
final_price = ticket_price - reduced
print("Final price $", format(final_price, ",.2f"), sep="")
#Calculate the sales tax.
tax_item = (final_price * 7) / 100
tax_item = 0
#Display the output.
print("7% Sales tax $", format(tax_item, ",.2f"), sep="")
#Calculate the subtotal.
sub_total = final_price + tax_item
#Display the output
print("Item subtotal $", format(sub_total, ",.2f"), sep="")
#set accumulator to 0.
total = 0.0
total = total + sub_total
#Display the output for all total items if user does not
#want to price another item.
total_amount = input("Enter the ticket price of the item or zero to quit: ")
print("Total amount due $" ,format(total, ",.2f"), sep="")
![SPC Home Page || St. Petersburg Coll ×
SPC Student Login - One SPC
Module 4 Assignment - COP100 x
b Answered: Write a program that
A https://mycourses.spcollege.edu/d2l/le/content/254774/viewContent/10567653/View
program4_1.py
Refer to the Trader Jane's program in module3. Copy it and enhance it so multiple items can be handled by the program. Use a while loop . This improved
program should output the total for all items.
Sample Output
Enter the ticket price of the item or zero to quit 100
Is this item reduced y/n? y
Is this item taxable y/n? n
Bill for this item
Original price $100.00
Reduction during event $25.00
Final price $75.00
7% Sales tax $0.00
Item subtotal $75.00
Enter the ticket price of the item or zero to quit 100
Is this item reduced y/n? n
Is this item taxable y/n? y
Bill for this item
Original price $100.00
Reduction during event $0.00
Final price $100.00
78 Sales tax $7.00
Item subtotal $107.00
Enter the ticket price of the item or zero to quit 0
Total amount due $182.00
program4_2.py
Write a program that displays a table of inches from 1-12 and equivalent lengths in centimeters. You can find the conversion factor online if necessary. Store
this factor in a properly named constant in your program. Display the inches accurate to one decimal place in a column 6 characters wide and the
centimeters accurate to two decimal places in a column 8 characters wide (see page 71). See Required Output.
11:33 PM
へロ ) G
99+
10/7/2020](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe0aaef3c-a136-4dd2-bb94-354b0a7938d3%2Fc4cbeb5f-9449-41fd-a7a1-a8dae7a2a0cc%2Fds9xe9_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)