Question Paper Code : 30509
B.E./B.Tech. DEGREE EXAMINATIONS, NOVEMBER/DECEMBER 2022.
First Semester
Civil Engineering
GE 3151 — PROBLEM SOLVING AND PYTHON PROGRAMMING
(Common to : All Branches)
(Regulations 2021)
Answer ALL questions.
PART A — (10 × 2 = 20 marks)
- 1.
Write an algorithm to find the sum of first 'N' natural numbers.
- 2.
Distinguish between top down and bottom up approaches to design an algorithm.
- 3.
What is slicing operator in python? Give an example.
- 4.
Python variables do not have specific types. Justify this statement using an example.
- 5.
Write a python program to add two matrices.
- 6.
Write a simple function to multiply two numbers in python.
- 7.
Write a program to create a clone of the list: list 1 = [1,2,3,4,5,6].
- 8.
How are the values of tuples accessed? Illustrate with an example.
- 9.
Define relative path and absolute path with respect to files.
- 10.
What are exceptions?
PART B — (5 × 16 = 80 marks)
- 11.(a)
- (i)Explain the different building blocks of algorithms with their notations.(10)
- (ii)Write an algorithm to find an element in the given set of numbers.(6)
- Or
- (b)
- (i)What is meant by recursion? Write a recursive algorithm to solve Towers of Hanoi problem.(8)
- (ii)Draw a flowchart to check if the given word is palindrome.(8)
- 12.(a)
- (i)Write a program to find the roots of a quadratic equation given the coefficients a, b, c.(8)
- (ii)Describe the shift and logical operators used in python with examples.(8)
- Or
- (b)
- (i)Elaborate on membership, identity and bitwise operators of python with suitable examples.(12)
- (ii)Write a program to print the digit at one's place of a number.(4)
- 13.(a)
- (i)Describe the conditional branching statements of python with examples.(8)
- (ii)Write the syntax of while loop and use the same to classify if a given number is prime or not.(8)
- Or
- (b)
- (i)Describe parameter passing in functions using examples.(8)
- (ii)Discuss about the scope and lifetime of variables considering functions.(8)
- 14.(a)
- (i)Describe the addition and deletion operation in a list data structure with examples.(8)
- (ii)Write a program that has a nested list to store topper details and display the details.(8)
- Or
- (b)
- (i)Discuss the basic tuple operations with examples.(8)
- (ii)Write a program to swap two values using tuple assignment.(8)
- 15.(a)
- (i)Explain opening and closing of files in python using examples.(8)
- (ii)Write a program to display the contents of a file by performing split operation whenever a comma is encountered in a file.(8)
- Or
- (b)
- (i)Explain the use of packages and modules in python with examples.(8)
- (ii)Write a program to handle the division by zero exception.(8)