Class 12 Computer Science
Class 12 Computer Science
CHAPTER 3
Working with functions
TOPIC EXPLANATION /NOTES/QUESTIONS
Questions 1. What is the scope of a variable defined inside a function?
a) Global scope
b) Local scope
c) Universal scope
d) Function scope
6. The values being passed through a function call statements are called
a) Actual parameter
b) Formal parameter
c) default parameter
d) None of these
a) global a
b) global b=100
c) global b
d) global a=100
11. What will be the output?
a) 5 b) 6
c) 4 d) This code will raise an error.
12. What will be the output of the following code?
a) 100#52 b) 85#52
c) 85#33 d) 185#52
a) [1, 2, 3, 4, 5, 6] b) [100, 2, 3, 4, 5, 6]
c) [100, 2, 3, 4, 5] d) [1, 2, 3, 4, 5]
15. Find and write the output of following python code:
lis=eval(input("Enter list"))
last=lis[-1]
for i in range(len(lis)-1,0,-1):
lis[i]=lis[i-1]
lis[0]=last
print(lis)
47. Function writing question12
Write a function LShift(Arr,n) in Python, which accepts a list Arr of numbers and n is a numeric
value by which all elements of the list are shifted to left.
Sample Input Data of the list Arr= [ 10,20,30,40,12,11], n=2
Output
Arr = [30,40,12,11,10,20]
Write a Recursive function in Python RecsumNat(N), to return the sum of the first N natural
numbers. For example, if N is 10 then the function should return (1 + 2 + 3 + ... + 10 = 55).
Write a Recursive function in Python Power(X,N), to return the result of X raised to the power
N where X and N are non-negative integers. For example, if X is 5 and N is 3 then the function
should return the result of (5)3 i.e. 125.
The function should calculate and return the average of the scores. Additionally, display
the scores that are above the calculated average.
For example, consider the following list of scores:
scores = [85, 92, 78, 95, 88]
The function should return the average (rounded to two decimal places)
and print the scores that are above the calculated average. (Note: Do not
use in-built functions)
79. Function writing question44
Write a userdefined function parser(L) that accepts a list as parameter and creates
another two lists storing the numbers from the original list , that are even and
numbers that are odd