0
Help me to understand this. I’m stuck.
You’re making a shopping cart program. The shopping cart is declared as a list of prices, and you need to add functionality to apply a discount and output the total price. Take the discount percentage as input, calculate and output the total price for the shopping cart
6 Respostas
0
I'm also a self learner.
Apart from solving questions, it is a good practice to read others' code. We can learn many things by going through the code of other members who has solved a particular challenge.
Python for beginners is easy to complete. But, it touches only the surface. If you really want to learn in depth, you can try Python Core, after beginners.
+ 1
Yes, you don't have to print the price of each item after discount. Only print the total cost after discount. So, the print function should be outside the loop.
+ 1
Thank you! Very helpfull. By the way, im studying Python by myself to get involved in asociated jobs.
I started with beginning course to improve by time from 0.
Do you have any other tips you want to offer me? Am i in the right path to become proffecional?
0
Given: The price of items in a shopping cart as a list
To do:
(i) Accept the discount percentage as input
[Do not forget that input() function returns a value of the data type 'String']
(ii) Use a for loop and iterate through each item in the cart and calculate the total price after applying discount
[Formula is already given
For X% discount on $Y price: Y - (Y*X/100)]
If your input is x and y is the price, then iterate the for loop with y.
Eg: cart = [ ]
x = int(input())
total = 0
for y in cart:
total = ________
print(total)
0
Still broke!
I think if i add the formula to total each time, and i take print function outside for loop, then it should work.
for y in cart:
Total+= y-(y*x/100)
print(total)
0
Thank you☺ All the best to your learning!!