Previous year paper

(SEM III) THEORY EXAMINATION 2023-24 PYTHON PROGRAMMING

Python Programming B.Tech 0 downloads

About this previous year paper

This examination evaluates a student’s conceptual understanding and programming ability in Python, covering core syntax, functions, file handling, data visualization, loops, strings, lists, numerical computing, and problem-solving skills.

The paper is divided into three sections, progressively testing basic concepts, applied programming, and advanced logic-building.

SECTION A – Short Answer Questions (14 Marks)

7 questions × 2 marks

This section checks essential, fundamental Python concepts that form the base for programming and data processing.

Topics Covered:

1. List Comprehension

Understanding how lists are created in a single line using expressions and iteration.

2. Difference Between / and // Operators

Floating-point division vs floor division with examples.

3. Output Prediction

Given a function involving .split() and join(), students predict final output.

4. Using Functions From Another File (module import)

How main.py accesses functions defined in library.py using import, from ... import, and module references.

5. Difference Between linspace and arange

Numerical range generation in NumPy for plotting and mathematical applications.

6. Error Identification in List/String Operations

Mutability vs immutability: why modifying a string index fails.

7. Functions of Matplotlib & Pandas

Basic plotting commands, data structures, and operations.

This section judges clarity of Python fundamentals and error understanding.

SECTION B – Applied Python Programming (21 Marks)

Attempt any 3 questions – each 7 marks

This section requires writing Python programs, demonstrating logic, and implementing operations on data structures, files, and functions.

Questions Cover:

1. Unpacking Tuples, Mutable Sequences & String Concatenation

Explaining with code how tuple unpacking works, modifying elements in lists, and joining strings.

2. List Slicing Operations

Performing multiple slicing tasks on a list, such as:
• reverse slices
• mid-segment extraction
• even-index elements
• reversing part of a list
• dividing and replacing elements

3. Perfect Square Function

Implementing perfect_square(number) that returns the number only if a perfect square; otherwise returns −1.

4. File Handling – Reverse Characters With Commas

Reading a file and rewriting content as comma-separated characters:
Example: "Hello!!" → "H,e,l,l,o,!,!"

5. Plotting Dataset Using Matplotlib

Constructing bar/line plots for calories, potassium, and fat from given food dataset.

This section evaluates programming fluency, slicing, iteration, logic writing, and basic data visualization.

SECTION C – Logical & Real-World Python Applications (35 Marks)

Each section contains two options; students attempt ONE.

3. String Manipulation & Sorting (7 Marks)

Option A – removenth(s, n)

Function to remove the nth character from a string, handling edge cases when n ≥ len(s).

Option B – Sorting comma-separated words

Program to accept input like:
without, hello, bag, world
Sort alphabetically and print result.

4. Password Validation or Loop Demonstrations (7 Marks)

Option A – Password Validator

Program enforcing:
✓ lowercase letter
✓ uppercase letter
✓ digit
✓ special char ($#@)
✓ length 6–12
Valid passwords printed comma-separated.

Option B – Demonstrate While & For Loops

Explanation with practical examples on iteration, termination, nested loops, and range usage.

5. Nested Lists & Text Filtering (7 Marks)

Option A – Smallest List Finder

Function ret_smaller(l) returning list with smallest length; ties resolved by first occurrence.

Option B – Text Filters

Filtering rules:

extract numbers

extract strings starting with vowels

extract strings containing nouns (Agra, Ramesh, Tomato, Patna)

Used to clean messy text through Python list comprehensions and filters.

6. File Processing & Digit-only Words (7 Marks)

Option A – Convert Numbers to Words in File

Program reads text and replaces numeric digits with word equivalents inside the file.

Option B – Extract Digit-only Words

Program reading a file and printing only those words composed purely of digits.

7. CSV Processing & Calculator App (7 Marks)

Option A – Process cities.csv

Tasks:
• read CSV
• remove last column → store in one array
• store last column separately
• plot first two columns using matplotlib

Option B – Build a Simple Calculator

Buttons/functions:

addition
– subtraction
× multiplication
÷ division
C clear
Python implementation using functions or GUI (Tkinter).

Purpose of This Examination

This exam ensures that students can:

Use Python for solving computational problems
Implement functions, loops, slicing, and data structures
Perform file handling, string manipulation, and data cleaning
Visualize data using matplotlib
Work with CSV files and external modules
Understand program errors and fix them
Apply logic to real-world tasks like password validation and text filtering
Build structured, reusable Python programs

This paper strengthens student ability to think algorithmically and apply Python in practical domains including data science, automation, and application development.

TypePrevious year paper
SubjectPython Programming
Board / courseB.Tech
FilePDF · 199.47 KB
Shared by SuGanta International

Added by the SuGanta team.