MAD Study Hub

Home / Past papers / MAD1 Quiz 2 / this paper

Modern Application Indian Institute Of Technology, Madras - Bs In Data Science And Applications Development I 14 Aug 26 - 16 Aug 2026

MAD1 Quiz 216 questions50 marks11 MCQ · 3 MSQ · 2 SA
Elapsed 00:00
Q1MCQ3 marks
Consider the Flask SQLAlchemy data model. question figure What is the output after the following Python code is executed ? (Assume all entries are successfully committed to the database) 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)
```
```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='opqrst@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. 4
  2. 3
  3. 2
  4. 1
Q2MCQ3 marks
Consider the SQLAlchemy model Order mapped to the table orders. question figure
Text of the picture (copyable)
Table name: orders

| id | cust_id | status | amount |
|---|---|---|---|
| 1 | C101 | PAID | 500 |
| 2 | C102 | PENDING | 1200 |
| 3 | C101 | PAID | 800 |
| 4 | C103 | CANCELLED | 400 |
| 5 | C102 | PAID | 1200 |

Choose the correct SQLAlchemy statements that is similar to the SQL query:

```sql
SELECT * FROM orders where status='PAID' and amount>500;
```
  1. question figure
    text
    ```python
    order_records = db.session.query(Order).filter( \
        Order.status == "PAID" and Order.amount > 500)
    ```
  2. question figure
    text
    ```python
    order_records = db.session.query(Order) \
        .filter(Order.status == "PAID") \
        .filter(Order.amount > 500)
    ```
  3. question figure
    text
    ```python
    order_records = db.session.query(Order).filter( \
        Order.status == "PAID") and \
    db.session.query(Order).filter(Order.amount > 500)
    ```
  4. question figure
    text
    ```python
    order_records = db.session.query(Order.status == "PAID" and \
        Order.amount > 500)
    ```
Q3MCQ3 marks
Consider the following models: Course and Enrollment corresponding to tables course and enrollment in SQLite database. question figure Based on the model schemas, what relationship do the classes Course and Enrollment share?
Text of the picture (copyable)
```python
class Course(db.Model):
    id = db.Column(db.Integer(), primary_key = True)
    title = db.Column(db.String(), unique = True)

class Enrollment(db.Model):
    id = db.Column(db.Integer(), primary_key = True)
    student_id = db.Column(db.String(), nullable = False)
    course_id = db.Column(db.Integer(), db.ForeignKey("course.id"))
```
  1. Many-to-Many
  2. One-to-Many
  3. One-to-One
  4. The tables are not at all related
Q4MCQ3 marks
Consider the following Python code. File name: decorator.py question figure What will be the output, when running the above code using the command "python decorator.py"?
Text of the picture (copyable)
```python
def loggerDecorator(func):
    def inner_wrapper():
        print("Function execution started")
        res1 = func()
        res2 = func()
        return res1, res2

    return inner_wrapper

@loggerDecorator
def getData():
    return "Data retrieved"

print(getData())
```
  1. question figure
    text
    ```
    ('Data retrieved', 'Data retrieved')
    Function execution started
    ```
  2. question figure
    text
    ```text
    Function execution started
    Data retrieved
    Data retrieved
    ```
  3. question figure
    text
    ```
    Function execution started
    ('Data retrieved', 'Data retrieved')
    ```
  4. question figure
    text
    ```
    Data retrieved
    Data retrieved
    Function execution started
    ```
Q5MCQ3 marks
Which of the following statements is correct? Statement 1: In Server-Side Rendering (SSR), the client's browser receives a nearly empty HTML skeleton and relies heavily on client-side JavaScript execution to fetch data and construct the Document Object Model (DOM). Statement 2: Client-Side Rendering (CSR) reduces the immediate processing load on the web server by offloading UI layout rendering tasks to the user's browser engine.
  1. Both are incorrect
  2. Both are correct
  3. Only Statement 1 is correct
  4. Only Statement 2 is correct
Q6MCQ3 marks
A recipe webpage needs to display two distinct sections: A list of ingredients where the order does not matter.1. A sequence of cooking steps that must be followed in order.2. Which combination of HTML list container tags is most appropriate for these sections?
  1. text
    Ingredients: <ol> | Cooking Steps: <ol>
  2. text
    Ingredients: `<ul>` | Cooking Steps: `<ul>`
  3. text
    Ingredients: `<d1>` | Cooking Steps: `<u1>`
  4. text
    Ingredients: `<ul>` | Cooking Steps: `<ol>`
Q7MCQ3 marks
Consider the following Python jinja2 templating code. question figure
Text of the picture (copyable)
File name: app.py
```python
from jinja2 import Template

t = Template("""
{% for i in range(3) %}
    {% set x = i %}
{% endfor %}
{{ x }}
""")

print(t.render())
```
What text output is generated when the command *python app.py* is executed?
  1. Nothing will be rendered in place of x
  2. 0
  3. 1
  4. 2
Q8MSQ5 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('/course/<path:subject>')
def course(subject):
    if "Python" in subject:
        return "Welcome to Python course!"
    else:
        abort(404)

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

@app.errorhandler(404)
def not_found(error):
    return "<h2>Course not available!</h2>"

