// Anna University, Chennai / 2019
Anna University — Problem Solving and Python Programming (GE8151), November/December 2019
Problem Solving and Python Programming · GE8151 · R2017 · B.E./B.Tech. Engineering (common paper) · Semester 1
Files open in a new tab. Use your browser's download or save option to keep a copy.
Work through the questions
15 questions
No verified answers are available for this paper.
How will you analyse the efficiency of an algorithm?
No verified answer or solution is available for this question.
What is the use of algorithms, flowcharts and pseudocode in problem solving?
No verified answer or solution is available for this question.
Compare an interpreter and a compiler. What type of translator is used for Python?
No verified answer or solution is available for this question.
Write a Python program to print the sum of cubes of the values of n variables.
No verified answer or solution is available for this question.
- 2025
- 2019
Also asked in Anna University — Problem Solving and Python Programming (GE3151), April/May 2025 (2025).
Do loop statements have else clauses? When will the clause be executed?
No verified answer or solution is available for this question.
Write a program to display a set of strings using the range() function.
No verified answer or solution is available for this question.
How will you update list items? Give one example.
No verified answer or solution is available for this question.
Can functions return tuples? If yes, give an example.
No verified answer or solution is available for this question.
How do you use command line arguments in Python?
No verified answer or solution is available for this question.
Write methods to rename and delete files.
No verified answer or solution is available for this question.
(a) (i) What is a programming language? Explain its types, with their advantages and disadvantages. (8 marks) (ii) Write a function find_index() that returns the index of a number in the Fibonacci sequence if present, or -1 otherwise. Call the function with user input and display the result. (8 marks) (OR) (b) (i) What is a recursive function? Give its advantages and disadvantages and compare it with an iterative function. (6 marks) (ii) Implement a recursive function in Python for the sieve of Eratosthenes. It finds all primes up to n. Start with a list of integers 2 to n and set i to 2. Remove multiples starting at 2*i and advancing by i. Take the first remaining number after i as the next prime and set i to that number. Continue until i is greater than n, or stop at the square root of n as an improvement. The numbers left in the list are prime. (10 marks)
No verified answer or solution is available for this question.
(a) (i) Write a Python program to rotate a list to the right n times, with and without slicing. (4 + 4 marks) (ii) Discuss keyword arguments and default arguments in Python with examples. (4 + 4 marks) (OR) (b) (i) Write a Python program to print the maximum among n randomly generated “d” numbers after storing them in a list. (10 marks) (ii) Evaluate these expressions in Python: 24//6%3, float(4+int(2.39)%2), 2**2**3. (6 marks)
No verified answer or solution is available for this question.
(a) (i) Three sticks form a triangle only if no length is greater than the sum of the other two. For example, sticks of 12 inches, 1 inch and 1 inch cannot form a triangle. (1) Write is_triangle, taking three integers and printing "Yes" or "No" depending on whether the sticks can form a triangle. (4 marks) (2) Write a function that prompts for three lengths, converts them to integers and checks them with is_triangle. (4 marks) (ii) Write a Python program using a built-in function to generate all permutations of a given string. (8 marks) (OR) (b) (i) Compare lists and arrays with an example. Can a list be considered an array? Justify. (6 marks) (ii) Write areAnagram1() to check whether two strings are anagrams using a built-in string function and areAnagram2() to check without a built-in string function. (10 marks)
No verified answer or solution is available for this question.
(a) (i) Define a dictionary in Python. Initialize two dictionaries with key-value pairs. Compare both with a master key list and print missing keys. Find keys in the first only, find common keys and merge the dictionaries in a single expression. (10 marks) (ii) What is list comprehension in Python? Explain with an example. (6 marks) (OR) (b) (i) What is a tuple in Python? How does it differ from a list? (8 marks) (ii) Write a Python program to sort n numbers using merge sort. (8 marks)
No verified answer or solution is available for this question.
(a) (i) What are exceptions? Explain how to handle them with an example. (8 marks) (ii) Write a Python program to count the words in a text file. (8 marks) (OR) (b) (i) How do you merge multiple files into a new file using Python? (6 marks) (ii) What are modules and how do you import them? Explain by creating and importing a module. (10 marks)
No verified answer or solution is available for this question.