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

Academics

AI-Powered learning for Grades 8–12, aligned with major Indian and international curricula.

Professionals

Professional Courses

Industry-relevant training in Business, Technology, and Design to help professionals and graduates upskill for real-world careers.

Games

Interactive Games

Fun, engaging games to boost memory, math fluency, typing speed, and English skills—perfect for learners of all ages.

Practice Questions

Test your understanding with targeted questions related to the topic.

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.

Practice 4 more questions and get performance evaluation

Interactive Quizzes

Engage in quick quizzes to reinforce what you've learned and check your comprehension.

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.

Solve 2 more questions and get performance evaluation

Challenge Problems

Push your limits with challenges.

Question 1

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.

Question 2

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.

Challenge and get performance evaluation