103 solutions available
Question 1Assertion. A function is a subprogram.Reason. A function exists within a program and works within it when called.
Question 2Assertion. Non-default arguments cannot follow default arguments in a function call.Reason. A function call can have different types of...
Question 3Assertion. A parameter having a default in function header becomes optional in function call.Reason. A function call may or may not have...
Question 4Assertion. A variable declared inside a function cannot be used outside it.Reason. A variable created inside a function has a function...
Question 5Assertion. A variable not declared inside a function can still be used inside the function if it is declared at a higher scope...
Question 6Assertion. A parameter having a default value in the function header is known as a default parameter.Reason. The default values for...
Question 7Assertion. A function declaring a variable having the same name as a global variable, cannot use that global variable.Reason. A local...
Question 8Assertion. If the arguments in a function call statement match the number and order of arguments as defined in the function definition,...
Question 1If return statement is not used inside the function, the function will return:0None objectan arbitrary integerError! Functions in Python...
Question 2Which of the following keywords marks the beginning of the function block?funcdefinedeffunction
Question 3What is the area of memory called, which stores the parameters and local variables of a function call ?a heapstorage areaa stackan array
Question 4Find the errors in following function definitions : def main() print ("hello")def func2(): print(2 + 3)def compute():...
Question 1A function is a subprogram that acts on data and often returns a value.
Question 2Python names the top level segment (main program) as __main__.
Question 3In Python, program execution begins with first statement of __main__ segment.
Question 4The values being passed through a function-call statement are called arguments / actual parameters / actual arguments.
Question 5The values received in the function definition/header are called parameters / formal parameters / formal arguments.
Question 6A parameter having default value in the function header is known as a default parameter.
Question 7A default argument can be skipped in the function call statement.
Question 8Keyword arguments are the named arguments with assigned values being passed in the function call statement.
Question 9A void function also returns a None value to its caller.
Question 10By default, Python names the segment with top-level statements (main program) as __main__.
Question 11The flow of execution refers to the order in which statements are executed during a program run.
Question 12The default value for a parameter is defined in function header.
Question 1What is the default return value for a function that does not return any value explicitly ?Noneintdoublenull
Question 2Which of the following items are present in the function header ?function name onlyboth function name and parameter listparameter list...
Question 3Which of the following keywords marks the beginning of the function block ?funcdefinedeffunction
Question 4What is the name given to that area of memory, where the system stores the parameters and local variables of a function call ?a heapstorage...
Question 5Pick one the following statements to correctly complete the function body in the given code snippet.def f(number): #Missing function...
Question 6Which of the following function headers is correct ?def f(a = 1, b):def f(a = 1, b, c = 2):def f(a = 1, b = 1, c = 2):def f(a = 1, b = 1, c...
Question 7Which of the following statements is not true for parameter passing to functions ?You can pass positional arguments in any order.You can...
Question 8Which of the following is not correct in context of Positional and Default parameters in Python functions ?Default parameters must occur to...
Question 9Which of the following is not correct in context of scope of variables ?Global keyword is used to change value of a global variable in a...
Question 10Which of the following function calls can be used to invoke the below function definition ?def test(a, b, c, d)test(1, 2, 3, 4)test(a = 1,...
Question 11Which of the following function calls will cause Error while invoking the below function definition ?def test(a, b, c, d)test(1, 2, 3,...
Question 12For a function header as follows :def Calc(X,Y = 20):Which of the following function calls will give an error ?Calc(15, 25)Calc(X = 15, Y...
Question 13What is a variable defined outside all the functions referred to as ?A static variableA global variableA local variableAn automatic...
Question 14What is a variable defined inside a function referred to asA static variableA global variableA local variableAn automatic variable
Question 15Carefully observe the code and give the answer.def function1(a): a = a + '1' a = a * 2...
Question 16What is the result of this code ?def print_double(x): print(2 ** x) print_double(3)86410
Question 17What is the order of resolving scope of a name in a Python program ?B G E LL E G BG E B LL B E G
Question 18Which of the given argument types can be skipped from a function call ?positional argumentskeyword argumentsnamed argumentsdefault...
Question 1Non-default arguments can be placed before or after a default argument in a function definition.
Question 2A parameter having default value in the function header is known as a default parameter.
Question 3The first line of function definition that begins with keyword def and ends with a colon (:), is also known as function header.
Question 4Variables that are listed within the parentheses of a function header are called function variables.
Question 5In Python, the program execution begins with first statement of __main__ segment.
Question 6Default parameters cannot be skipped in function call.
Question 7The default values for parameters are considered only if no value is provided for that parameter in the function call statement.
Question 8A Python function may return multiple values.
Question 9A void function also returns a value i.e., None to its caller.
Question 10Variables defined inside functions can have global scope.
Question 11A local variable having the same name as that of a global variable, hides the global variable in its function.
Question 1A program having multiple functions is considered better designed than a program without any functions. Why ?
Question 2What all information does a function header give you about the function ?
Question 3What do you understand by flow of execution ?
Question 4What are arguments ? What are parameters ? How are these two terms different yet related ? Give example.
Question 5What is the utility of : (i) default arguments, (ii) keyword arguments ?
Question 6Explain with a code example the usage of default arguments and keyword arguments.
Question 7Describe the different styles of functions in Python using appropriate examples.
Question 8Differentiate between fruitful functions and non-fruitful functions.
Question 9Can a function return multiple values ? How ?
Question 10What is scope ? What is the scope resolving rule of Python ?
Question 11What is the difference between local and global variable ?
Question 12When is global statement used ? Why is its use not recommended ?
Question 13Write the term suitable for following descriptions :(a) A name inside the parentheses of a function header that can receive a value.(b) An...
Question 14What do you understand by local and global scope of variables ? How can you access a global variable inside the function, if function has...
Question 1(a)What are the errors in following codes ? Correct the code and predict output :total = 0; def sum(arg1, arg2): total = arg1 +...
Question 1(b)What are the errors in following codes ? Correct the code and predict output :def Tot(Number) #Method to find Total Sum = 0 for...
Question 2Find and write the output of the following python code :def Call(P = 40, Q = 20): P = P + Q Q = P - Q print(P, '@', Q)...
Question 3Consider the following code and write the flow of execution for this. Line numbers have been given for your reference.1. def power(b, p):...
Question 4What will the following function return ?def addEm(x, y, z): print(x + y + z)
Question 5What will the following function print when called ?def addEm(x, y, z): return x + y + z print(x + y + z)
Question 6(i)What will be the output of following program ?num = 1 def myfunc(): return num print(num) print(myfunc()) print(num)
Question 6(ii)What will be the output of following program ?num = 1 def myfunc(): num = 10 return num print(num) print(myfunc()) print(num)
Question 6(iii)What will be the output of following program ?num = 1 def myfunc(): global num num = 10 return num print(num)...
Question 6(iv)What will be the output of following program ?def display(): print("Hello", end='') display() print("there!")
Question 7Predict the output of the following code :a = 10 y = 5 def myfunc(): y = a a = 2 print("y =", y, "a =", a) print("a + y...
Question 8What is wrong with the following function definition ?def addEm(x, y, z): return x + y + z print("the answer is", x + y + z)
Question 9Write a function namely fun that takes no parameters and always returns None.
Question 10Consider the code below and answer the questions that follow :def multiply(number1, number2): answer = number1 * number2...
Question 11Consider the code below and answer the questions that follow :def multiply(number1, number2): answer = number1 * number2...
Question 12(a)Find the errors in code given below :def minus(total, decrement) output = total - decrement...
Question 12(b)Find the errors in code given below :define check() N = input ('Enter N: ') i = 3...
Question 12(c)Find the errors in code given below :def alpha (n, string = 'xyz', k = 10) : return beta(string) return n def beta (string)...
Question 13Draw the entire environment, including all user-defined variables at the time line 10 is being executed.1. def sum(a, b, c, d): 2....
Question 14Draw flow of execution for the above program.
Question 15Find and write the output of the following python code :a = 10 def call(): global a a = 15 b = 20 print(a) call()
Question 16In the following code, which variables are in the same scope ?def func1(): a = 1 b = 2 def func2(): c = 3 d = 4 e = 5
Question 17Write a program with a function that takes an integer and prints the number that follows after it. Call the function with these arguments...
Question 18Write a program with non-void version of above function and then write flow of execution for both the programs.
Question 19(i)What is the output of following code fragments ?def increment(n): n.append([4]) return n L = [1, 2, 3] M = increment(L)...
Question 19(ii)What is the output of following code fragments ?def increment(n): n.append([49]) return n[0], n[1], n[2], n[3] L = [23, 35,...
Question 20What will be the output of the following Python code ?V = 25 def Fun(Ch): V = 50 print(V, end = Ch) V *= 2 print(V, end =...
Question 1Write a function that takes amount-in-dollars and dollar-to-rupee conversion price; it then returns the amount converted to rupees. Create...
Question 2Write a function to calculate volume of a box with appropriate default values for its parameters. Your function should have the following...
Question 3Write a program to have following functions :(i) a function that takes a number as argument and calculates cube for it. The function does...
Question 4Write a function that receives two numbers and generates a random number from that range. Using this function, the main program should be...
Question 5Write a function that receives two string arguments and checks whether they are same-length strings (returns True in this case otherwise...
Question 6Write a function namely nthRoot( ) that receives two parameters x and n and returns nth root of x i.e., x^(1/n).The default value of n is...
Question 7Write a function that takes a number n and then returns a randomly generated number having exactly n digits (not starting with zero) e.g.,...
Question 8Write a function that takes two numbers and returns the number that has minimum one's digit.[For example, if numbers passed are 491 and...
Question 9Write a program that generates a series using a function which takes first and last values of the series and then generates four terms that...