Previous

Variables and Types

6 / 6
Next

Default parameters let you assign a default value to a function argument. This means that if the caller does not provide a value for that parameter, the default will be used automatically. It helps make functions more flexible and easier to use.

For example:

def greet(name="friend"):
   print(f"Hello, {name}!")
greet() 
greet("Alice")

The first function call falls back to the default value "friend" and prints Hello, friend. The second function call overwrites the default parameter value and prints Hello, Alice.

Send

Capstone

Hint
Beginner

Write a program that takes three inputs item, price, and amount. Print the total price for the amount of items bought. For example, if the inputs are pen, 1.45 and 2, then the output must be 2 x pen - 2.90.

Help
Solve
Reset
Run
Submit
 

Test results

Test result #
Expected output
Your output

Your email has been verified!