Ordering a Pizza with Python - Tutorial 4 - Payment Information

Tech With Tim · Beginner ·🧠 Large Language Models ·6y ago

Key Takeaways

This video tutorial demonstrates how to use Python to collect user payment information for ordering a pizza, utilizing the Python Domino's API and various tools such as Kite and console.pi. The tutorial covers refining previous code, calculating order totals, and validating credit card information.

Full Transcript

hello everybody and welcome to the fourth video in the ordering a pizza with Python series now what we're gonna be doing in this video is just wrapping up kind of showing the items that are on someone's border I'm gonna show you how we can remove items from the order although I'm not really gonna implement like a script that does that for us we're actually gonna some how much all of the items that we've decide to order cost and then we're going to display that to the user and then ask them for their credit card information so they can insert that and pay and place their order so hopefully we'll wrap up everything in this video that we might extend into another one depending on how long this takes and as always a reminder and thank you to our sponsor kite for sponsoring this tutorial series they're the ones that are providing all these awesome auto completions you can see like even when I'm just typing print it gives me the completions from kites when I've been using some different things in the API it's been giving me a lot of useful suggestions for all the different methods so for example these methods are not built into a library like they're just from the IB the API Pizza API and kite is giving us those completions so anyways you can download that for free and a link in the description alright so let's get started now what I want to do is display not only what the code of a specific item is but I'd like to show the name of that item as well as how much that item costs so to do that what we need to do is look at all the information we have about a specific item so I kind of whiz through this in the last video but essentially what we've done here is we said for item in order dot data products now products stores all of the specific items that we've added into our order and all of those items have some information associated with them like for example a code so let's just print out the item which we actually ended up doing in the previous one so let's clear that and have a look at what this is so let's look for an item so let's look for just I don't know Pepsi like that there's no results for Pepsi okay so let's add something else so let's say yes let's look for a pizza what we want um I like this one so we'll take that can I paste that in here no I cannot so I'll just type in 112 T s I X enter nope that's all we need and we can see this is all the information we have about our item so quantity one price 1974 we're is the price there's just like all this information that we have associated with this we have the name so twelve inch thin six cheese pizza we have what else flavor code product code code price so we're gonna use the price tag as well as the name tag to display this item in a list for us so what I'm gonna do is simply do item name plus and in this case I'm gonna do a space a dollar sign like that and then plus item price and make sure that we have a capital P on our price and a capital n on our name so doing this should actually print out the items name and then the price but I also want to collect all these prices and add them together so what I'm gonna do is take this I'm gonna say price equals that will do stupid loss price in here and now what I'm gonna do is say total equals zero so this is gonna stand for order total and I'm gonna say total plus equals and in this case we're just gonna say float price like that so now we should be collecting the total in this total variable and at the end once we've listed all of our items we can say your or your order total so your if I could type correctly here border total is Poland Plus and in this case we'll just do string total like that and we actually might want to add a dollar sign like so okay so this should tell us how much our order total is and then after this we can ask for the credit card information which is what we'll do next so let's run this python tutorial dot pi you're now searching the menu look for an item let's just go for you know sprite like that so please type the code to the items you'd like to order press ENTER to stop ordering okay so let's just get a 500 milliliter sprite so 500 sprite like that and stop now let's actually look for another item so let's get some kind of pizza so what's an easy one to type we have 10s cc-can okay so 10 SC can I think that was right let's see SC and okay and then we'll say no we don't want anything more so these are two items we have a 500 milliliters sprite which is 177 a 10-inch hand to US Canadian pizza which is $13.99 and our order total is 15 dollars and 76 cents awesome so let's actually just separate the order total so it goes it down one line for us a little bit easier to read and now we need to talk about tax so tax is interesting because this is gonna depend really on what state you live in or what province or even what country you live in so I don't really know a way to get the tax rate from the API so what I'm gonna recommend to you guys if you care to actually implement tax into this and I might just even do a little plus sign and say plus tax so that people know that you know that is you know you need tax on top of that actually will do plus tax like that you could hard code some like tax variable up here and you can say like tax rates equals and in Canada for me where I live it's one point one three so 13% tax which is like very high but I know in some states it's like 7% so you do 1.07 and then you could just multiply whatever this number is so whatever this price number is by that tax rate and display that now that's up to you guys I just figured I mentioned that beeps in case anyone you know is gonna get mad at me in the comments for not including the tax okay so now that we've done that what we're gonna do is ask the user to insert their credit card information so they can actually place this order before we do that though I will show you that if you want to remove an item from your order you can use order dot remove item and then you can use just the code of that item and it will actually remove it for you so if you guys do want to implement that or create a more complicated program than what I'm showing you then you can do that because the point of this is not really to make like a fully functioning program it just to show you guys how to work with this and how we can actually use kind of some weird strange API switch this is okay so how are we gonna get the credit card information well fortunately for us I've actually written a kind of extension to this API called console dot pi you guys can have a read through it I documented it fairly well that actually has a method inside of here that will get a user's credit card information from the console so all we need to do is say card which is here is equal to and in this case it's going to be console input get underscore credit underscore card I believe that's correct we'll have a look here so get underscore credit underscore card and obviously since we're using console inputs what we need to do is import that from here so we'll say console input at the top like that and now we can actually use that to get the credit card and I'm going to show you what this does so inside of here this is what this method is that we're calling it asks for the payment information it says please enter your credit card information enter your credit card number expiry date security code zip postal code and then it actually checks to make sure this is a valid credit card before it returns it to us if we have an exception that what it does is simply calls this method again and keeps asking the user to insert their credit card so what we're gonna do now is say python tutorial dot pi we're gonna say you're looking on the menu okay so let's go for Coke let's go 500 Coke like this just because it's easy and then we'll say nope that's all we want okay so we can see your order is as follows 500 milliliter coke your order total is 177 plus tax payment information please enter your credit card information this information will not be saved so now we can insert a card number a expiry date three digit security code and zip slash postal code obviously this is an invalid card which had just told us so it's asking for the payment information again but once you insert valid payment information then you can actually pay and make the order so this is kind of the part of the tutorial series where like if you don't want a pizza to test this out just insert like some fake credit card numbers that are technically valid but aren't gonna have any you know numbers on them and then after this what we can do is actually place the order and see if we're gonna get a pizza now I'm gonna save that for the next video I think cuz I actually want to use this to order a pizza to my house and like make sure this works and show it to you guys but for now I think I might leave it at that so essentially what we've done is we've got the credit card information we have implemented kinda yeowwww this is what the tax is going to be for your order we've added up that we've looked at how we can use this console input and actually I'll add one more thing because we're not quite at ten minutes for this video yet we'll just extend it a little bit we can actually use this console input which I've created here to get some customer information when we're creating an order so for right now you see we've actually hard-coded the customer object up here so we've said you know this is all the information but we can actually do is simply use a method from console input which I'm gonna show you to do this we're gonna say console input dot get customer like this you can see we have get customer I'm actually gonna do get new customer and what this is gonna do and I'll show you because I've kind of programmed this slightly complex is ask the user to insert their information and then will actually save that information into a folder so that we can access it faster the next time we want to make an order so here we can say to start an order you must provide the following details country if you're ordering from Canada please type yes now so we type yes name please enter your name so it's Tim into your last name we'll do it tech insert your email address so we'll go Tim at Tech with Tim dotnet enter your phone number so we'll go nine oh five seven seven seven seven seven seven seven and then address we need to insert something here so I'm just gonna say forty Bay Street Toronto Ontario what was the postal code of this that's a good question I need to just look at the postal code here before I can insert this so that was whoops let's go over here so m5j x2 okay so let's paste that in there hit enter and then there we go it shows us the closest store so which is that asks us for the menu let's look for Coke we can add items to our order now so 500 coke no we don't want to add anything more assets for our payment information and there we go we've pretty much almost finished this program so anyways that has been it for this video you guys can mess around with this looking console input if you want to see what I've actually written here and kind of how this works and how these things are validated and with that being said if you guys enjoyed make sure you leave a like subscribe to the channel in the next video we will be ordering a pizza

