MAD Study Hub

Home / Past papers / MAD1 End Term / this paper

Modern Application Development I 18 Dec 25 - 21 Dec 2025

MAD1 End Term32 questions100 marks23 MCQ · 9 MSQ
Elapsed 00:00
Q1MCQ4 marks
Consider the following flask app and Jinja2 template. question figure If the flask app is running locally on http://127.0.0.1:5000. What will be the output on the browser for the base URL?
Text of the picture (copyable)
app.py
```python
from flask import Flask, render_template
app = Flask(__name__)

@app.route('/')
def home():
    return render_template("index.html", items=['DaShBoard', 'SETtings',
                                                 'HELP'])

app.run()
```

index.html
```html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Menu</title>
</head>
<body>
    {% macro nav_list(elements) %}
    <ol>
        {% for element in elements %}
        <li><a href="/{{ element|lower }}">{{ element|upper }}</a></li>
        {% endfor %}
    </ol>
    {% endmacro %}

    {{ nav_list(items) }}
</body>
</html>
```
  1. question figure
    text
    1. DaSHBoard
    2. SETtings
    3. HELP
  2. question figure
    text
    1. dashboard
    2. settings
    3. help
  3. question figure
    text
    1. DASHBOARD
    2. SETTINGS
    3. HELP
  4. question figure
    text
    1. DASHBOARD
    2. SETTINGS
    3. HELP
Q2MSQ5 marksselect all that apply
Consider the following flask app. question figure If the application is running locally on http://127.0.0.1:5000, select the correct options.
Text of the picture (copyable)
```python
from flask import Flask, abort, redirect, url_for

app = Flask(__name__)

@app.route('/home/<path:directory>')
def home(directory):
    if "DBMS" in directory:
        return "Welcome to DBMS course!"
    else:
        abort(404)

@app.route('/home/course/<path:directory>')
def course(directory):
    if "DBMS" in directory:
        return redirect(url_for('home', directory=directory))
    else:
        abort(404)

@app.errorhandler(404)
def page_not_found(error):
    return "<h2>Sorry, No course found!!<h2>"

app.run(debug=True)
```
  1. question figure
    text
    For the URL:
    ```
    http://127.0.0.1:5000/home/course/data_science?course=DBMS
    ```
    The browser will render:
    **Sorry, No course found!**
  2. question figure
    text
    For the URL:
    ```
    http://127.0.0.1:5000/home/IITM/DBMS?course=PM
    ```
    The browser will render:
    Welcome to DBMS course!
  3. question figure
    text
    For the URL:
    ```
    http://127.0.0.1:5000/home/course/programming?course=DBMS
    ```
    The browser will render:
    Welcome to DBMS course!
  4. question figure
    text
    For the URL:
    
    ```
    http://127.0.0.1:5000/home/IITM/DBMS?course=Data_structures
    ```
    
    The browser will render:
    **Sorry, No course found!**
Comprehension passage - the questions below it refer to this
Based on the above data, answer the given subquestions. question figure
Q3MSQ5 marksselect all that apply
Which of the following statements is/are correct ?
  1. For the command: python file.py find 103 , the terminal output is:question figure
    text
    Student not found!
  2. For the command: python file.py find 103 , the terminal output is:question figure
    text
    Student found: Dhawan
  3. For the command: python file.py find 104 sid , the terminal output is:question figure
    text
    ```
    IndexError: list index out of range
    ```
  4. For the command: python file.py find 102 , the terminal output is:question figure
    text
    Student found: Anant
  5. For the command: python file.py find 104 sid , the terminal output is:question figure
    text
    Student found: Veda
Q4MSQ3 marksselect all that apply
Which of the following commands will give the terminal output as: question figure
Text of the picture (copyable)
Invalid command!
  1. python file.py find 104 sid
  2. python file.py 102 find sid
  3. python file.py find 105 sid
  4. python file.py find
