Sunteți pe pagina 1din 5

DPS MIS, DOHA- QATAR

HOLIDAY HOMEWORK (201617)


CLASS: XII
Subject: Computer Science
1.

What is the difference between the formal parameters and actual


parameters? Give python code to illustrate both.

2.

Write the corresponding python expressions for the following mathematical


expressions:
(i)(a2+b2+c2)
(ii) 2-ye2y+4y

3.

How do you add key: value pairs to an existing dictionary?

4.

What are default arguments? How are they useful?

5.

Give the difference between global and local variable? Give python code to
illustrate both.

6.

7.

What will be the output of the following code?


def grap(x):
z=""
for y in x:
z=y+z
return z
print grap("Hello")
How are dictionaries different from lists?

8.

How are lists different from strings when both are sequences?

9.

Write the appropriate list method to perform the following tasks.


a) Add an element at the end of the list.
b) Delete 3rd element from the list
Write the two major differences between Procedure Oriented Programming
and Object Oriented Programming.

10.
11.

What do you mean by abstraction and encapsulation? How they are related?

12.

What is scope of a variable? What types of scopes can be there in Python.

13.

What are mutable and immutable types? List immutable and mutable types
of Python.

Page 1 of 5

14.

What is the length of the tuple shown below?


t=((((a,1), b, c), d,2), e, 3)

15.

What is an object? What is a class? How is an object different from a class?

16.

How are the terms abstraction and encapsulation related?

17.

What is polymorphism? Give an example illustrating polymorphism.

18.

Write the two major differences between Procedure Oriented Programming


and Object Oriented Programming.

19.

What are instance variables? How are they different from class variables?

20.

What are the differences between instance methods and static methods?

21.

What do you mean by name mangling? Support your answer with relevant
example.

22.

Differentiate between reference counting and automatic garbage collection


with respect to Python.

23.

How private members are different from public members of a class?

24.

27.

What is the role of __del__( ) method in a class? Explain with the help of an
example.
What is the role of __init__( ) method in a class? Explain with the help of an
example.
Define inheritance. Explain the different type of inheritance with example
code.
What is method overriding? What is its significance?

28.

What is super() function? What is its significance?

29.

What is stack? What basic operation can be performed on them?

30.

What is queue? What basic operation can be performed on them?

31.

What is the role of file object in data file handling?

32.

What is the difference between w and a modes?

33.

How is write() different from writelines()?

34.

Write statements to place the file pointer :


(i) to beginning of file
(ii) to 25th byte from the beginning
(iii) to 10 bytes behind the current position of file pointer
(iv) to 15 bytes ahead of current position of file pointer

25.
26.

Page 2 of 5

35.

What is the disadvantage of Linear Search? How it is overcome by using


Binary search. Explain with an example.

36.

Given an array: 67,34,90,12,8,56. Sort this array in ascending order using


insertion sort and selection sort.

37.

Evaluate the following postfix notation of expression:


100, 8, 3, *, 50, 2, -, +, -

38.

Convert the following expression to postfix form:


i.

A*(B+C*D)+E

ii.

a b

AND a c AND

OR

39.

What is an Exception? When is Exception Handling required? What are the


advantages of Exception Handling?

40.

When do you need multiple except handlers exception catching blocks?

41.

What is the purpose of finally clause of a try catch finally statement.

42.

Write a program to perform push and pop operations into a stack.

43.

Write a program to perform insert and delete operations into a queue.

44.

What will following python code produce, justify your answer


def divide(x, y):
try:
result = x / y
except ZeroDivisionError:
print "division by zero!"
else:
print "result is", result
finally:
print "executing finally clause"
divide(2,1)
divide(2,0)
divide(0,2)

45.

A list contains Item_code, Item_name, qty and price. Sort the list in

In ascending order of price using Bubble sort.

In descending order of qty using Insertion sort.

Page 3 of 5

46.

Define a class student in Python with the given specifications:


Instance variables:
Roll number, name
Methods:
Getdata()- To input roll number and name
Printdata()- To display roll number and name
Define another class marks, which is derived from student class
Instance variable
Marks in five subjects
Methods:
Inputdata() - To call Getdata() and input 5 subjects marks.
Outdata() - To call printdata() and to display 5 subjects marks.
Implement the above program in python.

47.

Create the class SOCIETY with following information:


society_name
house_no
no_of_members
flat
income
Methods
An __init__ method to assign initial values of society_name as "Surya
Apartments", flat as "A Type", house_no as 20, no_of_members as 3, income
as 25000.
Inputdata( ) - to read data
members(society,house_no,no_of_members&income) and call allocate_flat().
allocate_flat( ) - To allocate flat according to income
Income Flat
>=25000 A Type
>=20000 and <25000 B Type
<15000 C Type
Showdata( ) - to display the details of the entire class.

48.

What is the output of the following code?


class parent:
def __init__(self,param):
self.v1=param
class child(parent):
def __init__(self,param):
self.v2=param
obj=child(11)
print obj.v1,obj.v2

Page 4 of 5

49.

Given a binary file STUDENT.DAT, containing records of the following


attributes:
Admno-Admission number of the student
Name- Name of the student
Percentage- Percentage marks of the student
Write a function that would read the contents of the file STUDENT.DAT
and display the details of those students whose percentage is 75.

50.

Create a binary file Student containing students records having their name,
roll no., and marks in Computer science. Write procedures to perform the
following:
(i) Display all names along with their
marks.
(ii) Insert a student record at the
appropriate rollno.
(iii) Delete a particular student.

Page 5 of 5

S-ar putea să vă placă și