A function is a reusable block of code designed to perform a specific task.
Built-in Functions: Ready-to-use functions built directly into Python (like print(), len(), and max()).
User-Defined Functions: Custom functions created using the def keyword.
Parameters & Arguments: Parameters are the variables listed inside the function definition, while arguments are the actual values you pass into the function when you call it.
Docstring: A short text description placed at the top of a function inside triple quotes (""") to explain what it does.
Scope: Where a variable can be accessed. Local variables only exist inside a function, while global variables can be accessed anywhere.
Write a Python program where the user enters an item price. The menu allows them to choose between a Student Discount (10%), a Festive Discount (20%), or a VIP Discount (30%) by reusing the exact same function.ย
Write a Python console application for an arcade where players use tokens to play games.ย
Requirements:
Start the player with 5 tokens.
Write a function to check and deduct tokens, and reuse this function every time a game starts.
Create separate functions for Racing, Space Shooter, and Air Hockey.
Use a while loop and match-case menu to let the user choose a game or exit.