You are on page 1of 2

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

MODEL: DECEMBER 2018


SUB CODE/NAME: GE8151PROBLEM SOLVING AND PYTHON PROGRAMMING
Year/Sem : I/I Date : 10 .12.2018
Class/Section : Common to all Duration : 3 Hours
Faculty : Max. Marks : 100

Answer ALL Questions


SECTION A
Part – A (10*2=20)
1. Write an algorithm to find gcd of two numbers using recursion.
2. Write pseudo code to check whether citizen of India is eligible to vote based on age criteria
3. Draw the flow chart for calculating engineering cutoff mark.
4. List out the data type available in python with example.
5. What does f(31415927) return, for the following function definition?
def f(x):
d=0
while x > 1:
(x,d) = (x/2,d+1)
return(d)
6. What is lambda (anonymous) function, give an example
7. What are the two modes of python .
8. What is the value of triples after the following assignment?

triples = [ (x,y,z) for x in range(1,4) for y in range(x,4) for z in range(y,4) if x+y <= z ]

9. What is packages and identify what are the packages in python?


10. Write the program to print even number from the list num=[ ‘one’, 22, ‘six’,13,15,24,56,5,67]

Part-B (5*13=65)
11. a. (i) Explain in detail about building blocks of algorithms (10)
(ii)Write algorithm for find minimum in a list (3)
(OR)
b.(i)Write an algorithm and draw flowchart to insert a card in a list of sorted cards.(5)
(ii) Illustrate the Towers of Hanoi problem with relevant diagrams.(8)
12. a.(i) Explain in details about mutable and immutable object data types in Python with example.(10)
(ii) Write a python program to exchange two variables without using temporary variable. (3)
(OR)

b. (i) Explain different types of operators supported in python with example. (10)
(ii) Write a python program for find distance between two points p1(x1,y1) , p2(x2,y2) (3)
13. a. i)Describe briefly about iteration statements with example programs.(10)
(ii) what is the result of this code with explanation: (3)
def fib(x):
if x= =0 or x= =1:
return 1
else:
return fib(x-1) + fib(x-2)
print(fib(4))
.
(OR)

b(i)write python program to find factorial of given number with or without recursion .(8)
(ii) Write a python program to perform Binary search (5)
14. (a) (i) Explain details about dictionaries with example and perform the following operation on
dictionary .(10)
1. Accessing an element 2.Update 3.Add Element 4.Membership

(ii) What is alias and clone in list and give example. (3)
(OR)
(b) (ii) Write a python program to perform insertion sort, merge sort with explanation .(13)

15. (a) (i) Discuss the different modes for opening a file and closing a file. (5)
(ii) Explain about the file related methods in python. (8)
(OR)

(b)Describe in detail how exceptions are handled in python. Give relevant examples. (13)

PART –C (1*15)
16. a)(i) write the program to perform the following action in given list , (15)
list=[45,13,25,-10,56,89,4,80]
i) find the minimum and Maximum in the list
ii) insert the element 50 in the index of 4
iii) Delete the element -10 in the list
iv)Find the sum of the list
v)Find the length of list and reverse it
vi)result of list[::-1]
(OR)
b)i) write the python program to (15)
i) perform the Fibonacci series
ii find given number is prime number or not.

You might also like