Q5MCQ3 marks
Consider the following function to be tested and test functions given in the Python code snippet below. question figure
Text of the picture (copyable)
```python
def generate_series(n):
    seq = []
    for i in range(1, n+1):
        seq.append(i * 3)
    return seq

def test_case1():
    assert 9 in generate_series(3)

def test_case2():
    assert 21 in generate_series(6)

def test_case3():
    assert 30 in generate_series(8)
```
What will be the summary of the output for the command `pytest file.py` on the terminal?
  1. question figure
    text
    ```
    =========== 1 failed, 2 passed in 0.30s ===========
    ```
  2. question figure
    text
    ```
    ========== 2 failed, 1 passed in 0.30s ==========
    ```
  3. question figure
    text
    ```
    =================================== 3 failed in 0.30s ===================================
    ```
  4. question figure
    text
    ```text
    ============================= 1 failed, 1 passed in 0.30s =============================
    ```
Q6MCQ3 marks
Consider the following SQL create statement. question figure Which of the following flask_sqlalchemy models will create exactly the same table as created by the above SQL command?
Text of the picture (copyable)
```sql
CREATE TABLE employee (
    emp_id INTEGER NOT NULL,
    emp_code VARCHAR() NOT NULL,
    name VARCHAR(),
    salary INTEGER NOT NULL,
    join_date DATE NOT NULL,
    PRIMARY KEY (emp_id),
    UNIQUE (emp_code),
    UNIQUE (name)
)
```
  1. question figure
    text
    ```python
    class Employee(db.Model):
        emp_id = db.Column(db.Integer(), unique=True)
        emp_code = db.Column(db.String(), primary_key=True)
        name = db.Column(db.String(), unique=False)
        salary = db.Column(db.Integer())
        join_date = db.Column(db.Date())
    ```
  2. question figure
    text
    ```python
    class Employee(db.Model):
        emp_id = db.Column(db.Integer(), primary_key=True)
        emp_code = db.Column(db.String(), nullable=False, unique=True)
        name = db.Column(db.String(), unique=True)
        salary = db.Column(db.Integer(), nullable=False)
        join_date = db.Column(db.Date(), nullable=False)
    ```
  3. question figure
    text
    ```python
    class Employee(db.Model):
        emp_id = db.Column(db.Integer(), primary_key=True)
        emp_code = db.Column(db.String(), unique=True)
        name = db.Column(db.String(), unique=True, nullable=False)
        salary = db.Column(db.Integer())
        join_date = db.Column(db.Date())
    ```
  4. question figure
    text
    ```python
    class Employee(db.Model):
        emp_id = db.Column(db.Integer(), nullable=False)
        emp_code = db.Column(db.String(), unique=True)
        name = db.Column(db.String())
        salary = db.Column(db.Integer(), nullable=False)
        join_date = db.Column(db.Date(), nullable=False)
    ```
Q7MCQ4 marks
Consider the following python code snippet. What will be the rendered output for the terminal output? question figure
Text of the picture (copyable)
```python
from jinja2 import Template

products = [
    {"category": "Groceries", "price": 40, "name": "Rice"},
    {"category": "Electronics", "price": 300, "name": "Headphones"},
    {"category": "Groceries", "price": 10, "name": "Soap"},
]

t = """
<ul>
{% for group in products|groupby('category') %}
    <li>{{ group.grouper }}
        <ul>
        {% for item in group.list %}
            <li>{{ item.name }} costs {{ item.price }}</li>
        {% endfor %}
        </ul>
    </li>
{% endfor %}
</ul>
"""

temp = Template(t)
print(temp.render(products=products))
```
  1. question figure
    text
    * Groceries
        * Rice costs 40
    * Electronics
        * Headphones costs 300
    * Groceries
        * Soap costs 10
  2. question figure
    text
    * Electronics
        * Headphones costs 300
    * Groceries
        * Rice costs 40
    * Groceries
        * Soap costs 10
  3. question figure
    text
    * Groceries
      * Rice costs 40
    * Groceries
      * Soap costs 10
    * Electronics
      * Headphones costs 300
  4. question figure
    text
    - Electronics
      - Headphones costs 300
    - Groceries
      - Rice costs 40
      - Soap costs 10