Original Description

In this ordering a pizza with python tutorial we will refine some of our previous code and learn how to collect a users payment information. We will do this using the python domino's API. ⭐️ Thanks to Kite for sponsoring this video! Download the best AI automcolplete for python programming for free: https://kite.com/download/?utm_medium=referral&utm_source=youtube&utm_campaign=techwithtim&utm_content=pizza-4 - Links - GitHub (API Download): https://github.com/techwithtim/pizzapi Sublime Text: https://www.sublimetext.com/ Jarvis Johnson's Channel: https://www.youtube.com/channel/UCoLUji8TYrgDy74_iiazvYA How to Fix Pip: https://www.youtube.com/watch?v=AdUZArA-kZw Playlist: https://www.youtube.com/watch?v=J_ud6KxX_s0&list=PLzMcBGfZo4-m6lHUaxnOZUoUZLQLr0Ylr ◾◾◾◾◾ 💻 Enroll in The Fundamentals of Programming w/ Python https://tech-with-tim.teachable.com/p... 📸 Instagram: https://www.instagram.com/tech_with_tim 🌎 Website https://techwithtim.net 📱 Twitter: https://twitter.com/TechWithTimm ⭐ Discord: https://discord.gg/pr2k55t 📝 LinkedIn: https://www.linkedin.com/in/tim-rusci... 📂 GitHub: https://github.com/techwithtim 🔊 Podcast: https://anchor.fm/tech-with-tim 💵 One-Time Donations: https://www.paypal.com/donate/?token=... 💰 Patreon: https://www.patreon.com/techwithtim ◾◾◾◾◾◾ ⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡ Tags: - Tech With Tim - Python Tutorials - Python Ordering a Pizza - Ordering a Pizza with Python - Dominos Python API - Python Pizza API #Python
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Tech With Tim · Tech With Tim · 0 of 60

