Create a function with default argument
Write a program to create a function show_employee()
using the following conditions.
- It should accept the employee’s name and salary and display both.
- If the salary is missing in the function call then assign default value 9000 to salary
Given:
Expected output:
Name: Ben salary: 12000
Name: Jessa salary: 9000
Hint:
Default arguments take the default value during the function call if we do not pass them. We can assign a default value to an argument in function definition using the
=
assignment operator.Solution:
Explanation:
need an explanation for this answer? contact us directly to get an explanation for this answer