Arguments, parameters and scope PYQ
PYQ PRACTICE SCOPE: Arguments, parameters and scope.
Concept ID: U1_FUNCTION_ARGS_SCOPE.
Use only previous-year questions whose concept_ids include U1_FUNCTION_ARGS_SCOPE.
Key things we'll cover
Arguments, parameters and scope
PYQ references used by both prompts22 included0 excluded
Flagged questions are excluded from both Study Notes and PPT references until corrected in Paper Analyzer.
Included
ID 6486 · 2021 · 1 mark(s)
Which of the following components are part of a function header in Python?
a) Function Name
b) Return Statement
c) Parameter List
d) Both a and c
Functions and Modules → Arguments parameters and scope
Included
ID 6508 · 2021 · 1 mark(s)
What will be the output of the following code?
value = 50
def display(N):
global value
value = 25
if N%7==0:
value = value + N
else:
value = value - N
print(value, end="#")
display(20)
print(value)
a) 50#50
b) 50#5
c) 50#30
d) 5#50#
Functions and Modules → Arguments parameters and scope, Function output tracing
Included
ID 6515 · 2021 · 1 mark(s)
What will be the output of the following code?
x = 3
def myfunc():
global x
x+=2
print(x, end=' ')
print(x, end=' ')
myfunc()
print(x, end=' ')
a) 3 3 3
b) 3 4 5
c) 3 3 5
d) 3 5 5
Functions and Modules → Arguments parameters and scope, Function output tracing
Included
ID 6543 · 2022 · 1 mark(s)
Assertion (A): If the arguments in function call statement match the number and order of arguments as defined in the function definition, such arguments are called positional arguments.
Reasoning (R): During a function call, the argument list first contains default argument(s) followed by positional argument(s).
a) Both A and R are true and R is the correct explanation for A
b) Both A and R are true and R is not the correct explanation for A
c) A is True but R is False
d) A is false but R is True
Functions and Modules → Arguments parameters and scope
Included
ID 6559 · 2022 · 3 mark(s)
Write a function INDEX_LIST(L), where L is the list of elements passed as argument to the function. The function returns another list named 'indexList' that stores the indices of all Non-Zero Elements of L.
For example:
If L contains [12,4,0,11,0,56]
The indexList will have - [0,1,3,5]
Functions and Modules → Arguments parameters and scope
Included
ID 6580 · 2023 · 1 mark(s)
Consider the code given below:
b=100
def test(a):
__________________ # missing statement
b=b+a
print(a,b)
test(10)
print(b)
Which of the following statements should be given in the blank for #Missing Statement, if the output produced is 110?
a) global a
b) global b=100
c) global b
d) global a=100
Functions and Modules → Arguments parameters and scope
Included
ID 6112 · 2023 · 2 mark(s)
Write the output of the code given below :
a =30
def call (x):
global a
if a%2==0:
x+=a
else:
x-=a
return x
x=20
print (call(35),end="#")
print (call(40),end="@")
Functions and Modules → Arguments parameters and scope, Function output tracing
Included
ID 6308 · 2023 · 2 mark(s)
(a) Write the output of the Python code given below :
g=0
def fun1(x,y):
global g
g=x+y
return g
def fun2 (m,n):
global g
g=m-n
return g
k=fun1 (2,3)
fun2 (k,7)
print (g)
Functions and Modules → Arguments parameters and scope, Function output tracing
Included
ID 6309 · 2023 · 2 mark(s)
(b) Write the output of the Python code given below :
a=15
def update (x):
global a
a=2
if x%2==0:
a*=x
else:
a//=x
a=a+5
print (a,end="$")
update (5)
print (a)
Functions and Modules → Arguments parameters and scope, Function output tracing
Included
ID 6590 · 2023 · 2 mark(s)
Write a function countNow(PLACES) in Python, that takes the dictionary PLACES as an argument and displays the names (in uppercase) of the places whose names are longer than 5 characters.
For example, Consider the following dictionary:
PLACES={1:"Delhi",2:"London",3:"Paris",4:"New York",5:"Doha"}
The output should be:
LONDON
NEW YORK
Functions and Modules → Arguments parameters and scope
Included
ID 6591 · 2023 · 2 mark(s)
Write a function, lenWords(STRING), that takes a string as an argument and returns a tuple containing length of each word of a string.
For example, if the string is "Come let us have some fun", the tuple will have (4, 3, 2, 4, 4, 3)
Functions and Modules → Arguments parameters and scope
Included
ID 6147 · 2024 · 1 mark(s)
Assertion (A): We can use a dictionary as an argument in a function.
Reason (R): A dictionary can be passed as an argument in a function and function can access and modify the dictionary elements inside it.
(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).
(B) Both Assertion (A) and Reason (R) are true and Reason (R) is not the correct explanation of Assertion (A).
(C) Assertion (A) is true but Reason (R) is false.
(D) Assertion (A) is false but Reason (R) is true.
Functions and Modules → Arguments parameters and scope
Included
ID 6343 · 2024 · 1 mark(s)
Assertion (A) : Global variables are accessible in the whole program.
Reason (R) : Local variables are accessible only within a function or block in which it is declared.
(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).
(B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of Assertion (A).
(C) Assertion (A) is true, but Reason (R) is false.
(D) Assertion (A) is false, but Reason (R) is true.
Functions and Modules → Arguments parameters and scope
Included
ID 6622 · 2024 · 1 mark(s)
What will be the output of the following code?
c = 10
def add():
global c
c = c + 2
print(c,end='#')
add()
c=15
print(c,end='%')
a) 12%15#
b) 15#12%
c) 12#15%
d) 12%15#
Functions and Modules → Arguments parameters and scope, Function output tracing
Included
ID 6630 · 2024 · 1 mark(s)
Assertion (A): Positional arguments in Python functions must be passed in the exact order in which they are defined in the function signature.
Reason (R): This is because Python functions automatically assign default values to positional arguments.
a) Both A and R are true and R is the correct explanation for A
b) Both A and R are true and R is not the correct explanation for A
c) A is True but R is False
d) A is False but R is True
Functions and Modules → Arguments parameters and scope
Included
ID 6164 · 2024 · 3 mark(s)
Write a user defined function in Python named show() which takes a list of integers as an argument and displays only those numbers from the list which are perfect squares.
For example: If the list is [10, 21, 36, 14, 81, 100] then the function should display:
36
81
100
Functions and Modules → Arguments parameters and scope
Included
ID 6380 · 2025 · 1 mark(s)
What will be the output of the following code segment ?
a=5
def func_1(b=10):
global a
a=b–10
b+=a
print(a,b)
func_1(a)
(A) 0 5
(B) 5 0
(C) 0 –5
(D) –5 0
Functions and Modules → Arguments parameters and scope, Function output tracing
Included
ID 6672 · 2025 · 1 mark(s)
What will be the output of the following Python code?
i = 5
print(i,end='@@')
def add():
global i
i = i+7
print(i,end='##')
add()
print(i)
a) 5@@12##15
b) 5@@5##12
c) 5@@12##12
d) 12@@12##12
Functions and Modules → Arguments parameters and scope, Function output tracing
Included
ID 6202 · 2025 · 3 mark(s)
Write a user defined function in Python named Display(List) which takes a list of integers as an argument and displays only even numbers from the list.
Functions and Modules → Arguments parameters and scope
Included
ID 6410 · 2025 · 3 mark(s)
(b) Write the output on execution of the following Python code :
def ALTER(Y=25):
global X
Y += X
X += Y
print(X,Y,sep="#")
X=5; Y=15
ALTER(Y)
ALTER()
print(X,Y,sep="@")
Functions and Modules → Arguments parameters and scope, Function output tracing
Included
ID 6211 · 2025 · 5 mark(s)
Write a user defined function in Python named display() which takes a string as an argument and creates a pattern as shown below:
For example: if the string passed as argument is "hello"
then the output will be:
h
he
hel
hell
hello
Functions and Modules → Arguments parameters and scope
Included
ID 6239 · 2026 · 2 mark(s)
What is the difference between default parameters and positional parameters in Python ? Also give an example of a function header which uses both.
Functions and Modules → Arguments parameters and scope