Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Arguments and Return Values | Python Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. Python Fundamentals

Lesson 10 of 55

·Python

Arguments and Return Values

20 minutes

Course progress18%

What you'll learn

Keep these ideas in mind as you work through the lesson.

4 points
  • Positional arguments are required and ordered.
  • Keyword arguments improve readability and can be passed in any order.
  • Default parameters provide fallback values.
  • `*args` collects extra positional arguments; `**kwargs` collects extra keyword arguments.

Arguments and Return Values

Functions can accept positional, keyword, default, and variable‑length arguments.

def repeat(message, times=2):
    return message * times

print(repeat('Hi'))          # HiHi
print(repeat('Hi', 3))    # HiHiHi
  • Positional arguments are matched by order.
  • Keyword arguments let you specify the parameter name (repeat(message='Hi', times=3)).
  • Default values (times=2) make an argument optional.
  • Use *args to collect extra positional arguments and **kwargs for extra keyword arguments.
Make it stickPractice what you've learned1 quiz · 5 practical tests · Optional activities from Python FundamentalsBrowse activities
Previous lessonFunctionsContinue to lesson 11Lambda FunctionsBack to Python Fundamentals curriculum