Practice Default Arguments - 8.3.3 | 8. Advanced Python – Revision and Functions | CBSE 12 AI (Artificial Intelligence)
Students

Academic Programs

AI-powered learning for grades 8-12, aligned with major curricula

Professional

Professional Courses

Industry-relevant training in Business, Technology, and Design

Games

Interactive Games

Fun games to boost memory, math, typing, and English skills

Default Arguments

8.3.3 - Default Arguments

Enroll to start learning

You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.

Learning

Practice Questions

Test your understanding with targeted questions

Question 1 Easy

Write a function that uses a default argument for a country.

💡 Hint: Think of a common value for the country.

Question 2 Easy

What will be the output of this function: def test(a, b=5): return a + b; print(test(3))?

💡 Hint: Consider what happens when the default value is used.

4 more questions available

Interactive Quizzes

Quick quizzes to reinforce your learning

Question 1

What is a default argument in Python?

A set value for an argument
An argument that can't be changed
None of the above

💡 Hint: Think about the function's behavior when no value is given for a parameter.

Question 2

True or False: A mutable default argument can lead to surprising outcomes in a function's operation.

True
False

💡 Hint: Consider functions with lists or dictionaries as defaults.

2 more questions available

Challenge Problems

Push your limits with advanced challenges

Challenge 1 Hard

Create a function that takes a name and a default age, ensuring that age defaults to 21 if not supplied. Create two different instances of the function and illustrate how it works.

💡 Hint: Experiment with calling your function to see how defaults work.

Challenge 2 Hard

Describe what could go wrong if you use a list as a default argument in a function. Illustrate with code.

💡 Hint: Test this out with several calls to the function.

Get performance evaluation

Reference links

Supplementary resources to enhance your learning experience.