Python Programming PYQ 2020-21 AKTU Question Paper

AKTU · BTECH · Semester 3 · Python Programming · Session 2020-21 · PYQ

AKTU Python Programming previous year question paper 2020-21 for B.Tech Semester 3. Covers Introduction to Python, Program Flow Control, Complex Data Types…

Open the interactive reader to study this resource on AcademicArk.

Python Programming AKTU syllabus

  1. Unit 1: Introduction to Python
  2. Unit 2: Program Flow Control
  3. Unit 3: Complex Data Types & Functions
  4. Unit 4: File Operations & Regular Expressions
  5. Unit 5: Packages, GUI & OOP

Questions in Python Programming AKTU PYQ 2020-21

  1. Q1a. What is the use of “raise” statement? Describe with an example. (2 marks, 2020-21)
  2. Q1b. Write a recursive Python function “rprint” to print all elements in a list in reverse. rprint([]) prints nothing rprint([1,2,3]) prints 3 2 1 (2 marks, 2020-21)
  3. Q1c. Describe the behavior of “range (s, e)” in Python. (2 marks, 2020-21)
  4. Q1d. Explain the use of “with” construct in Python with an example program. (2 marks, 2020-21)
  5. Q1e. Which of the following statements produce an error in Python? x, y, z = 1,2,3 # s1 a, b = 4,5,6 # s2 u = 7,8,9 # s3 (List all the statements that have error.) (2 marks, 2020-21)
  6. Q1f. Explain the role of precedence with an example. (2 marks, 2020-21)
  7. Q1g. How do you read an input from a user in Python to be used as an integer in the rest of the program? Explain with an example. (2 marks, 2020-21)
  8. Q1h. Consider the program: x = ['12', 'hello', 456] x[0] *= 3 x[1][1] = 'bye' Explain why this program generates an error. (2 marks, 2020-21)
  9. Q1i. What is the output of the following program? (lambda x,y : y - 2*x) (1, 11) (2 marks, 2020-21)
  10. Q1j. Explain the use of lt function in a class Python? (2 marks, 2020-21)
  11. Q2a. Write a Python function removekth(s, k) that takes as input a string s and an integer k>=0 and removes the character at index k. If k is beyond the length of s, the whole of s is returned. For example, removekth(“PYTHON”, 1) returns “PTHON” removekth(“PYTHON”, 3) returns “PYTON”… (10 marks, 2020-21)
  12. Q2b. Write a Python function average to compute the average of a list of numbers. The function must use try-except to handle the case where the input list is empty. Further, in that case the average for the empty list should be set to 0.0 using the except block. (10 marks, 2020-21)
  13. Q2c. Describe the differences between a linear search and a binary search? (10 marks, 2020-21)
  14. Q2d. Write a function lessthan(lst, k) to return list of numbers less than k from a list lst. The function must use list comprehension. Example: lessthan([1, -2, 0, 5, -3], 0) returns [-2, -3] (10 marks, 2020-21)
  15. Q2e. Write a program factors(N) that returns a list of all positive divisors of N (N>=1). For example: factors(6) returns [1,2,3,6] factors(1) returns [1] factors(13) returns [1,13] (10 marks, 2020-21)
  16. Q3a. How can you create Python file that can be imported as a library as well as run as a standalone script? (10 marks, 2020-21)
  17. Q3b. Describe the difference between import library and from library import * when used in a python program. Here library is some python library. (10 marks, 2020-21)
  18. Q4a. Write a function makePairs that takes as input two lists of equal length and returns a single list of same length where k-th element is the pair of k-th elements from the input lists. For example, makePairs([1,3,5,7],[2,4,6,8]) returns [(1,2),(3,4),(5,6),(7,8)] makePairs([],[]) returns [] (10 marks, 2020-21)
  19. Q4b. Show an example where both Keyword arguments and Default arguments are used for the same function in a call. Show both the definition of the function and its call. (10 marks, 2020-21)
  20. Q5a. Explain why Python is considered an interpreted language. (10 marks, 2020-21)
  21. Q5b. What is short circuit evaluation? What is printed by the following Python program? a = 0 b = 2 c = 3 x = c or a print(x) (10 marks, 2020-21)
  22. Q6a. Write a Python program, triangle(N), that prints a right triangle having base and height consisting of N * symbols as shown in these examples: triangle(3) prints: * ** *** triangle(5) prints: * ** *** **** ***** (10 marks, 2020-21)
  23. Q6b. Write a Python program, countSquares(N), that returns the count of perfect squares less than or equal to N (N>1). For example: countSquares(1) returns 1 # Only 1 is a perfect square <= 1 countSquares(5) returns 2 # 1, 4 are perfect squares <= 5 countSquares(55) returns 7 # 1, 4, 9, 16, 25, 36, 49… (10 marks, 2020-21)
  24. Q7a. Write a Python function, alternating(lst), that takes as argument a sequence lst. The function returns True if the elements in lst are alternately odd and even, starting with an even number. Otherwise it returns False. For example: alternating([10, 9, 9, 6]) returns False alternating([10, 15, 8])… (10 marks, 2020-21)
  25. Q7b. Write a Python function, searchMany(s, x, k), that takes as argument a sequence s and integers x, k (k>0). The function returns True if there are at most k occurrences of x in s. Otherwise it returns False. For example: searchMany([10, 17, 15, 12], 15, 1) returns True searchMany([10, 12, 12, 12],… (10 marks, 2020-21)

AKTU paper codes: BCC302, BCC402, BCC302H, BCC402H, KNC302, KNC402

Python Programming previous year papers

More Python Programming resources

Browse all notes · Semester 3 notes