🧠 Don’t miss out! Get FREE access to my Skool community — packed with resources, tools, and support to help you with Data, Machine Learning, and AI Automations! 📈 https://www.skool.com/data-and-ai-aut...
Ever wondered what *args and **kwargs actually do in Python? This beginner-friendly crash course will help you understand and master these powerful tools for flexible function definitions—in just 25 minutes!
🚀 Hire me for Data Work: https://ryanandmattdatascience.com/da...
👨💻 Mentorships: https://ryanandmattdatascience.com/me...
📧 Email: [email protected]
🌐 Website & Blog: https://ryanandmattdatascience.com/
🖥️ Discord: / discord
📚 *Practice SQL & Python Interview Questions: https://stratascratch.com/?via=ryan
📖 *SQL and Python Courses: https://datacamp.pxf.io/XYD7Qg
🍿 WATCH NEXT
Python for Data Analyst and Scientists Playlist: • Python Tutorials For Data Analysts and Sci...
Regular Expressions: • Master Python Regular Expressions in 1 Hou...
List Comprehension: • Master Python List Comprehension in Just 2...
Mean, Median, Mode (More ARGS Examples): • 5 Ways to Find the Mean, Median, and Mode ...
In this video, I break down how to use *args and **kwargs in Python to send a variable number of arguments to your functions. I explain why we use one star for args (to unpack iterables) and two stars for kwargs (to unpack dictionaries), making it easy to understand when and how to use each one.
We walk through eleven different practical examples, starting with simple functions like finding the smallest number and multiplying values, then moving to string manipulation with baseball lineups. I show you how to work with kwargs using examples like parabola equations, concert ticket sales, and venue information. You'll also learn how to combine both args and kwargs in the same function, and I demonstrate how to use them within classes for more advanced object-oriented programming.
Each example includes working code that you can follow along with, from basic mathematical operations to building concert information systems. By the end of this video, you'll understand the key differences between args and kwargs, know when to use for loops with each, and be able to confidently implement them in your own Python projects. I also share best practices for naming conventions and setting default values.
TIMESTAMPS
00:00 Introduction to Args and Kwargs
01:04 Example 1: Finding Smallest Number with Args
02:26 Example 2: Multiplying Numbers with Args
04:12 Example 3: Baseball Lineup with Args
06:22 Example 4: Parabola with Kwargs
08:58 Example 5: Summing Concert Ticket Sales with Kwargs
10:40 Example 6: Concert Information with Kwargs
13:00 Example 7: Combining Args and Kwargs
15:17 Example 8: Using Args with Classes
19:19 Example 9: Using Kwargs with Classes
23:40 Recap and Key Takeaways
OTHER SOCIALS:
Ryan’s LinkedIn: / ryan-p-nolan
Matt’s LinkedIn: / matt-payne-ceo
Twitter/X: https://x.com/RyanMattDS
Who is Ryan
Ryan is a Data Scientist at a fintech company, where he focuses on fraud prevention in underwriting and risk. Before that, he worked as a Data Analyst at a tax software company. He holds a degree in Electrical Engineering from UCF.
Who is Matt
Matt is the founder of Width.ai, an AI and Machine Learning agency. Before starting his own company, he was a Machine Learning Engineer at Capital One.
*This is an affiliate program. We receive a small portion of the final sale at no extra cost to you.