Skip to content

// Anna University, Chennai / 2020

Anna University — Problem Solving and Python Programming (GE8151), November/December 2020

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.

  1. Question 1

    Part AUnit 1Descriptive2 marks

    Python

    What factors are used to judge the quality of algorithms?

    No verified answer or solution is available for this question.

  2. Question 2

    Part AUnits 1, 3Descriptive2 marks

    Python

    What is control flow? List and define the ways in which control is executed.

    No verified answer or solution is available for this question.

  3. Question 3

    Part AUnit 2Descriptive2 marks

    Python

    Define expression.

    No verified answer or solution is available for this question.

  4. Question 4

    Part AUnit 2Descriptive2 marks

    Python

    Write a Python program to exchange the values of two numbers without using a temporary variable.

    No verified answer or solution is available for this question.

  5. Question 5

    Part AUnit 3Descriptive2 marks

    Python

    Define a string slice. Give an example.

    No verified answer or solution is available for this question.

  6. Question 6

    Part AUnit 3Descriptive2 marks

    Python

    Given an array of n elements, write a function to search for a given element x in the array.

    No verified answer or solution is available for this question.

  7. Question 7

    Part AUnit 4Descriptive2 marks

    Python

    What is cloning a list? Give an example.

    No verified answer or solution is available for this question.

  8. Question 8

    Part AUnit 4Descriptive2 marks

    Python

    What is the difference between a list and a tuple in Python?

    No verified answer or solution is available for this question.

  9. Question 9

    Part AUnit 5Descriptive2 marks

    Python

    What are packages? How do you import modules from a package?

    No verified answer or solution is available for this question.

  10. Question 10

    Part AUnit 5Descriptive2 marks

    Python

    How will you update the contents of one file to another file in Python?

    No verified answer or solution is available for this question.

  11. Question 11

    Part BUnit 1Descriptive16 marks

    Python

    (a) (i) Explain the strategies for developing algorithms with an example. (10 marks) (ii) Write an algorithm for the Towers of Hanoi problem. (6 marks) (OR) (b) Explain the process of algorithm design and analysis. (8 + 8 marks)

    No verified answer or solution is available for this question.

  12. Question 12

    Part BUnits 2, 3Descriptive16 marks

    Python

    (a) (i) Explain the order of evaluation when an expression contains more than one operator. (8 marks) (ii) Differentiate parameters and arguments. Explain how to pass arguments to a function with a suitable example. (4 + 4 marks) (OR) (b) Define various methods and functions in Python. Differentiate them with an example. (8 + 8 marks)

    No verified answer or solution is available for this question.

  13. Question 13

    Part BUnit 3Descriptive16 marks

    Python

    (a) (i) Describe fruitful and void functions with examples. (4 + 4 marks) (ii) There are two sorted arrays A and B of size n each. Write an algorithm to find the median after merging them into an array of length 2n. (8 marks) (OR) (b) (i) Write a recursive implementation of binary search. (8 marks) (ii) What are immutable strings? For the sentence "Chennai Anna University", sort the words in ascending order. (8 marks)

    No verified answer or solution is available for this question.

  14. Question 14

    Part BUnit 4Descriptive16 marks

    Python

    (a) (i) Write nested_sum, which adds all integers from the nested lists, and cumsum, which takes a list of numbers and returns the cumulative sum list. Its ith element equals the sum of the first i + 1 elements of the input. (5 + 5 marks) (ii) Take dictionaries d1 and d2 and return a new dictionary containing all keys from d1 that are absent from d2. (6 marks) (OR) (b) (i) Write is_sorted, which returns True if a list is sorted in ascending order and False otherwise, and has_duplicates, which returns True if any element appears more than once. The original list should be preserved. (8 marks) (ii) Write a function that takes a histogram, returns a list of word-frequency tuples and prints the ten most common words. (8 marks)

    No verified answer or solution is available for this question.

  15. Question 15

    Part BUnit 5Descriptive16 marks

    Python

    (a) (i) Write a program that reads a file and builds a histogram of the words in the file. (8 marks) (ii) Print all numbers in a text file and the number of blank spaces in it. (8 marks) (OR) (b) (i) Write a function called sed that takes a pattern string, a replacement string and two filenames. Read the first file and write the contents to the second, creating it if necessary. Replace every occurrence of the pattern with the replacement. If opening, reading, writing or closing fails, catch the exception, print an error message and exit. (8 marks) (ii) Explain how to read or process command line arguments in Python, with an example. (8 marks)

    No verified answer or solution is available for this question.

Keep preparing

Revisit another year or explore a different paper in the library.

More from this exam