27 solutions available
Question 4Find the errors in following function definitions : def main() print ("hello")def func2(): print(2 + 3)def compute():...
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 11What is the difference between local and global variable ?
Question 12When is global statement used ? Why is its use not recommended ?
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 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 9Write a function namely fun that takes no parameters and always returns None.
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 =...