MAD Study Hub

Home / Past papers / MAD1 Quiz 2 / this paper

IIT M DIPLOMA AN EXAM QDD4 03 Aug - 03 Aug 2025

MAD1 Quiz 216 questions50 marks10 MCQ · 5 MSQ · 1 SADiploma / afternoon / QDD4
Elapsed 00:00
Q1MCQ2 marks
You manage a datacenter where each server has a 10 Gigabit per second network connection and the facility’s backbone link is also 10 Gbps. Your application is handling 10,000 requests per second, each with a 50 KB response, which translates to about 4 Gbps of required throughput. So, if each request involves minimal CPU processing, and the existing server has sufficient resources to handle the load. Which of the following scaling strategies is most appropriate to meet this demand?
  1. Scale up on a single server
  2. Scale out to multiple servers in the datacenter
  3. Both will produce similar results
  4. None of these
Q2MCQ2 marks
Which of the following statements BEST describes a key advantage of Jinja2 server-side rendering over JavaScript/JSON-based client-side rendering?
  1. It guarantees that dynamic updates on user interactions never requireadditional data fetches.
  2. It provides faster initial page load and improved Search Engine Optimizationwithout requiring client-side template logic.
  3. It allows the client to handle all template rendering, reducing load on theserver.
  4. None of these
Q3MCQ2 marks
question figure
Text of the picture (copyable)
Consider the following table "ExamScores" in the SQLite database.

| id | score |
|----|-------|
| 1  | 57    |
| 2  | 98    |
| 3  | 83    |

Which of the following Python statements will print the maximum score value?
  1. question figure
    text
    ```python
    >>> print(db.session.query.max(ExamScores.score))
    ```
  2. question figure
    text
    ```python
    >>> print(db.session.query(func.max(ExamScores.score)).scalar())
    ```
  3. question figure
    text
    ```python
    >>> print(db.session.query(func.max(ExamScores.score)))
    ```
  4. question figure
    text
    ```python
    >>> print(db.session.query.max(ExamScores.score).scalar())
    ```
Q4MCQ2 marks
What is the right syntax to use an external JavaScript file(.js) into the current html file?
  1. question figure
    text
    ```html
    <script src="jsfile.js"></script>
    ```
  2. question figure
    text
    ```html
    <script href="jsfile.js"></script>
    ```
  3. question figure
    text
    ```html
    <import src="jsfile.js"></import>
    ```
  4. question figure
    text
    ```html
    <import link="jsfile.js"></import>
    ```
Q5MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following Flask and HTML implementations.

Flask file: main.py

```python
from flask import Flask, render_template
app = Flask(__name__)

@app.route("/text/size/<int:size>/<color>")
def set_size(size, color):
    style = {"font-size": str(size) + "px", "color": color}
    return render_template("index.html", css_style=style)

app.run(debug=True)
```

HTML file: index.html

```html
<!DOCTYPE html>
<html>
    <div style="color: {{css_style['color']}};
    font-size:{{css_style['font-size']}};">
        IITM BS Degree Program
    </div>
</html>
```

Assume that the Flask code is running on the server http://127.0.0.1:5000 without any errors.
Choose the correct URL to render the output below.

IITM BS Degree Program
  1. question figure
    text
    http://127.0.0.1:5000?text=red&size=20
  2. question figure
    text
    ```
    http://127.0.0.1:5000?size=20&text=red
    ```
  3. question figure
    text
    ```
    http://127.0.0.1:5000/text/size/red/20
    ```
  4. question figure
    text
    ```
    http://127.0.0.1:5000/text/size/20/red
    ```
Q6MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following Python code.
File name: main.py

```python
def calculate(funx):
    def wrapper(a, b):
        x = funx(a, b)
        return x**2
    return wrapper

@calculate
def foo(x, y):
    return x - y

# main code
print(foo(5, 2))
```

What is the correct output of the given code?
  1. 10
  2. 9
  3. 3
  4. 4
Q7MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following Python code snippet.

```python
from string import Template

msg = "The $lang programming language is $desc and $useful for web
development."

template = Template(msg)

print(=== OUTPUT ===)
```

Which of the following statements, when substituted in place of `=== OUTPUT ===`, will throw a KeyError?
  1. question figure
    text
    ```python
    template.substitute({'lang': 'Python'})
    ```
  2. question figure
    text
    ```python
    template.substitute({'lang': 'Python', 'desc': 'popular',
    'useful': 'useful'})
    ```
  3. question figure
    text
    ```python
    template.safe_substitute({'lang': 'Python'})
    ```
  4. question figure
    text
    ```python
    template.safe_substitute({'lang': 'Python', 'desc':
    'versatile'})
    ```
Q8MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following Flask app code.

```python
from flask import Flask, request

valid_users = [
    {"uid": "student", "pwd": "12345"},
    {"uid": "professor", "pwd": "54321"},
    {"uid": "hod", "pwd": "abcde"},
]

app = Flask(__name__)

@app.route("/signin")
def login():
    args = request.args
    for vu in valid_users:
        if vu["uid"] == args["uid"] and vu["pwd"] == args["pwd"]:
            return "You are authorized!!"
    else:
        return "You are unauthorized!!"

app.run(debug=True)
```

Assume the above flask app runs on "http://127.0.0.1:5000/" and is accessed through the web browser. What will be the output for the URL: "http://127.0.0.1:5000/signin?uid=professor&pwd=54321" ?
  1. You are authorized!!
  2. You are unauthorized!!
  3. Not Found
  4. Internal Server Error
Q9MCQ4.5 marks
question figure question figure
Text of the picture (copyable)
Consider the following HTML code.
Filename: main.html

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Greetings</title>
</head>
<body>

    <button onclick="alert('Hello, welcome')">Greet1!</button><br>
    <button onclick="console.log('Hello, welcome')">Greet2!</button><br>
    <button onclick="document.write('Hello, welcome')">Greet3!</button><br>
    <button onclick="console.error('Hello, welcome')">Greet4!</button>

</body>
</html>
```
Rendered HTML output below:

[Greet1!] (button)
[Greet2!] (button)
[Greet3!] (button)
[Greet4!] (button)

Which of the above “Greet” buttons will print greetings on the dialogue box?
  1. Greet4
  2. Greet3
  3. Greet2
  4. Greet1
Q10MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following flask application.

```python
from flask import Flask, abort
app = Flask(__name__)

users = ["admin", "user_1", "user_2", "user_3"]

@app.route('/home/<string:username>', methods = ['POST'])
def home(username):
    if username in users:
        return f"<h1>Hello {username}, Welcome!</h1>"
    else:
        abort(407)

@app.errorhandler(404)
def user_error_1(error):
    return "<h1>The user you are looking for is invalid.</h1>"

@app.errorhandler(405)
def user_error_2(error):
    return "<h1>Please check the web request.</h1>"

@app.errorhandler(407)
def user_error_4(error):
    return "<h1>Proxy authentication required.</h1>"

app.run()
```

If the application is running locally on `http://127.0.0.1:5000`. What will be rendered on the browser for the URL `http://127.0.0.1:5000/home/user_4` ?
  1. question figure
    text
    Hello user_4, Welcome!
  2. question figure
    text
    The user you are looking for is invalid.
  3. question figure
    text
    Not Found
  4. question figure
    text
    Please check the web request
Q11MSQ3 marksselect all that apply
Which of the following statements is/are false about caching in REST APIs?
  1. Caching allows storing server responses in a proxy or frontend so that a clientneed not make requests to the server for the same resources repeatedly.
  2. Caching degrades the overall quality of service and increases load on theservers.
  3. Browsers treat all GET and POST requests cacheable by default.
  4. Caching optimizes the network by increasing the latency.
Q12MSQ3 marksselect all that apply
Which of the following is/are correct with respect to storing data in graphs?
  1. Data on social networks can be stored with the help of graphs.
  2. Graphs support storing attributes such as node degree, edge weights ,andother metadata.
  3. Data is stored as a key-value pair.
  4. In graphs, path finding is not as important as just searching the data.
Q13MSQ4.5 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the Flask Restful API code given below:
File name: app.py

```python
from flask import Flask, request
from flask_restful import Resource, Api

app = Flask(__name__)
api = Api(app)

class APICalculator(Resource):
    def post(self):
        d = request.json
        a = int(d["val1"])
        b = int(d["val2"])
        oper = d["operator"]
        if oper == "+":
            return {"Sum": (a + b)}, 200
        elif oper == "-":
            return {"Difference": (a - b)}, 200
        elif oper == "*":
            return {"Product": (a * b)}, 200
        else:
            return {"Error": "Invalid option"}, 401

api.add_resource(APICalculator, "/")

app.run(debug=True)
```

Assume that the Flask server is running on http://127.0.0.1:5000. Which of the following is the correct curl command(s) that will return calculated values?
**Note: Assume data sent is valid for cmd, and powershell**
  1. question figure
    text
    ```
    curl -X POST "http://127.0.0.1:5000" -H 'Content-Type: application/json' -d '{"val1":27, "val2":3, "operator":"+"}'
    ```
  2. question figure
    text
    ```
    curl -X POST "http://127.0.0.1:5000" -H 'Content-Type: application/json' -d
    '{"val1":27,"val2":3,"operator":"**"}'
    ```
  3. question figure
    text
    ```
    curl -X POST "http://127.0.0.1:5000" -H 'Content-Type: application/json' -d '{"val1":27,"val2":3,"operator":"/"}'
    ```
  4. question figure
    text
    ```
    curl -X POST "http://127.0.0.1:5000" -d
    '{"val1":27, "val2":3, "operator":"/"}'
    ```
  5. question figure
    text
    ```
    curl -X POST "http://127.0.0.1:5000" -H 'Content-Type: application/json' -d '{"val1":27, "val2":3, "operator":"-"}'
    ```
Q14SA3 marks
question figure
Text of the picture (copyable)
Consider a document of 2000 characters written using only the characters from the character set L1 = {'x', 'y', 'z', 'w', 'v', 'u', 't', 's'}. If the character set L1 is to be upgraded by adding all the characters from the set L2 = {'1', '2', '3', '4', '5'}, by how many bits will the size of the original document increase?(assume an optimal number of bits are used for representing each character).
Comprehension passage - the questions below it refer to this
question figure
Q15MSQ4.5 marksselect all that apply
question figure
Text of the picture (copyable)
You need to obtain a list of (id, days_to_fix)
where days_to_fix is the number of days
between broken_at and fixed_at. Using
Flask-SQLAlchemy, which of the following
approaches will work?
  1. question figure
    text
    ```python
    repairs = GlassRepair.query.all()
    result = [
        (r.id, (r.fixed_at - r.broken_at).days)
        for r in repairs
    ]
    ```
  2. question figure
    text
    ```python
    repairs = db.session.query(GlassRepair).all()
    result = []
    for r in repairs:
        delta = r.fixed_at - r.broken_at
        result.append((r.id, delta.days))
    ```
  3. question figure
    text
    ```python
    repairs = GlassRepair.query(
        GlassRepair.id,
        (GlassRepair.fixed_at - GlassRepair.broken_at).label('days_to_fix')
    ).all()
    ```
  4. question figure
    text
    ```python
    from datetime import timedelta
    repairs = GlassRepair.query.all()
    result = [
        (r.id, timedelta(days=(r.fixed_at - r.broken_at)).days)
        for r in repairs
    ]
    ```
Q16MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
You want to retrieve all repairs that took more
than 7 days to fix. Using Flask-SQLAlchemy,
which of the following approaches will
correctly yield a list of (id, days_to_fix)
only for those records where days_to_fix > 7?
  1. question figure
    text
    ```python
    repairs = GlassRepair.query.filter_by(status='fixed').all()
    result = [
        (r.id, (r.fixed_at - r.broken_at).days)
        for r in repairs
        if (r.fixed_at - r.broken_at).days > 7
    ]
    ```
  2. question figure
    text
    ```python
    from sqlalchemy import and_
    
    repairs = GlassRepair.query.filter(
        and_(
            GlassRepair.status=='fixed',
    
            (GlassRepair.fixed_at - GlassRepair.broken_at) > 7
        )
    ).all()
    result = [(r.id, (r.fixed_at - r.broken_at).days) for r in repairs]
    ```
  3. question figure
    text
    ```python
    repairs = db.session.query(GlassRepair).all()
    result = []
    for r in repairs:
        days = (r.fixed_at - r.broken_at).days
        if days > 7 and r.status == 'fixed':
            result.append((r.id, days))
    ```
  4. question figure
    text
    ```python
    repairs = GlassRepair.query(
        GlassRepair.id,
        (GlassRepair.fixed_at - GlassRepair.broken_at).label('days_to_fix')
    ).filter_by(status='fixed').filter(
        GlassRepair.fixed_at - GlassRepair.broken_at > 7
    ).all()
    ```

Answer key

  1. Q1 (MCQ, 2 marks): A
  2. Q2 (MCQ, 2 marks): B
  3. Q3 (MCQ, 2 marks): B
  4. Q4 (MCQ, 2 marks): A
  5. Q5 (MCQ, 3 marks): D
  6. Q6 (MCQ, 3 marks): B
  7. Q7 (MCQ, 3 marks): A
  8. Q8 (MCQ, 3 marks): B
  9. Q9 (MCQ, 4.5 marks): D
  10. Q10 (MCQ, 4.5 marks): D
  11. Q11 (MSQ, 3 marks): B, C, D
  12. Q12 (MSQ, 3 marks): A, B
  13. Q13 (MSQ, 4.5 marks): A, B, E
  14. Q14 (SA, 3 marks): 2000
  15. Q15 (MSQ, 4.5 marks): A, B
  16. Q16 (MSQ, 3 marks): A, C

Concepts this paper tests

Auto-generated summary from the source site. Handy as a checklist; the lessons above explain each idea from scratch.

Summary of Core Topics, Concepts, Principles, and Equations

1. Modern Application Development

2. Database Management (SQLite, SQLAlchemy)

3. Web Development (Flask, HTML, JavaScript)

4. Python Programming

5. REST APIs and Caching

6. Data Structures (Graphs)

7. Mathematics (Information Theory)