Python For Application Development MNCST309 KTU BTech CS 2024 Scheme Minor Model Question Paper

 

MODEL QUESTION PAPER

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY

THIRD SEMESTER B.TECH MINOR DEGREE EXAMINATION,MONTH AND YEAR

Course Code:MNCST309

Course Name:Python for Application Development

Max.Marks:60

 

Duration:     2Hours 30Minutes

 

 

 

PARTA

 

 

Answer all questions.Each question carries 3marks

CO

Marks

1

 

Write a Python program that takes two integer inputs from the user and prints the larger of the two numbers. If the numbers are equal, it should print "Numbers are equal".

1

(3)

2

 

Explain the difference between a list and a tuple in Python.Provide short code example demonstrating one key difference in their behavior.

1

(3)

3

 

Explain the purpose of a decorator in Python.Provide a simple example of a decorator that adds a greeting message before executing a function.

2

(3)

4

 

Write a Python function that takes a filename as input and checks if the file exists in the current directory. The function should return True if the file exists and False otherwise. Use the os module for this task.

2

(3)

5

 

Explain the concept of inheritance in object-oriented programming.

Provide a simple Python example demonstrating a parent class and a child class inheriting from it.

3

(3)

6

 

Design a Python class Counter with the following methods: increment() (increases the counter by 1),decrement()(decreases the counter by 1), and get_value()(returns the current counter value).Ensure the counter

cannot go below zero.

 

3

 

(3)

7

 

Create a NumPy array of the first 10 even numbers(2,4,6,...20).

4

(3)

8

 

Given a NumPy array ,write Python code to find the indices  of all the even numbers within that array.For example,if the arrayis[1,2,3,4,5,

6],the output should be[1,3,5].

4

(3)

PARTB

Answer any one full question from each module.Each question carries 9marks

Module1

9

a)

A mobile app records daily temperatures (as float values) entered by a user. Write a code snippet that stores these in a list, converts each to an integer for quick preview, and prints them in a tabular format with proper alignment..

 

1

 

4

b)

A health tracker needs to categorize user activity based on number of steps walked in a day. Using selection and iteration, write a program fragment to classify each day’s data as “Sedentary”, “Active”, or

“Highly Active”from a given dictionary of daily step counts.

 

1

 

5

10

a)

Describe how Python supports arithmetic and comparison operations.Your team is developing a console-based student mark

1

9


 

 

analyzer. The input is taken as a string of comma-separated marks. Demonstrate how to:

1.      Parse and convert the input into numeric form.

2.      Classify each mark as "Fail", "Pass", or "Distinction" based on thresholds using appropriate control structures.

3.      Format and print the output with a ligned columns.

 

 

Module2

11

a)

Create a function log_event(event_type, message) that writes logs into a text file in the format: [EVENT_TYPE]: message. The function should append logs to the same file each time.

 

2

 

4

b)

Using the os module,write a function that checks if a back up directory exists.If not,it creates one.Then it copies a specified file to that directory.Explain how the code ensures portability.

 

2

 

5

12

a)

Write a Python function using recursion that prints the names of all .py files in a given directory and its sub directories.

2

4

b)

Enhance the above function to count the number of .py files and write their paths to a log file.Use the os module and demonstrate how

exceptions(e.g.,permission errors)are handled gracefully.

 

2

 

5

Module3

13

a)

Design a class Vehicle with attributes like speed and engine_on.Add a method start() to turn on the engine and print a message.

3

3

b)

Create a derived class ElectricCar from Vehicle that overrides the start() method and includes a method charge(). Demonstrate how polymorphism works by calling start() from both classes. Also include exception handling for invalid charging input.

 

3

 

4

14

a)

Write a class BankAccount with methods deposit() and withdraw().

Raise an exception if withdrawal exceeds balance.

3

3

b)

Extend the class to support a subclass SavingsAccount that applies

interest during deposit. Demonstrate method overriding and show how exceptions are handled during deposit if the amount is negative.

 

3

 

4

Module4

15

a)

Write a function using regex to check if a password meets the following rules: minimum 8 characters, includes at least one uppercase letter, one number, and one special character.

 

4

 

4

b)

Given a 2D NumPy array representing stock prices over days, write a function to:

1. Calculate daily differences,

2. Identify days with maximum gain/loss,

3. Return a new array with these differences

 

 

4

 

 

5

16

a)

From a multiline string containing log entries like "User: John, ID: 001",extract all user names using regular expressions. Convert the extractednames into a NumPy array. Assume you now want to sort them alphabetically and count how many start with each letter. Write code to do this and return the results.

 

 

4

 

 

9

*****

Comments

Popular posts from this blog

Python For Application Development MNCST309 KTU BTech CS Minor 2024 Scheme - Dr Binu V P

Course Details MNCST 309 Python For Application Development