Class Test Function

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

DAV PUBLIC SCHOOL PRATP VIHAR,GZB

XII(2020-21) COMPUTERSCIENCE(083)
CLASS TEST(Functions)

MaxMarks:30 Time : 1:30 hr


Questions 1 to 5 carry One marks and question 6 to 7 carry two marks

1. A function is begin with the keyword


I)void II) return iii)int iv)def
2. Function that does not return any value are known as
i)fruitful functions ii)void function iii)library functions iv)user defined functions

3. Which of the following argument worked with implicit value that are used if no value is
provided?
i) keyboard ii) required iii) variable length iv) default

4. What is the output of the program given below:

x=50
def func(x):
x=2
func(x)
print(‘x is now’,x)
I) x is now 50 ii) x is now 2 iii) X is now 100 iv) Error

5. Predict the output of the following code.


def swap(P ,Q):
P,Q=Q,P
print( P,"#",Q)
return (P)
R=100
S=200
R=swap(R,S)
print(R,"#",S)
6. Find and write the output of the following Python code:
def Show(str):
m=""
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"#"
print(m)
Show('HappyBirthday')

7. What is wrong with the following definition?


def addEm(x,y,z):
return x+y+z
print(x+y+z)

Q 8. What is function? How does useful ? (2)


Q9. what is the argument? Given example . (2)

Q10. Write a function that : (4)

a) ask the user to input a diagram of spare (centimeters , inches,etc)


b) set the variable called radius to 1/2 of that number
c) calculate the volume of a sphere using this radius and formula: Volume=4/3*pi*r*3
d) printer statement estimating the value of spell include the appropriate unit information in
litres or quarts.
e) Return this same amount as output of the function

Q11. from the program code given below identify the part mentioned below : (3)

def processNumber(x):

x=72

return x+3
y=54

res=processNumber(y)

identify these parts: function header, function call, arguments ,parameters, function body. main
program

Q12. Write a function that take positive integer and return’s one’s position digit of the integer (3)

Q13. Differentiate between call by value and call by reference with a suitable example for each. (2)

Q14. Write a function LMove(Lst,n) in Python, which accepts a list Lst 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
Lst= [ 10,20,30,40,12,11], n=2
Output Lst = [30,40,12,11,10,20] (3)

Q15. Find the errors in code: (3)


def alpha(n, string=’xyz’,k=10)
return beta(string)
return n
def beta(string)
return string==str(n)
print(alpha(“Independence day”) : )
print(beta(string=’true’) : )
print(alpha(n=5,“good bye”) : )

You might also like