Q.Differentiate between following with the help of an example:
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Parameter = the stand-in name written in the function header; argument = the actual value supplied in the call. Global variable = defined outside every function, visible program-wide; local variable = defined inside a function, alive only during that call.
The idea. Both pairs describe the two sides of a boundary. Parameter/argument is the boundary of a function call (definition side vs call side); global/local is the boundary of a function's scope (outside vs inside).
a) Argument vs Parameter
def area(length, breadth): # length and breadth are PARAMETERS
return length * breadth
print(area(6, 4)) # 6 and 4 are ARGUMENTS
side = 5
print(area(side, side)) # the current value of side (5) is the argument
Expected output
24
25
| Parameter | Argument | |
|---|---|---|
| Where it appears | function definition header | function call |
| What it is | a variable name (a stand-in) | an actual value/expression |
| Example above | length, breadth | 6, 4, side |
| When it gets a value | at call time, from the matching argument | already has one |
When area(6, 4) executes, the argument 6 is bound to the parameter length and 4 to breadth, positionally.
b) Global vs Local variable
city = "Delhi" # GLOBAL: defined outside all functions
def show():
pin = 110001 # LOCAL: created when show() starts
print(city, pin) # a function may READ a global freely
show()
print(city) # global still accessible here
print(pin) # NameError! pin died when show() returned
Expected output
Delhi 110001
Delhi
Traceback (most recent call last):
...
NameError: name 'pin' is not defined
| | Global variable | Local variable |
|---|---|---| …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.