← Previous Next →
1 A* Path Finding Algorithm(Visualization)
A* Path Finding Algorithm(Visualization)
Tech With Tim
2 Python Programming Tutorial #1 - Variables and Data Types
Python Programming Tutorial #1 - Variables and Data Types
Tech With Tim
3 Python Programming Tutorial #2 - Basic Operators and Input
Python Programming Tutorial #2 - Basic Operators and Input
Tech With Tim
4 Python Programming Tutorial #3 - Conditions
Python Programming Tutorial #3 - Conditions
Tech With Tim
5 Python Programming Tutorial #4 - IF/ELIF/ELSE
Python Programming Tutorial #4 - IF/ELIF/ELSE
Tech With Tim
6 Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Tech With Tim
7 Python Programming Tutorial #6 - For Loops
Python Programming Tutorial #6 - For Loops
Tech With Tim
8 Python Programming Tutorial #7 - While Loops
Python Programming Tutorial #7 - While Loops
Tech With Tim
9 Python Programming Tutorial #8 - Lists and Tuples
Python Programming Tutorial #8 - Lists and Tuples
Tech With Tim
10 Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Tech With Tim
11 Python Programming Tutorial #10 - String Methods
Python Programming Tutorial #10 - String Methods
Tech With Tim
12 How to Overclock a NVIDIA GPU
How to Overclock a NVIDIA GPU
Tech With Tim
13 Python Programming Tutorial #11 - Slice Operator
Python Programming Tutorial #11 - Slice Operator
Tech With Tim
14 Python Programming Tutorial #12 - Functions
Python Programming Tutorial #12 - Functions
Tech With Tim
15 Python Programming Tutorial #13 - How to Read a Text File
Python Programming Tutorial #13 - How to Read a Text File
Tech With Tim
16 Python Programming Tutorial #14 - Writing to a Text File
Python Programming Tutorial #14 - Writing to a Text File
Tech With Tim
17 Python Programming Tutorial #15 - Using .count() and .find()
Python Programming Tutorial #15 - Using .count() and .find()
Tech With Tim
18 Python Programming Tutorial #16 - Introduction to Modular Programming
Python Programming Tutorial #16 - Introduction to Modular Programming
Tech With Tim
19 Python Programming Tutorial #17 - Optional Parameters
Python Programming Tutorial #17 - Optional Parameters
Tech With Tim
20 Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Tech With Tim
21 Python Programming Tutorial #19 - Global vs Local Variables
Python Programming Tutorial #19 - Global vs Local Variables
Tech With Tim
22 Python Programming Tutorial #20 - Classes and Objects
Python Programming Tutorial #20 - Classes and Objects
Tech With Tim
23 Cool VBS Script to Prank Your Friends!
Cool VBS Script to Prank Your Friends!
Tech With Tim
24 How to Overclock an AMD GPU
How to Overclock an AMD GPU
Tech With Tim
25 Best GPU'S For Mining Ethereum (2018)
Best GPU'S For Mining Ethereum (2018)
Tech With Tim
26 Recursion and Memoization Tutorial Python
Recursion and Memoization Tutorial Python
Tech With Tim
27 Ethereum Mining Rig - Hardware Guide
Ethereum Mining Rig - Hardware Guide
Tech With Tim
28 Pygame Tutorial #1 - Basic Movement and Key Presses
Pygame Tutorial #1 - Basic Movement and Key Presses
Tech With Tim
29 How to Install Pygame (Windows 8/10)
How to Install Pygame (Windows 8/10)
Tech With Tim
30 How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
Tech With Tim
31 How to Mine Ethereum 2018 - WORKING (Super-Easy)
How to Mine Ethereum 2018 - WORKING (Super-Easy)
Tech With Tim
32 Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Tech With Tim
33 Pygame Tutorial #2 - Jumping and Boundaries
Pygame Tutorial #2 - Jumping and Boundaries
Tech With Tim
34 Pygame Tutorial #3 - Character Animation & Sprites
Pygame Tutorial #3 - Character Animation & Sprites
Tech With Tim
35 Pygame Tutorial #4 - Optimization & OOP
Pygame Tutorial #4 - Optimization & OOP
Tech With Tim
36 OBS Studio Tutorial - Best OBS Settings
OBS Studio Tutorial - Best OBS Settings
Tech With Tim
37 Linear Search Algorithm - Python Example and Code
Linear Search Algorithm - Python Example and Code
Tech With Tim
38 Make Any Mic Sound AMAZING! (WITH OBS)
Make Any Mic Sound AMAZING! (WITH OBS)
Tech With Tim
39 Binary Search Algorithm - Python Example & Code
Binary Search Algorithm - Python Example & Code
Tech With Tim
40 Pygame Tutorial #5 - Projectiles
Pygame Tutorial #5 - Projectiles
Tech With Tim
41 Pygame Game - Mini Golf
Pygame Game - Mini Golf
Tech With Tim
42 Pygame Tutorial - Projectile Motion (Part 1)
Pygame Tutorial - Projectile Motion (Part 1)
Tech With Tim
43 Pygame Tutorial - Projectile Motion (Part 2)
Pygame Tutorial - Projectile Motion (Part 2)
Tech With Tim
44 Pygame Tutorial #6 - Enemies
Pygame Tutorial #6 - Enemies
Tech With Tim
45 Pygame Tutorial #7 - Collision and Hit Boxes
Pygame Tutorial #7 - Collision and Hit Boxes
Tech With Tim
46 Pygame Tutorial #8 - Scoring and Health Bars
Pygame Tutorial #8 - Scoring and Health Bars
Tech With Tim
47 Cloud Mining vs. Hardware Mining - 2018
Cloud Mining vs. Hardware Mining - 2018
Tech With Tim
48 How to Install Pygame on Mac OSX (Fast-Simple)
How to Install Pygame on Mac OSX (Fast-Simple)
Tech With Tim
49 Pygame Tutorial #9 - Sound Effects, Music & More Collision
Pygame Tutorial #9 - Sound Effects, Music & More Collision
Tech With Tim
50 Pygame Tutorial #10 - Finishing Touches & Next Steps
Pygame Tutorial #10 - Finishing Touches & Next Steps
Tech With Tim
51 How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
Tech With Tim
52 How to Create a Button in Pygame [CODE IN DESCRIPTION]
How to Create a Button in Pygame [CODE IN DESCRIPTION]
Tech With Tim
53 Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Tech With Tim
54 Pygame Side-Scroller Tutorial #2 - Random Object Generation
Pygame Side-Scroller Tutorial #2 - Random Object Generation
Tech With Tim
55 Pygame Side-Scroller Tutorial #3 - Collision
Pygame Side-Scroller Tutorial #3 - Collision
Tech With Tim
56 Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Tech With Tim
57 How to Create A Message Box in Python - Tkinter
How to Create A Message Box in Python - Tkinter
Tech With Tim
58 Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Tech With Tim
59 How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
Tech With Tim
60 Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Tech With Tim