Comprehension passage - the questions below it refer to this
Consider the following flask application and html template. Assume that the Flask app is running at http://127.0.0.1:5000. question figure Based on the above data, answer the given subquestions. question figure
Q8MCQ4 marks
What will be the final styling applied to the element inside the div for the URL: http://127.0.0.1:5000/?color=green&size=30&msg=welcome+user
  1. background-color: blue, font-size: 20px, padding: 10px, color: white
  2. background-color: green, font-size: 30px, padding: 20px, color: white
  3. background-color: blue, font-size: 20px, padding: 30px, color: green
  4. background-color: green, font-size: 30px, padding: 10px, color: white
Q9MCQ3 marks
What will be the rendered output on the browser for the URL: http://127.0.0.1:5000/?color=green&size=30&msg=welcome+user
  1. question figure
    text
    HELLO USER
  2. question figure
    text
    HELLO USER
  3. question figure
    text
    WELCOME USER
  4. question figure
    text
    WELCOME USER
Q10MSQ3 marksselect all that apply
Which of the following statements correctly differentiates between synchronous and asynchronous updates in frontend development?
  1. In synchronous updates, the UI waits for the operation to complete, while in asynchronous updates, the UI remains responsive.
  2. Synchronous execution is blocking, whereas asynchronous execution is non- blocking.
  3. Asynchronous updates are preferred for network requests and background tasks, while synchronous is best for quick operations.
  4. Both synchronous and asynchronous updates allow the browser to continue execution without waiting.
Q11MCQ3 marks
question figure
Text of the picture (copyable)
Match the type of update with the correct analogy/description:

| Update Type             | Analogy/Description                                                      |
| :---------------------- | :----------------------------------------------------------------------- |
| 1. Synchronous Updates  | A. Runs tasks one after another, without parallel execution              |
| 2. Asynchronous Updates | B. Freezes the UI until the operation is complete                        |
| 3. Blocking Execution   | C. Ordering food at a restaurant and waiting in line until it is ready   |
| 4. Non-blocking Execution | D. Ordering food, receiving a buzzer, and waiting at a table until it rings |
|                         | E. Allows other tasks to continue while waiting for a response           |
  1. 1 → C, 2 → D, 3 → B, 4 → A
  2. 1 → B, 2 → A, 3 → D, 4 → C
  3. 1 → A, 2 → B, 3 → E, 4 → C
  4. 1 → C, 2 → D, 3 → B, 4 → E
Q12MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
Given the following test code:

```python
def test_about(client):
    response = client.get('/about')
    assert response.status_code == 200
    assert b'This is the about page.' in response.data
```

Assume the client fixture works correctly and you are testing a Flask route `/about` that should return the text "This is the about page.". Which of the following options would cause this test to fail?
  1. text
    The route `/about` is missing in `app.py`.
  2. text
    The route `/about` exists but returns "About us page" instead.
  3. text
    The route `/about` returns `<p>this is the about page.</p>` instead of plain text.
  4. None of these.
Comprehension passage - the questions below it refer to this
Based on the above data, answer the given subquestions. question figure
Q13MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
The goal is to print "Even" for even numbers and "Odd"
for odd numbers in the sequence. Which of the following
if-else blocks should replace <!-- Missing code goes
here --> so that the code works correctly?
  1. question figure
    text
    ```jinja2
    {% if num / 2 == 0 %}
    Even
    {% else %}
    Odd
    {% endif %}
    ```
  2. question figure
    text
    ```jinja2
    {% if num % 2 == 0 %}
    Even
    {% else %}
    Odd
    {% endif %}
    ```
  3. question figure
    text
    ```jinja2
    {% if num is even %}
    Even
    {% else %}
    Odd
    {% endif %}
    ```
  4. question figure
    text
    ```jinja
    {% if num % 2 %}
    Even
    {% else %}
    Odd
    {% endif %}
    ```
Q14MCQ2 marks
If the correct if-else block is used, what will be the output of the program for the sequence [2, 5, 8]?
  1. question figure
    text
    Even
    Even
    Even
  2. question figure
    text
    Odd
    Even
    Odd
  3. question figure
    text
    ```
    2
    5
    
    8
    ```
  4. question figure
    text
    Even
    Odd
    Even
Comprehension passage - the questions below it refer to this
A Household Services Application maintains the following three tables: question figure The Requests table represents service bookings made by customers. Based on the above data, answer the given subquestions. question figure question figure
Q15MCQ3 marks
Which SQL query correctly retrieves the customer names and the services they requested?
  1. question figure
    text
    ```sql
    SELECT c.name, s.service_name
    FROM customers c, services s
    WHERE c.id = s.id;
    ```
  2. question figure
    text
    ```sql
    SELECT c.name, r.status
    FROM customers c
    JOIN services s ON c.id = s.id;
    ```
  3. question figure
    text
    ```sql
    SELECT c.name, s.service_name
    FROM customers c
    JOIN requests r ON c.id = r.customer_id
    JOIN services s ON r.service_id = s.id;
    ```
  4. question figure
    text
    ```sql
    SELECT c.name, s.service_name
    FROM services s
    LEFT JOIN customers c ON s.id = c.id;
    ```
Q16MCQ3 marks
Which query finds the number of service requests made by each customer?
  1. question figure
    text
    ```sql
    SELECT r.customer_id, COUNT(*) AS total_requests
    FROM requests r;
    ```
  2. question figure
    text
    ```sql
    SELECT c.name, COUNT(r.service_id) AS total_requests
    FROM customers c
    JOIN requests r ON c.id = r.customer_id
    GROUP BY c.name;
    ```
  3. question figure
    text
    ```sql
    SELECT c.name, COUNT(s.id) AS total_requests
    FROM customers c
    JOIN services s ON c.id = s.id
    GROUP BY c.name;
    ```
  4. question figure
    text
    ```sql
    SELECT c.name, r.service_id
    FROM customers c
    JOIN requests r ON c.id = r.customer_id;
    ```
Q17MCQ2 marks
If the given tables are mapped to Flask-SQLAlchemy models (Customer, Service, Request), which query correctly retrieves all services requested by customer with id=1?
  1. question figure
    text
    ```python
    customer = Customer.query.filter_by(id=1).first()
    services = Service.query.all()
    ```
  2. question figure
    text
    ```python
    services = Service.query.filter_by(customer_id=1).all()
    ```
  3. question figure
    text
    ```python
    customer = Customer.query.get(1)
    services = [r.service for r in customer.requests]
    ```
  4. question figure
    text
    ```python
    services = Request.query.filter_by(id=1).all()
    ```
Q18MCQ2 marks
Which of the following is the correct way to add a click event listener to a button with id="myBtn" in JavaScript?
  1. question figure
    text
    ```javascript
    document.getElementById("myBtn").onclick = function() {alert("Clicked!");
    };
    ```
  2. question figure
    text
    ```javascript
    document.getElementById("myBtn").addEventListener("click", function() {
        alert("Clicked!");
    });
    ```
  3. question figure
    text
    ```html
    <button onclick="alert('Clicked!')">Click Me</button>
    ```
  4. All of these
Q19MCQ3 marks
question figure
Text of the picture (copyable)
What will be the output of the following code?
```html
<script>
  function greet(name = "Guest") {
    return "Hello, " + name;
  }
  console.log(greet());
  console.log(greet("Alice"));
</script>
```
  1. question figure
    text
    Hello, Guest
    Hello, Alice
  2. question figure
    text
    ```
    Hello, undefined
    Hello, Alice
    ```
  3. question figure
    text
    ```
    Hello, Guest
    '[object console]'
    ```
  4. Error: Missing argument
Q20MCQ3 marks
question figure
Text of the picture (copyable)
You want to change the text of a `<p>` element with `id="msg"` to "Welcome to JavaScript!" when a button is clicked. Which code snippet correctly does this?

```html
<p id="msg">Old Message</p>
<button id="btn">Change</button>
<script>
    // Code goes here
</script>
```
  1. question figure
    text
    ```javascript
    document.getElementById("btn").onclick = function() {
        document.getElementById("msg").innerHTML = "Welcome to JavaScript!";
    };
    ```
  2. question figure
    text
    ```javascript
    document.getElementById("btn").addEventListener("click", function() {
        msg.text = "Welcome to JavaScript!";
    });
    ```
  3. question figure
    text
    ```javascript
    document.querySelector("#btn").addEventListener("click", function() {
        document.querySelector("#msg").innerText = "Welcome to JavaScript!";
    });
    ```
  4. Both andquestion figure
    text
    ```javascript
    document.getElementById("btn").onclick = function() {
        document.getElementById("msg").innerHTML = "Welcome to JavaScript!";
    };
    ```
Q21MCQ2 marks
Consider the data table below in SQLite database. question figure
Text of the picture (copyable)
Table: products

| pid | name  | price |
| :-- | :---- | :---- |
| 101 | Pen   | 10    |
| 102 | Bag   | 450   |
| 103 | Watch | 800   |
| 104 | Shoes | 1300  |

Which query lists all products sorted from expensive to cheap?
  1. SELECT * FROM products ORDER BY price ASC;
  2. SELECT * FROM products ORDER BY price DESC;
  3. SELECT price FROM products;
  4. SELECT MAX(price) FROM products;
Q22MSQ3 marksselect all that apply
Which of the following commands is/are valid to run pytest from the command line?
  1. pytest
  2. pytest test_file.py
  3. pytest -run
  4. pytest -k “login”
Q23MCQ2 marks
Consider the following Python code. question figure Which of the following assertion test case throws the exception?
Text of the picture (copyable)
```python
def max_value(nums):
    if not nums:
        return None
    return max(nums)

def test_max_value():
    ##Assertions to test max_value function##
```
  1. assert max_value([3, 7, 2]) == 7
  2. assert max_value([]) is None
  3. assert max_value("abczfk") == "z"
  4. assert max_value(1) == 1
Q24MCQ2 marks
What does the following curl command do? question figure
Text of the picture (copyable)
```
curl -X POST -d "username=student&password=1234" https://student/login
```
  1. Sends a POST request to retrieve data.
  2. Sends a POST request to send form data.
  3. Sends a POST request to send JSON data.
  4. Sends a POST request to retrieve JSON data.
Q25MCQ2 marks
question figure
Text of the picture (copyable)
Consider the following HTML5 form:

```html
<form method="POST" action="/submit">
    <input type="email" name="email" required>
    <input type="password" name="password" required minlength="8">
    <input type="number" name="age" min="18" max="65" required>
    <button type="submit">Submit</button>
</form>
```

Which of the following attributes are HTML5 native validation features that work without JavaScript?
  1. required, minlength, and type="email"
  2. min, max, and minlength
  3. required, type="password", and action
  4. type="email", min, max, minlength, and required
Q26MSQ5 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following Flask-RESTful code:

```python
class UserResource(Resource):
    def get(self, user_id=None):
        if user_id:
            return {"message": "User details", "id": user_id}, 200
        return {"message": "All users"}, 200

    def post(self):
        return {"message": "User created"}, 201

api.add_resource(UserResource, '/users', '/users/<int:user_id>')
```

Which of the following requests will execute successfully?
  1. GET /users - returns 200 with all users
  2. GET /users/5 - returns 200 with user details for ID 5
  3. POST /users - returns 201 with user created message
  4. POST /users/5 - returns 201 with user created message
Q27MSQ3 marksselect all that apply
Which statements about frontend and backend validation are TRUE?
  1. Frontend validation (HTML5/JavaScript) is sufficient for security
  2. Frontend validation improves user experience by providing immediate feedback
  3. Backend validation is mandatory for security because frontend can be bypassed
  4. Backend validation should validate the same constraints as frontend
Q28MCQ3 marks
question figure
Text of the picture (copyable)
Consider this logging setup:

```python
import logging

logging.basicConfig(level=logging.INFO,
                    format='%(levelname)s:%(name)s:%(message)s')

logging.debug("Debug message")
logging.info("Info message")
logging.warning("Warning message")
```

What will be displayed in the output?
  1. All three messages will be displayed
  2. Only the info and warning messages will be displayed
  3. Only the warning message will be displayed
  4. Only the info and debug messages will be displayed
Q29MCQ4 marks
question figure
Text of the picture (copyable)
Given the following pytest test structure:

```python
@pytest.fixture
def sample_data():
    return {"name": "John", "age": 30}

def test_name(sample_data):
    assert sample_data["name"] == "John"

def test_age(sample_data):
    assert sample_data["age"] == 30
```

When running `pytest -v`, how many times will the sample_data fixture be executed?
  1. Once for all tests
  2. Twice, once for each test
  3. Once during collection phase only
  4. It depends on the pytest configuration
Q30MCQ5 marks
question figure
Text of the picture (copyable)
Consider test file with markers:

```python
@pytest.mark.slow
def test_database():
    pass

@pytest.mark.unit
def test_calculation():
    pass

@pytest.mark.slow
@pytest.mark.unit
def test_complex():
    pass
```

Running `pytest -m "unit and not slow"` will execute which tests?
  1. test_database and test_complex
  2. Only test_calculation
  3. test_calculation and test_complex
  4. All three tests
Q31MCQ2 marks
You are on the main branch and want to merge feature1 and feature2 branches. What is the correct command sequence?
  1. text
    ```
    git merge feature1 then git merge feature2
    ```
  2. question figure
    text
    ```
    git checkout feature1 then git merge feature2 then git merge main
    ```
  3. question figure
    text
    ```
    git checkout feature1 then git merge feature2 then git checkout main then git merge feature1
    ```
  4. question figure
    text
    ```
    git merge feature1 then git checkout feature2 then git merge main
    ```
Q32MCQ3 marks
question figure
Text of the picture (copyable)
In a Flask-Login protected route below:

```python
@app.route('/dashboard')
@login_required
def dashboard():
    return f"Welcome {current_user.username}"
```

What happens when an unauthenticated user tries to access /dashboard?
  1. Returns a 404 error
  2. Displays "Welcome None"
  3. Redirects to the login page
  4. Returns an error page with HTTP 403

Answer key

  1. Q1 (MCQ, 4 marks): D
  2. Q2 (MSQ, 5 marks): A, B
  3. Q3 (MSQ, 5 marks): B, E
  4. Q4 (MSQ, 3 marks): B, D
  5. Q5 (MCQ, 3 marks): B
  6. Q6 (MCQ, 3 marks): B
  7. Q7 (MCQ, 4 marks): D
  8. Q8 (MCQ, 4 marks): D
  9. Q9 (MCQ, 3 marks): C
  10. Q10 (MSQ, 3 marks): A, B, C
  11. Q11 (MCQ, 3 marks): D
  12. Q12 (MSQ, 3 marks): A, B, C
  13. Q13 (MSQ, 3 marks): B, C
  14. Q14 (MCQ, 2 marks): D
  15. Q15 (MCQ, 3 marks): C
  16. Q16 (MCQ, 3 marks): B
  17. Q17 (MCQ, 2 marks): C
  18. Q18 (MCQ, 2 marks): D
  19. Q19 (MCQ, 3 marks): A
  20. Q20 (MCQ, 3 marks): D
  21. Q21 (MCQ, 2 marks): B
  22. Q22 (MSQ, 3 marks): A, B, D
  23. Q23 (MCQ, 2 marks): D
  24. Q24 (MCQ, 2 marks): B
  25. Q25 (MCQ, 2 marks): D
  26. Q26 (MSQ, 5 marks): A, B, C
  27. Q27 (MSQ, 3 marks): B, C, D
  28. Q28 (MCQ, 3 marks): B
  29. Q29 (MCQ, 4 marks): B
  30. Q30 (MCQ, 5 marks): B
  31. Q31 (MCQ, 2 marks): A
  32. Q32 (MCQ, 3 marks): C