app.run(debug=True)
```
  1. question figure
    text
    For the URL:
    
    ```
    http://127.0.0.1:5000/learn/web/Python?level=advanced
    ```
    
    The browser will render:
    
    **Course not available!**
  2. question figure
    text
    For the URL:
    
    ```
    http://127.0.0.1:5000/course/ML/Python?topic=NLP
    ```
    
    The browser will render:
    
    Welcome to Python course!
  3. question figure
    text
    For the URL:
    
    ```
    http://127.0.0.1:5000/learn/basics/Python?level=beginner
    ```
    
    The browser will render:
    
    Welcome to Python course!
  4. question figure
    text
    For the URL:
    
    ```
    http://127.0.0.1:5000/course/Java/React?type=Framework
    ```
    
    The browser will render:
    
    **Course not available!**
Q9MCQ5 marks
Consider the following Flask application structure and code. question figure Which of the following statements about the template rendering behavior is correct? question figure
Text of the picture (copyable)
```
my_app/
├── app.py
├── views/
│   └── index.html
├── templates/
│   ├── base.html
│   └── page.html
└── my_templates/
    ├── public/
    │   └── home.html
    └── private/
        └── dashboard.html
```
app.py:
```python
from flask import Flask, render_template

app = Flask(__name__, template_folder='my_templates')

@app.route('/')
def home():
    return render_template('public/home.html')

@app.route('/dashboard')
def dashboard():
    return render_template('private/dashboard.html')

@app.route('/view')
def view():
    return render_template('index.html')

@app.route('/page')
def page():
    return render_template('page.html')

if __name__ == '__main__':
    app.run(debug=True)
```
  1. All routes will work correctly as Flask searches both and
    text
    templates/
    ```
    my_templates/
    ```
  2. Only and routes work, while and routes fail with Error
    text
    /dashboard
    /view
    The image contains a single, small, blurry, diagonal line. It appears to be a checkmark or a slash, but its exact nature is unclear due to the low resolution.
    /page
    TemplateNotFound
  3. The and routes work, while and fail with Error
    text
    The image contains a single, small, blurry, diagonal line. It appears to be a checkmark or a slash, but its exact nature is unclear due to the low resolution.
    /dashboard
    /view
    /page
    TemplateNotFound
  4. All routes fail because Flask requires templates to be in a default folder
Q10MCQ2 marks
What does the following curl command do?
Text of the picture (copyable)
```
curl -X PUT -d "status=active&role=admin" https://api/users/update
```
  1. Sends a PUT request to update data using form format.
  2. Sends a PUT request using JSON encoding.
  3. Sends a GET request to retrieve user information.
  4. Sends a DELETE request to remove user data.
Q11MCQ2 marks
In the context of asynchronous updates, which of the following statements is correct?
  1. It updates a web page without reloading the whole page
  2. It leads to better user experience as it involves quick response on the main page with minimal data to refresh
  3. Both It updates a web page without reloading the whole page and It leads to better user experience as it involves quick response on the main page with minimal data to refresh are correct
  4. None of these
Q12MCQ4 marks
Consider the following Flask RESTful API code. 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)
```

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.

```bash
curl -X POST http://127.0.0.1:5000 -H "Content-Type: application/json" -d "{\"n\":3}"
```
  1. {"n": 3}
  2. Runtime error
  3. 400 Bad Request
  4. { }
Q13SA2 marks
A magnetic disk can spin only in one direction with a constant speed of 6000rpm. What is the maximum delay (worst-case latency) before data transfer starts (in milliseconds)?
Q14MSQ4 marksselect all that apply
Consider the following Flask app code. question figure The above flask app is running on "http://127.0.0.1:5000". Which of the following commands will return a runtime error?
Text of the picture (copyable)
```python
from flask import Flask
from flask_restful import Resource, Api

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

class UserResource(Resource):
    def get(self):
        return {"status": "GET request"}, 200

    def post(self, user_id):
        return {"status": "POST request", "user_id": user_id}, 201

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

if __name__ == "__main__":
    app.run(debug=True)
```
  1. text
    ```
    curl http://127.0.0.1:5000/users/5001 -X GET
    ```
  2. text
    ```
    curl http://127.0.0.1:5000/users/5001 -X POST
    ```
  3. text
    ```
    curl http://127.0.0.1:5000/users -X POST
    ```
  4. text
    ```
    curl http://127.0.0.1:5000/users -X GET
    ```
Q15MSQ2 marksselect all that apply
Which of the following statements is/are true about Document Object Model (DOM)?
  1. It is the programming interface for web documents.
  2. It is the abstract model of the document.
  3. Its structure is rigid and cannot be changed once created.
  4. It can only be manipulated with the help of JavaScript.
Q16SA3 marks
An e-commerce web application stores user shopping cart information as server-side session state. Each active user session occupies an average of 4 KB of memory. During a flash sale, the application is expected to handle 1.5 million concurrent active sessions, all stored in a centralized Redis cache server. What is the minimum RAM capacity (in GB) required solely to store these session states? (Assume that 1000B=1KB, 1000KB=1MB and so on)

Answer key

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