# Shopping cart exercise foods = [] prices = [] total = 0 while True: food = input("Enter a food to buy (q to quit): ") if food.lower() == "q": break else: price = float(input(f"Enter the price of a {food}: $")) foods.append(food) prices.append(price) print("----- YOUR CART -----") for food in foods: print(food, end=" ") for price in prices: total += price print() print(f"Your total is: ${total}")
@SemuaTentangIkanIlham2 жыл бұрын
Thanks friend .
@deedee9713 Жыл бұрын
How do u add quantity?
@yuenlin2-1424 ай бұрын
Can you explain how we could allow the user to remove foods from their cart?😢
@TeckTalesАй бұрын
@@yuenlin2-142 instead of append use remove inside your if statement
@apathy251 Жыл бұрын
BROOO you are the best i just started learning pyhton and i couldnt get shit how the teacher explained stuff than i started to watch your vidyia and holy shit you explain it so well and easy to understand.
@PonderP3785 ай бұрын
Napaka simple ng explanation at madaling maintindihan. Salamat!
@mashapetrovka4302 ай бұрын
I wanted it to show the name and price for each line so I did this instead # shopping cart program foods = [] prices = [] total = 0 while True: food = input("Enter a food to buy (q to quit):") if food.lower() == "q": break else: price = float(input(f"Enter the price of a {food}: $")) foods.append(food) prices.append(price) print("------YOUR-CART------") for food, price in zip(foods, prices): print(food, f" {price}") total += price print(f"Your total is: ${total}")
@skyisthelimpet2 жыл бұрын
Nice exercise for beginners, great work
@脱不完的头发8 ай бұрын
通俗易懂有逻辑!谢谢大佬!
@r2id_yt11 ай бұрын
Thank you my friend
@tara23378 ай бұрын
I had so much fun with my shopping cart list program😁
@user-ze5vx6vf3n6 ай бұрын
the best tutorial that i finded
@gaddafisuleiman88822 жыл бұрын
Finally! You're awesome, Bro!
@GeniusBro-qw8no9 ай бұрын
Wrote this before watching video item = [] prices= [] print (f"Hello this is a shopping list") print ("if you want to quit press q") while True: f = (input(f"what would you Like to add:")) if f == ("q"): break else: item.append(f) while True: try: p = (int(input("what is the price of the item:$"))) prices.append(p) break except ValueError: print ('please input a proper integer!') items = len(item) #print(f"total items: {item}") #print(f"total prices: {prices}") for item, price in zip(item, prices): print(f"- {item}: ${price}") print(f"total number of items:{items}") print(f"Price of all items: {sum(prices)}")
@oriantiktokАй бұрын
WOWWWW amazing
@eyalsilbershtein57652 жыл бұрын
That exercise was great! Can you do some more advanced coding Technics?
@nicolewynne47812 жыл бұрын
Please could you do PHP beginner full course? Your videos are like an oasis in the desert for people like us who have financial struggles. Thanks a million BRO!!!
@b1.7.32 жыл бұрын
PHP is not really worth learning if you dont know it already, imo Express.js is way better to learn.
@noliyeb Жыл бұрын
@@b1.7.3why is it not worth learning?
@VAIBHAVMALHOTRA196 ай бұрын
Don't listen to that person who said php isn't worth it. It is still worth it and I know people who got employed to work on the php.
@nadyashaymardanova6000 Жыл бұрын
Очень интересно
@22AT1A04CSKNATIQAHMED Жыл бұрын
digital clock import time p=input("specify whether ypo are entering time in hours or minutes or seconds:") t=int(input("Enter time:")) if p == "hours": t=t*60*60 elif p=="minutes": t*=60 else: t=t for x in range(t,0,-1): sec=x%60 min=int(x/60)%60 hour=int(x/3600)%60 print(f"{hour:02}:{min:02}:{sec:02}") time.sleep(1) print("Time is up!")
@mwaijames313 Жыл бұрын
Surprisingly, I am getting an " unsupported operand type(s) for +: int and list" error. Here is my code foods = [] prices = [] total = 0 while True: food = input(" Enter a food to buy('q' to quit): ") if food.lower() == "q": break else: price = float(input(f"Enter the price of a {food}: Kshs ")) foods.append(food) prices.append(prices) print ("-----Your Cart -----") for food in foods: print (food, end= ' ') for price in prices: total += price print(f"Your total is Kshs{total}") What could be wrong here?
@mwaijames313 Жыл бұрын
Silly me. 🤣🤣🤣. I had written prices.append(prices) rather than prices.append(price).
@BinaryBites248 Жыл бұрын
in prices.append(prices) you had put prices with a s
@jennifersilves4195 Жыл бұрын
It's always like that. Glad you found the bug.
@tennybabcock51465 ай бұрын
i think a line of code where you can only enter string for items and float for price would be good
@22AT1A04CSKNATIQAHMED Жыл бұрын
shopping cart program foods=[] prices=[] total=0 while total>=0: food=input("Enter the item (q to quit): ") if (food=="Q")or(food=="q"): break else: price=float(input(f"The price of the item is $")) foods.append(food) prices.append(price) print("******Your items are******") for food in foods: print(food) for price in prices: total+=price print(f"your total is {total}")
@КириллБашков-ь9ж2 жыл бұрын
good work! Let's try write this program on C# )
@kristijanlazarev9 ай бұрын
awesome
@michaelsantiago57372 жыл бұрын
More exercise please
@gamePlays96992 жыл бұрын
GREAT!
@bashar87652 жыл бұрын
Really like those, keel them going buddy!
@timecop1983Two Жыл бұрын
Don't stop bro!!! Greate videos
@FactlessFact-ByRaji10 ай бұрын
can you come up with a program or project connecting python with any database like mysql ...
@parkashvyas5252 Жыл бұрын
Thank you so much.
@space7nstuff94 Жыл бұрын
What's the purpose of the f in the beginning on the string?
@prizepig2 жыл бұрын
Thanks for the lessons
@nalanihamby3710 Жыл бұрын
I’m so confused, I’ve got everything typed exactly as it is on the video but when I get to the price it throws an error and tells me ‘str’ object has no attribute ‘append’ why clue what I am doing wrong?
@sarahmadrid6606 Жыл бұрын
print needs to be changed to a float: total += float(price)
@adilivni8688 Жыл бұрын
And he did not tell us😤
@synxedits25 Жыл бұрын
@@adilivni8688 he did, actually 3:11
@Pawfessor14 ай бұрын
skill issue
@Emmanuel-l7y1h3 ай бұрын
Same
@ManideepGampa2 жыл бұрын
Great work bro❤️❤️❤️
@adilivni8688 Жыл бұрын
You should give flow to the price +=
@oxygen15332 жыл бұрын
broooo, please tell us how to make money as beginner programmer
@BelleMosa8 ай бұрын
Can you make a video with a coffe shop?
@aissaboukrikeb15918 ай бұрын
what if the user enter letter not number in price? HOW WE CAN FIXIT
@sakshamkarna9041 Жыл бұрын
cool
@damioni50647 ай бұрын
instead of print() can i use print(" ")
@celestepozzi9204 Жыл бұрын
youre so smart, i cant figure out the foods.append(food) i cant fix it, it means my knowledge in python is still off
@anonymousx_x3842 Жыл бұрын
i was stuck at the same point as you but look at the name of empty list for "foods" we declared at starting. then look at the "food" variable we use to get the input. now look at the append(). the error is because of the wrong variable name we are giving.
@harrybean32442 жыл бұрын
NOW THAT IS GIGA :) I rate it giga/10
@viktorbihar85999 ай бұрын
Number 15: Burger King Foot Lettuce. bro's voice reminds me of this meme, lol.
@corexx2 жыл бұрын
You are the best bro code, i hope you see this!
@techwithdavid2 жыл бұрын
Nice one 👍
@ricodexr2 жыл бұрын
🛒
@TermiTech20112 жыл бұрын
How you enjoy the Dracula theme in pycharn?
@setok52312 жыл бұрын
Can you make a video how to create round button in java pls😢
@Beeposky Жыл бұрын
how do you declare a list? ive atempted to make something similar to this but my lists are getting the undeclared error
@calowed2 жыл бұрын
is there a way to add taxes? like a percentage that adds onto the total.
@piyushbhalwalkar2218 Жыл бұрын
yes , just add your math for tax on to the total
@touchedbygod2358 ай бұрын
I got everything in 4:45 but it is saying error on line 12 did you mean price
@adilivni8688 Жыл бұрын
You forgot to put flow in the price.
@ratulmitra3476 ай бұрын
price=float(input(f"enter the price of a {food}: ₹'')) This line is wrong? I don't understand.... SyntaxError: unterminated string literal (detected at line 9) This is showing
@thuvarahathavakkumar1438Ай бұрын
{food} which is wrong you have rewrite (food) like this
@keikoo3282 Жыл бұрын
And pay in Bitcoin ?
@ronitsworld93882 ай бұрын
his typing speed fr 💀💀💀
@DogasNetwork Жыл бұрын
@Bro Code which IDE are you using? 🙂
@Not_AltAccount10 ай бұрын
What was the program to code Python again?
@xMythric9 ай бұрын
There are many types of programs based on your device. For example you could use the official python app on a computer which is the one he uses or i use pyto because i code python on an ipad
@adamesmail8 ай бұрын
hello
@noahschmidt79968 ай бұрын
Why does my list say q q q?
@DesiredFactsDaily Жыл бұрын
Bruhhhhhhhhhhhhhhhhhhhhhh.....Im here
@RaytonSatkek Жыл бұрын
class Product: def __init__(self, product_id, product_name, unit_price): self.product_id = product_id self.product_name = product_name self.unit_price = unit_price def display_product_details(self): print("Product ID:", self.product_id) print("Product Name:", self.product_name) print("Unit Price:", self.unit_price) # Example usage: product1 = Product(1, "Widget", 10.99) product1.display_product_details() Tried running on PC and not working, please help
@aFirmae Жыл бұрын
Ok, so I tried making this output look better, but failed at displaying the cart with proper alignment, can anyone help? I think this line of the code needs to be modified, print(f"{i}. {food.capitalize()} x {quantity:
@aFirmae Жыл бұрын
I want the "YOUR CART" to look like: ---------------- YOUR CART ------------- 1. Pizza x 4 $23.96 2. Hamburgers x 3 $10.5 3. Hotdogs x 2 $ 3.0 --------------------------------------------------
@aFirmae Жыл бұрын
Sample Output: Enter your food products. Press Enter to quit. 1. pizza Price of pizza: 5.99 Number of pizza: 4 2. hamburgers Price of hamburgers: 3.50 Number of hamburgers: 3 3. hotdogs Price of hotdogs: 1.50 Number of hotdogs: 2 4. --------- YOUR CART ----------- 1. Pizza x 4 $23.96 2. Hamburgers x 3 $10.5 3. Hotdogs x 2 $3.0 ---------------------------------------- Your total is: $37.46
@DannLopez-l4n10 ай бұрын
I MADE THIS CODE, THIS IS BETTER, IT MAKES IT VERTICAL LIKE A RECIPT 👇 #Declare variables foods = [] prices = [] total = 0.0 while True: food = input("Enter a food to buy: (press q to quit): ") if food.lower() == "q": break else: price = float(input(f"Enter the price of {food}: $")) foods.append(food) #This will put the values of food to foods prices.append(price) print(" -------YOUR CART-------") j = 0 for x in foods: print(f"{x: