MAD Study Hub

Home / Past papers / MAD1 End Term / this paper

Modern Application Development I 06 May 26 - 10 May 2026

MAD1 End Term32 questions100 marks24 MCQ · 7 MSQ · 1 SA
Elapsed 00:00
Q1MCQ2 marks
Which of the following is the correct match between Column A and Column B? question figure
Text of the picture (copyable)
| Column A | Column B |
|---|---|
| 1. ftp | A. Web domain |
| 2. 127.0.0.1 | B. Protocol |
| 3. `<b></b>` | C. Decorator |
| 4. seek.onlinedegree.iitm.ac.in | D. Loop back IP |
| 5. @app.route | E. HTML element |
  1. 1-B, 2-D, 3-E, 4-A, 5-C
  2. 1-B, 2-A, 3-E, 4-D, 5-C
  3. 1-A, 2-D, 3-E, 4-B, 5-C
  4. 1-B, 2-D, 3-C, 4-A, 5-E
Q2MCQ2 marks
Logging is typically used for what purpose?
  1. detect unusual activity on the server.
  2. block unauthorized access.
  3. enforce HTTPS connections.
  4. convert HTTP to HTTPS.
Q3MCQ2 marks
A web server has an outgoing bandwidth of 5Gbps, and each client requires 2Mbps. What is the maximum number of concurrent requests allowed? (Use: 1KB= 1000Bytes, 1MB=1000KB and so on)
  1. 2.5
  2. 25
  3. 250
  4. 2500
Q4MCQ2 marks
Consider the following SQL Alchemy model with below data. question figure Which of the following SQL Alchemy statements is used to count the number of students registered for ?
Text of the picture (copyable)
CourseRegistrations
| ID | student_id | course_id | date_of_registration |
|---|---|---|---|
| 1 | S101 | CS101 | 17-10-2024 |
| 2 | S103 | CS101 | 10-10-2024 |
| 3 | S101 | CS201 | 16-10-2024 |
| 4 | S102 | CS101 | 17-10-2024 |
| 5 | S104 | CS201 | 06-10-2024 |
```
course_id="CS101"
```
  1. question figure
    text
    ```python
    count = db.session.query(CourseRegistrations) \
        .filter(course_id == "CS101") \
        .count()
    ```
  2. question figure
    text
    ```python
    count = db.session.query \
        .filter(CourseRegistrations.course_id == "CS101") \
        .count()
    ```
  3. question figure
    text
    ```python
    count = db.query(CourseRegistrations) \
        .filter(course_id == "CS101") \
        .count()
    ```
  4. question figure
    text
    ```python
    count = db.session.query(CourseRegistrations) \
        .filter(CourseRegistrations.course_id == "CS101") \
        .count()
    ```
Q5MCQ2 marks
What is the purpose of the primary_key=True attribute in a SQLAlchemy model?
  1. It allows duplicate values in the column
  2. It uniquely identifies each row in the table
  3. It automatically creates foreign key relationships
  4. It makes the column optional
Q6MSQ3 marksselect all that apply
Which of the following statements are correct regarding git?
  1. Files in the staging area can be committed.
  2. The command converts a local folder into a Git repository.
    text
    ```
    "git init"
    ```
  3. The command moves the local repository to the remote repository.
    text
    ```
    "git add"
    ```
  4. Git can be used only online.
  5. Git branches are pointers to commits.
Q7MSQ3 marksselect all that apply
Consider the following Python Flask code. question figure Which of the following options are true?
Text of the picture (copyable)
File name: app.py
```python
from flask import Flask, url_for

app = Flask(__name__)

@app.route("/home")
def index():
    return "Home page!"

@app.route("/login")
def signin():
    return "Login page!"

@app.route("/<route>")
def get_url(route):
    return url_for(route, _external=True)

app.run(debug=True)
```
Assume that the Flask app is running at http://127.0.0.1:5000.
  1. URL request: http://127.0.0.1:5000/signin will return output: http://127.0.0.1:5000/login
  2. URL request: http://127.0.0.1:5000/login will return output: http://127.0.0.1:5000/login
  3. URL request: http://127.0.0.1:5000/index will return output: http://127.0.0.1:5000/home
  4. URL request: http://127.0.0.1:5000/home will return output: http://127.0.0.1:5000/home
Q8MSQ3 marksselect all that apply
Consider the following Python Flask code. question figure
Text of the picture (copyable)
File name: app.py

```python
from flask import Flask

app = Flask(__name__)

@app.route("/calculate/<v1>/<v2>")
def compute(v1, v2):
    try:
        return f"{int(v1) / int(v2)}"
    except:
        return "Arithmetic operation error!"

app.run(debug=True)
```

Assume that the Flask app is running at http://127.0.0.1:5000. Which of the following URL requests will return "Arithmetic operation error!"?
  1. text
    ```
    http://127.0.0.1:5000/calculate/4/"2"
    ```
  2. text
    http://127.0.0.1:5000/calculate/4/4
  3. text
    ```
    http://127.0.0.1:5000/calculate/4/0.2
    ```
  4. text
    ```
    http://127.0.0.1:5000/calculate/4/2?v1=1
    ```
  5. text
    ```
    http://127.0.0.1:5000/calculate/4.0/0.5
    ```
Q9MSQ3 marksselect all that apply
Consider the following Python code. question figure Which of the following statement(s) should replace ==Missing code here== so that it prints the output without any KeyError exception?
Text of the picture (copyable)
```python
from string import Template

message = "Available courses: $course1, $course2, $course3"
template = Template(message)
==Missing code here===
```
  1. question figure
    text
    ```python
    print(template.safe_substitute({"course1": "Python", "course2": "Java",
    "course3": "C++",}))
    ```
  2. question figure
    text
    ```python
    print(template.substitute({"course1": "Python", "course2": "Java",
    "course3": "C++",}))
    ```
  3. question figure
    text
    ```python
    print(template.safe_substitute({"course1" : "Python", "course3" : "C++",}))
    ```
  4. question figure
    text
    ```python
    print(template.substitute({"course1" : "Python", "course2" : "Java"}))
    ```
Q10MCQ3 marks
Consider the following HTML/CSS code. question figure Read the following statements about “index.html” and choose the correct option. Statement 1: Internal element selector blue will be overridden by ID selector red. Statement 2: Internal ID selector red will be overridden by inline styling green.
Text of the picture (copyable)
File name: index. html

```html
<!DOCTYPE html>
<html lang="en">
<style>
    p{
        color: blue;
    }
    #mypara{
        color: red;
    }
</style>
<body>
    <p id="mypara" style="color: green">IIT BS Degree</p>
</body>
</html>
```
  1. Both statements are incorrect.
  2. Both statements are correct.
  3. Statement 1 is incorrect, but statement 2 is correct.
  4. Statement 2 is incorrect, but statement 1 is correct.
Q11MCQ3 marks
Consider the Flask SQLAlchemy data model. question figure
Text of the picture (copyable)
```python
class User(db.Model):
    __tablename__ = "user"
    id = db.Column(db.Integer, primary_key=True)
    mail_id = db.Column(db.String, unique=True)
    password = db.Column(db.String, nullable=False)
```

What is the output after the following Python code is executed ? (Assume all entries are successfully committed to the database)

```python
>>> u1=User(mail_id='abc@gmail.com',password='12345')
>>> u2=User(mail_id='pxyz@gmail.com',password='abcd1234')
>>> u3=User(mail_id='lmn@gmail.com',password='54321')
>>> u4=User(mail_id='pqrst@gmail.com',password='xyz123')
>>> db.session.add_all([u1,u2,u3,u4])
>>> db.session.commit()
>>> result=User.query.filter(User.mail_id.like('p%')).all()
>>> print(len(result))
```
  1. 1
  2. 2
  3. 3
  4. 4
Q12MCQ3 marks
You write an algorithm to sort N numbers (stored in an array a[0] to a[N-1]) as follows: Algorithm steps: i. Search through the list of numbers to find the lowest number - say it is position "i" ii. Move a[i-1] to a[i], a[i-2] to a[i-1] etc, till a[0] to a[1] iii. Place the original a[i] in position 0 iv. Repeat the above steps but now starting from position 1 to N-1, then 2 to N-1 etc till all numbers are in the correct places. What is the running complexity of this algorithm?
  1. linear
  2. quadratic
  3. cubic
  4. exponential
Q13MCQ3 marks
Consider the following graph that represents the variation in bandwidth of a network for an entire day (24 hours). Three users were connected to the network at three different times of the day. What is the total data consumed in GigaBytes by all the users in 24 hrs? question figure
Text of the picture (copyable)
This is a 2D line graph with a horizontal x-axis labeled "Time (Hours)" and a vertical y-axis labeled "BandWidth" with units "Megabits/s".

The x-axis ranges from 0 to 24, with major ticks at 0, 4, 8, 12, 14, 16, 20, and 24.
The y-axis ranges from 0 to 12, with major ticks at 0, 2, 4, 6, 8, 10.

There is an orange step-function line graph representing bandwidth over time.
- From 0 to 4 hours, bandwidth is 8 Megabits/s.
- From 4 to 8 hours, bandwidth is 10 Megabits/s.
- From 8 to 12 hours, bandwidth is 6 Megabits/s.
- From 12 to 16 hours, bandwidth is 8 Megabits/s.
- From 16 to 20 hours, bandwidth is 2 Megabits/s.
- From 20 to 24 hours, bandwidth is 4 Megabits/s.

Additionally, there are three horizontal lines with labels indicating user activity:
- A blue line labeled "user 1" extends from 0 to 4 hours at an unspecified y-value (visually above 10).
- A yellow line labeled "user 2" extends from 8 to 14 hours at an unspecified y-value (visually above 10).
- A green line labeled "user 3" extends from 16 to 24 hours at an unspecified y-value (visually above 10).

Vertical dashed lines extend from the x-axis ticks at 4, 8, 12, 14, 16, 20, and 24 hours up to the top of the graph.
  1. 547.2 GB
  2. 12 GB
  3. 43.2 GB
  4. 345.6 GB
Q14MCQ3 marks
Consider the following Python code. question figure
Text of the picture (copyable)
File name: test_cases.py

```python
def square(n):
    return n*n

def test1():
    assert square(5)==25

def test2():
    assert square(square(2))==16

def test3():
    assert square(square(2))==8
```

Assume that the above code is executed using the command “**pytest -v test_cases.py**”. What is the output of the tested code?
  1. question figure
    text
    ```
    test_cases.py::test1 PASSED
    test_cases.py::test2 PASSED
    test_cases.py::test3 FAILED
    ```
  2. question figure
    text
    ```
    test_cases.py::test1 PASSED
    test_cases.py::test2 FAILED
    test_cases.py::test3 FAILED
    ```
  3. question figure
    text
    ```
    test_cases.py::test1 PASSED
    test_cases.py::test2 FAILED
    test_cases.py::test3 PASSED
    ```
  4. question figure
    text
    ```
    test_cases.py::test1 PASSED
    test_cases.py::test2 PASSED
    test_cases.py::test3 PASSED
    ```
Q15MCQ3 marks
Consider the following Python Jinja2 template code. question figure
Text of the picture (copyable)
File name: main.py

```python
from jinja2 import Template
import sys

t = """
Better learning path of App Dev courses:
=>{{course[0]}} => {{course[1]}} => {{course[2]}} => {{course[3]}}
"""

course = sys.argv[1:]
render_t = Template(t)
output = render_t.render(course=course)
print(output)
```

Which of the following is the correct command to render the following **output**?
**Output**:

Better learning path of App Dev courses:
=>MAD1 => MAD2 => MAD1 Project => MAD2 Project
  1. python main.py MAD1 MAD2 MAD1 Project MAD2 Project
  2. python main.py MAD1 MAD2 MAD1_Project MAD2_Project
  3. python main.py "MAD1 MAD2 MAD1 Project MAD2 Project"
  4. python main.py MAD1 MAD2 "MAD1 Project" "MAD2 Project"
Q16MCQ3 marks
Consider the following csv file. question figure Choose the correct Python code that will print the output: ['90', '76', '81']?
Text of the picture (copyable)
File name: marks.csv

| id | name | course1 | course2 | course3 |
|---|---|---|---|---|
| 1 | Ram Kumar | 90 | 56 | 78 |
| 2 | David John | 67 | 76 | 71 |
| 3 | Sanju | 56 | 61 | 81 |
  1. question figure
    text
    ```python
    import csv
    
    with open("marks.csv") as marks:
        rows = csv.reader(marks)
        next(rows)
        max_m = [max(r[2:]) for r in rows]
        print(max_m)
    ```
  2. question figure
    text
    ```python
    import csv
    
    with open("marks.csv") as marks:
        rows = csv.reader(marks)
        max_m = [max(r) for r in rows]
        print(max_m)
    ```
  3. question figure
    text
    ```python
    import csv
    
    with open("marks.csv") as marks:
        rows = csv.reader(marks)
        next(rows)
        max_m = [max(r[2:]) for r in rows]
        print(max_m)
    ```
  4. question figure
    text
    ```python
    import csv
    
    with open("marks.csv") as marks:
        rows = csv.reader(marks)
        max_m = [max(r) for r in rows]
    print(max_m)
    ```
Q17MCQ3 marks
Which of the following is the correct flask_login code snippet to register a user as logged in for the current session?
  1. login_user(user.id)
  2. login_user(user)
  3. login_user(user.name)
  4. login_user(user.name and user.password)
Q18MCQ3 marks
Consider the following HTML code snippet (without any CSS styling). question figure Which of the following statements correctly describes how the elements will be displayed by default in a browser?
Text of the picture (copyable)
```html
<div>
  <h1>Content 1</h1>
  <p>Content 2</p>
  <span>Content 3</span>
  <span>Content 4</span>
</div>
```
  1. The content of all elements will appear on the same line as they are inline elements.
  2. The content of , and tags will start on new lines as they are block elements.
    text
    `<h1/>`
    `<p>`
    ```html
    <span>
    ```
  3. The content of and tags will start on new lines, others will display inline.
    text
    `<h1/>`
    `<p>`
  4. The content of tags will start on new lines, others will display inline.
    text
    ```html
    <span>
    ```
Q19MCQ3 marks
What does the following curl command do? question figure
Text of the picture (copyable)
```
curl -X POST -d "email=user@test.com&password=secret" https://auth/signin
```
  1. Sends a POST request to retrieve authentication 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 user credentials.
Comprehension passage - the questions below it refer to this
Consider the following HTML and Python flask code. question figure Based on the above data, answer the given subquestions. question figure
Q20MCQ3 marks
Which of the following statements are correct for the statements below? Statement 1: Accessing the URL: http://127.0.0.1:5000 directly in the browser makes a POST request. Statement 2: Clicking on the Submit button will invoke the GET request method.
  1. Both statements are correct.
  2. Both statements are incorrect.
  3. Statement 1 is incorrect, but statement 2 is correct.
  4. Statement 2 is incorrect, but statement 1 is correct.
Q21MCQ3 marks
What will be the rendered output for the following input in the form? question figure
Text of the picture (copyable)
UI screenshot:
A web form with a label "Enter a number :", an input field containing "-5", and a "Submit" button.
  1. 404 Not Found
  2. [-1, -2, -3, -4, -5]
  3. [ ]
  4. None of these
Q22MSQ2 marksselect all that apply
Which of the following statements are true in the context of HTML forms?
  1. default type is “submit”.
    text
    ```html
    <button>
    ```
  2. “read-only” inputs are not submitted.
  3. “disabled” inputs are not submitted.
  4. “required” works on
    text
    ```html
    <input type='hidden'>
    ```
Q23MSQ2 marksselect all that apply
Which of the following statements are true about DOM?
  1. Changing the DOM value changes the HTML source file.
  2. JS can interact with DOM elements.
  3. DOM is created before the JS is executed.
  4. DOM is created after the JS is executed.
  5. HTML and DOM are identical.
Q24MCQ4 marks
Consider the following Flask RESTful API code. question figure Assume that the Flask app is running at http://127.0.0.1:5000. The client sends the below CURL request in the git bash terminal. question figure What will be the response?
Text of the picture (copyable)
File name: app.py
```python
from flask_restful import reqparse, Resource, Api
from flask import Flask

parser = reqparse.RequestParser()
parser.add_argument("n", type=int, required=True)
app = Flask(__name__)
api = Api(app)

class MyResponse(Resource):
    def post(self):
        args = parser.parse_args()
        return args

api.add_resource(MyResponse, "/")
app.run(debug=True)
```
```
curl -X POST http://127.0.0.1:5000 -H "Content-Type: application/json" -d '{}'
```
  1. {"n": None}
  2. Runtime error
  3. 400 Bad Request
  4. { }
Q25MCQ4 marks
Consider the code below in a file called question figure Which of these is the correct output when the command is run in the terminal?
Text of the picture (copyable)
```
test_users.py
```
test_users.py

```python
import pytest

@pytest.fixture
def users():
    return { "emails": ["alice@test.com", "bob@test.com"], "roles":
             ["admin", "user"]}

def test_email(users):
    assert "alice@test.com" in users['emails']

def test_role(users):
    assert users['roles'][0] == "admin"
```
```
"pytest -k email"
```
  1. ====== 1 passed, 1 deselected in 0.02s =========
  2. ====== 1 passed, 2 deselected in 0.02s =========
  3. ====== 1 failed, 1 deselected in 0.02s =========
  4. ====== 1 failed, 2 deselected in 0.02s =========
Q26MCQ4 marks
Consider the following HTML templates and Python Flask code. question figure Assume that the Flask app is running at . What will be rendered for the URL request ?
Text of the picture (copyable)
File name: base.html
```html
<!DOCTYPE html>
<html lang="en">
<body>
    {% block content %}
    <div>Parent content</div>
    {% endblock %}
</body>
</html>
```

File name: child.html
```html
{% extends "base.html" %}
{% block content %}
    <div>Child content</div>
{% endblock %}
```

File name: app.py
```python
from flask import Flask, render_template

app = Flask(__name__)

@app.route("/home")
def index():
    return render_template("child.html")

app.run(debug=True)
```
http://127.0.0.1:5000
http://127.0.0.1:5000/home
  1. Parent content Child content
  2. Parent content
  3. Child content
  4. Child content Parent content
Q27MCQ5 marks
Consider the following Flask SQLAlchemy models and RESTful API code. question figure
Text of the picture (copyable)
File name: app.py
```python
class User(db.Model):
    __tablename__ = "user"
    id = db.Column(db.Integer, primary_key=True)
    full_name = db.Column(db.String, unique=True)

class UserPosts(db.Model):
    __tablename__ = "user_posts"
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String, unique=True, nullable=False)
    description = db.Column(db.String, nullable=True)
    user_id = db.Column(db.Integer, db.ForeignKey("user.id"))

class UserApi(Resource):
    def post(self):
        user_data = request.json
        ==Missing code 1==
        db.session.add(user)
        db.session.commit()
        return {"msg": "User added!"}, 201

class UserPostsApi(Resource):
    def post(self):
        post_data = request.json
        ==Missing code 2==
        db.session.add(user_post)
        db.session.commit()
        return {"msg": "Post added!"}, 201
```
Which of the following is the most suitable ==Missing code 1== and ==Missing code 2==? So that the Flask application does not return any run-time error?
  1. question figure
    text
    ==Missing code 1==
    ```python
    user = User(full_name=user_data["full_name"])
    ```
    
    ==Missing code 2==
    ```python
    user_post = UserPosts(
        title=post_data["title"],
        description=post_data["description"],
        user_id=post_data["user_id"],
    )
    ```
  2. question figure
    text
    ```python
    ==Missing code 1==
    user = User(name=user_data["full_name"])
    
    ==Missing code 2==
    user_post = UserPosts(
        post_title=post_data["title"],
        post_description=post_data["description"],
        post_user_id=post_data["user_id"],
    )
    ```
  3. question figure
    text
    ```python
    ==Missing code 1==
    user_data = User(full_name=user_data["full_name"])
    
    ==Missing code 2==
    user_post_data = UserPosts(
        title=post_data["title"],
        description=post_data["description"],
        user_id=post_data["user_id"],
    )
    ```
  4. question figure
    text
    ```
    ==Missing code 1==
    user_data = User(name=user_data["full_name"])
    
    ==Missing code 2==
    user_post_data = UserPosts(
        post_title=post_data["title"],
        post_description=post_data["description"],
        post_user_id=post_data["user_id"],
    )
    ```
Q28MCQ5 marks
Consider the following HTML/JavaScript code. question figure The above code allows courses to be added dynamically to the element when the user clicks the “Add” Button. What is the most suitable given below?
Text of the picture (copyable)
File name: courses.html

```html
<!DOCTYPE html>
<html lang="en">
<body>
    <label>Enter course :</label>
    <input type="text" id="txt_course">
    <button onclick="add_item()">Add</button><br>
    Courses:<br>
    <ul id="courses">
        <!-- Empty courses-->
    </ul>
    <script>
        function add_item(){
            course=document.getElementById("txt_course").value;
            document.getElementById("txt_course").value="";
            // Missing JS Code snippet
        }
    </script>
</body>
</html>
```

Expected output:

Enter course : [text input field] [Add button]
Courses:
* Java
* PDSA
```html
<ul>
```
```javascript
//Missing JS Code snippet
```
  1. question figure
    text
    ```javascript
    courses=document.getElementById("txt_course");
    courses.innerHTML=courses.innerHTML+"<li>"+course+"</li>";
    ```
  2. question figure
    text
    ```javascript
    courses=document.getElementById("courses");
    courses.innerHTML=courses.innerHTML+"<li>"+course+"</li>";
    ```
  3. question figure
    text
    ```javascript
    courses.innerHTML=courses.innerHTML + "<li>"+course+"</li>";
    ```
  4. question figure
    text
    ```javascript
    courses.innerHTML = "<li>"+course+"</li>";
    ```
Q29MCQ5 marks
Consider the following flask application "app.py" given below. question figure
Text of the picture (copyable)
```python
import sys
from flask import Flask, render_template

app = Flask(__name__, static_folder = 'public')

@app.route('/')
def func():
    folder_1 = sys.argv[1]
    folder_2 = sys.argv[2]

    if app.static_folder == folder_1:
        return f"<h1>Static folder verified: {folder_1}</h1>"

    if app.static_folder == folder_2:
        return f"<h1>Static folder verified: {folder_2}</h1>"

    return "<h1>Invalid argument</h1>"

app.run(debug = True)
```

If the application is running locally on http://127.0.0.1:5000. What will be rendered by the browser for the command:

```
python app.py /assets /public
```
  1. Static folder verified: /assets
  2. Static folder verified: /public
  3. Invalid argument
  4. None of these
Q30MCQ5 marks
Examine the following Python code snippet. question figure What will be the output when running the command: ?
Text of the picture (copyable)
File: app_logger.py

```python
import logging
import sys

logging.basicConfig(level=logging.INFO,
                    format='%(asctime)s - %(levelname)s - %(message)s')


def calculate(num):
    logging.debug("Calculation initialized")
    logging.info("Input number: %d", num)

    if num == 0:
        logging.warning("Zero detected - cannot process")
        return None
    elif num > 100:
        logging.error("Number exceeds limit: %d", num)
        return None
    else:
        result = num * 2
        logging.info("Calculation succeeded")
        return result


try:
    input_num = int(sys.argv[1])
    result = calculate(input_num)
    if result:
        print(f"Result: {result}")
except IndexError:
    logging.critical("No argument supplied")
except ValueError:
    logging.error("Argument is not numeric")
```
```
python app_logger.py 150
```
  1. question figure
    text
    ```
    2024-07-29 10:20:15,234 - DEBUG - Calculation initialized
    2024-07-29 10:20:15,235 - INFO - Input number: 150
    2024-07-29 10:20:15,236 - ERROR - Number exceeds limit: 150
    ```
  2. question figure
    text
    ```
    2024-07-29 10:20:15,235 - INFO - Input number: 150
    2024-07-29 10:20:15,236 - ERROR - Number exceeds limit: 150
    ```
  3. question figure
    text
    ```
    2024-07-29 10:20:15,235 - WARNING - Zero detected - cannot process
    2024-07-29 10:20:15,236 - ERROR - Number exceeds limit: 150
    ```
  4. question figure
    text
    ```
    2024-07-29 10:20:15,235 - INFO - Input number: 150
    2024-07-29 10:20:15,236 - DEBUG - Calculation succeeded
    ```
Q31SA2 marks
A magnetic disk can spin only in one direction with a constant speed of 5000rpm. What is the maximum delay(worst-case latency) before data transfer starts (in milliseconds)?
Q32MSQ4 marksselect all that apply
Consider the following flask app. Given that allows code to be tested without a server, which of the following statements is correct? question figure
Text of the picture (copyable)
```
test_request_context()
```
```python
from flask import Flask, url_for

app = Flask(__name__)

@app.route('/api')
def api():
    return 'API Response'

@app.route('/data/<category>')
def data(category):
    return f'Data for {category}'

with app.test_request_context():
    #== print statement ==#
```
  1. If is replaced by , the output on the terminal will be
    text
    ```python
    #=== print statement ===#
    ```
    ```python
    print(url_for('data', category='sales'))
    ```
    ```
    /data?category=sales
    ```
  2. If is replaced by , the output on the terminal will be
    text
    ```python
    #=== print statement ===#
    ```
    ```python
    print(url_for('data', category='sales', format='json'))
    ```
    ```
    /data/sales/json
    ```
  3. If is replaced by , the output on the terminal will be
    text
    ```python
    #=== print statement ===#
    ```
    ```python
    print(url_for('api', category='sales'))
    ```
    ```
    /api?category=sales
    ```
  4. If is replaced by , the output on the terminal will be
    text
    ```python
    #=== print statement ===#
    ```
    ```python
    print(url_for('api'))
    ```
    /api

Answer key

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