0% found this document useful (0 votes)
5 views

cs

This document is an examination paper for Grade XII Computer Science, consisting of multiple sections that test knowledge on Python programming concepts. It includes multiple-choice questions, short answer questions, and programming tasks related to functions, exception handling, and recursion. The paper is structured into sections with varying marks allocated for each question.

Uploaded by

First War Gaming
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

cs

This document is an examination paper for Grade XII Computer Science, consisting of multiple sections that test knowledge on Python programming concepts. It includes multiple-choice questions, short answer questions, and programming tasks related to functions, exception handling, and recursion. The paper is structured into sections with varying marks allocated for each question.

Uploaded by

First War Gaming
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

BRIMMING HIGH INTERNATIONAL SCHOOL

TIRUTTANI | KANCHIPURAM

Subject: Computer Science Date:

Grade: XII Mark: 70

---------------------------------------------------------------------------------------------------------------------------

SECTION- A (1 mark)

1. Which of the following Keywords mark the Beginning of the function block?

A) func B) Define C) def D) function

2. Which of the following function headers is correct?

A) def f(a = 1,b): B) def f(a =1,b,c = 2): C) def f(a = 1,b = 1,c = 2):

D) def f(a = 1,b = 1,c = 2,d):


3. What is the result of this code ?
def print_double(x) :
print(2**x)
print_double(3)
A) 8 B) 6 C) 4 D) 10

4. What is the order of resolving scope of a name in a Python program ?

(L: Local namespace, E: Enclosing namespace, B: Built-In Namespace, G: Global namespace)

a. B G E L b. L E G B c. G E B L d. L B E G

5. Which of the given argument types can be skipped from a function call ?

a) positional arguments (b) keyword arguments (c) named arguments

(d) default arguments

6. What is the keyword to define a function in Python?


(A) function (B) def (C) func (D) define

7. Which of the following statements will raise an exception?


(A) print("Hi")
(B) x = 5 / 0
(C) x = int("123")
(D) print(len("Hello"))

8.What is the correct way to handle exceptions in Python?


(A) try-catch
(B) try-catch-finally
(C) try-except
(D) do-except

9. What will be the output of the following code?

def greet():

return "Hello"

print(greet())

(A) Hello (B) greet() (C) return Hello (D) Error

10. Which error occurs when a variable is not defined?


(A) NameError (B) ValueError (C) TypeError (D) IndexError

11. What is recursion?

12.Write the syntax of a user-defined function in Python.

13.What is a default argument?

14.Name one built-in function in Python.

15.What is an exception in Python?

16.Write one advantage of using functions in a program.

17.What is the output of this code?

18.Which of the following is a correct function definition?


(A) def func[]: (B) def func(): (C) def = func() (D) func def():

19. What is the output of this code?

try:

x = 10 / 2

print("No Error")

except:

print("Error")

(A) Error (B) No Error (C) 5.0 (D) 10 / 2

20. State True or False:

Function arguments in Python must be passed in the same order as defined.


21. State True or False:

A function without a return statement will return None by default.

SECTION- B (7 x 2=14 marks)

22. Explain the purpose of *args in function definitions with a simple example.

OR

What is recursion? Write one condition that must be present in a recursive function.

23.Differentiate between a built-in function and a user-defined function. Give one example of each.

24. Write a try-except block that catches a division by zero error and prints a custom message.

25. What is the difference between try-except and try-finally blocks?

26. Find and write the output of the following python code:

def ChangeVal (M,N):

for i in range(N):

if M[i] %5 == 0 :

M[i] //=5

If M[i] %3==0 :

M[i] //=3

L = [25, 8, 75, 12]

ChangeVal (L,4)

for i in L:

print(i, end = '#')


27. What is the difference between the formal parameters and actual parameters? What are their
alternative names? Also, give a suitable Python code to illustrate both.

Or

Differentiate between local and global variables with a Python program.

28. What will be the output of the following code? Explain your answer.

def fun(a, b=3, c=5):

print(a, b, c)

fun(1, c=4)

SECTION- C (3 x 3 = 9 marks)

29. Write a Python program that asks the user to enter an integer. Handle the case when the user enters
non-numeric data.

30. What is the role of the finally block in exception handling? Write a program that shows its use
when closing a file.

OR

What is the importance of exception handling in Python?.

31. Explain the following types of function arguments with examples:

 Positional
 Keyword
 Default

SECTION-D (4 x 4 =16 marks)


32. Program to calculate simple interest using a function interest() that can receive principal
amount, time and rate and returns calculated simple interest. Do specify default values for rate
and time as 10% and 2 years respectively.

33. Program that receives two numbers in a function and returns the results of all arithmetic
operations (+, -, *, /, %) on these numbers.

34.Explain the use of global key word used in a function with the help of a suitable example.

35.what is the significance of having functions in a program ?


SECTION- E (2 X 5=10 Marks)

13. Write a code to demonstrate the use of try, except, else,and finally blocks in Python.

14. Write a program to input two numbers from the user and divide the first by the second. Handle the
following exceptions:

 ValueError
 ZeroDivisionError

You might also like