This video tutorial teaches how to use Python to collect user payment information for ordering a pizza, covering topics such as order calculation, credit card validation, and console input. By following this tutorial, viewers can learn how to refine their previous code and create a more efficient ordering system. The tutorial also demonstrates how to use various tools such as Kite and console.pi to improve the development process.

Key Takeaways
  1. Print out item information
  2. Display item name and price in a list
  3. Collect total cost of items
  4. Ask for credit card information
  5. Run Python tutorial
  6. Type code to order items
  7. Remove items from order using order.remove_item method
  8. Get credit card information using console input
  9. Check for valid credit card
  10. Ask user for credit card information
💡 The tutorial demonstrates how to use Python to collect user payment information for ordering a pizza, highlighting the importance of validating credit card information and using console input to improve the user experience.

Related AI Lessons

Embeddings Simplified
Learn the basics of embeddings and how they simplify complex data, a crucial concept in AI and ML
Medium · RAG
Building LSTMs with PyTorch and Lightning AI Part 7: Resuming Training with Checkpoints
Learn to resume LSTM training with checkpoints using PyTorch and Lightning AI, enabling efficient model iteration and development
Dev.to · Rijul Rajesh
How AI Learns with Less Labeled Data
Learn how AI can learn with less labeled data, a crucial aspect of machine learning beyond model selection
Medium · AI
Comparing Sarvam-30B and Qwen2.5–14B on Spider Text-to-SQL: An Active-Parameter Perspective
Learn how to compare large language models like Sarvam-30B and Qwen2.5-14B on the Spider Text-to-SQL benchmark from an active-parameter perspective
Medium · LLM
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →