MAD Study Hub

Home / Past papers / MAD1 Quiz 2 / this paper

IIT M DIPLOMA AN EXAM QDD2 01 Dec 2024 - 01 Dec 2024

MAD1 Quiz 216 questions50 marks10 MCQ · 6 MSQDiploma / afternoon / QDD2
Elapsed 00:00
Q1MCQ4.5 marks
You have a DRAM module with bus width of 64 bits, clock speed of 800 MHz, and operating in DDR (double-data-rate or two values per clock cycle) mode. What is the maximum memory bandwidth in Gigabytes per second achievable with this module if it is working in dual channel mode (two memory interfaces are used)?
  1. 51.2
  2. 102.4
  3. 25.6
  4. 12.8
Q2MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following table "product" created in SQLite database corresponding to model class "Product" using flask_sqlalchemy.

| id | name | type | form | quantity |
|---|---|---|---|---|
| 1001 | Cold Drinks | edible | liquid | 100 |
| 1002 | Detergent | non-edible | liquid | 126 |
| 1005 | Rugs | non-edible | solid | 345 |
| 1008 | LPG Cylinders | accessories | solid | 236 |
| 1009 | Curd | edible | semi-solid | 520 |

Which of the following code snippets will change the type of edible liquids to "perishable" and will increase their quantities by 450 correctly when typed in the Python console?
  1. question figure
    text
    ```python
    >>> prod = Product.query.filter_by(type = 'edible').all()
    >>> for item in prod:
    ...     item.type = "perishable"
    ...     item.quantity = 450
    ... 
    >>> db.session.commit()
    ```
  2. question figure
    text
    ```python
    >>> prod = Product.query.filter_by(type='edible', form="liquid").all()
    >>> for item in prod:
    ...     item.type = "perishable"
    ...     item.quantity += 450
    ... 
    >>> db.session.commit()
    ```
  3. question figure
    text
    ```python
    >>> prod = Product.query.filter_by(type='edible', form="liquid").all()
    >>> for item in prod:
    ...    item.form = "perishable"
    ...    item.quantity = 450
    ...
    >>> db.session.commit()
    ```
  4. question figure
    text
    ```python
    >>> prod = Product.query.filter_by(type = 'edible').all()
    >>> for item in prod:
    ...     item.form = "perishable"
    ...     item.quantity += 450
    ... 
    >>> db.session.commit()
    ```
Q3MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following python code.

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

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

salaries = {
    1: {"name": "Ravi", "basic": 14500},
    2: {"name": "David", "basic": 9500},
    3: {"name": "Tinu", "basic": 15009},
}

class Salaries(Resource):
    def do_something(self):
        global salaries
        for s in salaries.keys():
            salaries[s]["hra"] = salaries[s]["basic"] * 0.10

    def get(self):
        self.do_something()
        return salaries

api.add_resource(Salaries, "/api/salaries")
app.run(debug=True)
```

Consider that the above code is running locally on "http://127.0.0.1:5000". What will the output for the URL: "http://127.0.0.1:5000/api/salaries"?
  1. question figure
    text
    ```json
    {
        "1": {"hra": 1450.0 },
        "2": {"hra": 950.0 },
        "3": {"hra": 1500.9}
    }
    ```
  2. question figure
    text
    ```json
    {
        "1": {
            "name": "Ravi",
            "basic": 14500,
            "hra": 1450.0
        },
        "2": {
            "name": "David",
            "basic": 9500,
            "hra": 950.0
        },
        "3": {
            "name": "Tinu",
            "basic": 15009,
            "hra": 1500.9
        }
    }
    ```
  3. question figure
    text
    ```json
    {
      "1": {
        "name": "Ravi",
        "basic": 14500
      },
      "2": {
        "name": "David",
        "basic": 9500
      },
      "3": {
        "name": "Tinu",
        "basic": 15009
      }
    }
    ```
  4. question figure
    text
    ```json
    {
      "1": {
        "basic": 14500,
        "hra": 1450.0
      },
      "2": {
        "basic": 9500,
        "hra": 950.0
      },
      "3": {
        "basic": 15009,
        "hra": 1500.9
      }
    }
    ```
Q4MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following flask application.

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

@app.route('/login/<id>')
def login(id):
    if id:
        if id.isalnum():
            abort(400, "Bad Request: Invalid ID")
        return f'<h1>Your ID is: {id}</h1>'
    return f'<h1>Invalid ID</h1>'

app.run(debug=True)
```

Which of the following statements is/are true if the application is running locally on http://127.0.0.1:5000 ?
  1. question figure
    text
    For URL http://127.0.0.1:5000/login?id=MAD-I the browser will render
    Not Found
  2. question figure
    text
    For URL http://127.0.0.1:5000/login/ the browser will render
    **Invalid ID**
  3. question figure
    text
    For URL http://127.0.0.1:5000/login/CS2003 the browser will render Bad
    Request: Invalid ID
  4. question figure
    text
    For URL http://127.0.0.1:5000/login/PDSA the browser will render Bad
    Request: Invalid ID
Q5MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following flask application.
app.py
```python
from flask import Flask, abort, request

app = Flask(__name__)
data = {'PDSA':'CS2003', 'DBMS':'CS2004', 'Java':'CS2005'}
@app.route('/course/<course_name>')
def course(course_name):
    course_id = request.args.get('id')
    if course_name in data and course_id == data[course_name]:
        return f'<h1>The Course ID for {course_name} is: {course_id}</h1>'
    else:
        abort(400, "Bad Request: Invalid data")

app.run(debug=True)
```
Which of the following statements is/are true if the application is running locally on
http://127.0.0.1:5000 ?
  1. question figure
    text
    For URL http://127.0.0.1:5000/PDSA?id=CS2003 the browser will render;
    **Not Found**
  2. question figure
    text
    For URL http://127.0.0.1:5000/course/Java?id=CS2005 the browser will
    render;
    **The Course ID for Java is: CS2005**
  3. question figure
    text
    For URL http://127.0.0.1:5000/course?course_name=DBMS&id=CS2004 the
    browser will render;
    **The Course ID for DBMS is: CS2004**
  4. question figure
    text
    For URL http://127.0.0.1:5000/course/DBMS?id=CS2003 the browser will
    render;
    Bad Request: Invalid data
Q6MSQ3 marksselect all that apply
Consider the following HTML document “form.html” and the flask route given in “app.py”. Assume all the required methods are imported, Which of the following statements is/are correct. question figure Consider the following HTML document “form.html” and the flask route given in “app.py”. Assume all the required methods are imported, Which of the following statements is/are correct.
Text of the picture (copyable)
Filename: form.html

```html
<!DOCTYPE html>
<html>
<head>
    <style>
        input:valid {border: 2px solid red;}
    </style>
</head>
<body>
    <form action="/submit_form" method="post">
        <label for="e-mail">Please enter your email address</label>
        <input id="e-mail" name="e-mail" required/>
        <button>Submit</button>
    </form>
</body>
</html>
```

Filename: app.py

```python
@app.route('/submit_form', methods = ['GET', 'POST'])
def form_on_submit():
    if request.method == 'POST':
        email = request.form.get('e-mail')
        if "@" in email:
            return "Form is validated"
    return render_template('form.html')
```
  1. The above HTML document has frontend validation incorporated, usingHTML5 form validation.
  2. The above HTML document has only backend validation incorporated.
  3. The above HTML document has both frontend and backend validationincorporated.
  4. If the e-mail input field is left blank, the border colour of the input field will bered.
Q7MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following flask code.

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

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

class Car:
    def __init__(self, brand, model):
        self.brand = brand
        self.model = model

    def __str__(self) -> str:
        result = {
            "brand": self.brand,
            "model": self.model,
        }
        return str(result)

class MyApi(Resource):
    def get(self, brand, model):
        c = Car(brand, model)
        return json.dumps(c, default=vars)

api.add_resource(MyApi, "/api/<string:brand>/<string:model>")
app.run(debug=True)
```

If the flask server is running locally on "http://127.0.0.1:5000/". Which of the following URLs will result in a Not Found error?
  1. question figure
    text
    http://127.0.0.1:5000/api/maruti/swift
  2. question figure
    text
    ```
    http://127.0.0.1:5000/api/brand=Hyundai/model=Creta
    ```
  3. question figure
    text
    ```
    http://127.0.0.1:5000/api/brand=Ford,model=Fiesta
    ```
  4. question figure
    text
    http://127.0.0.1:5000/api/Honda&City
  5. question figure
    text
    http://127.0.0.1:5000/api/model=Accent/brand=Hundai
Q8MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the flask code below.

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

@app.route("/")
def get_home():
    a = [i for i in range(11)]
    t = ", ".join(map(str, a))
    return t

@app.route("/numbers/<int:n>")
def get_numbers(n):
    a = [i for i in range(n + 1)]
    t = ", ".join(map(str, a))
    return t

if __name__ == "__main__":
    app.run(debug=True)
```

Assume that the above flask application is running on http://127.0.0.1:5000. Which of the following statements is/are True for the above code snippet?
  1. question figure
    text
    URL : http://127.0.0.1:5000/
    Output: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
  2. question figure
    text
    URL: http://127.0.0.1:5000/numbers/5
    Output: 0, 1, 2, 3, 4, 5
  3. question figure
    text
    URL: http://127.0.0.1:5000/7
    Output: 0, 1, 2, 3, 4, 5, 6, 7
  4. question figure
    text
    URL: http://127.0.0.1:5000/7
    Output: **Not Found**
Q9MCQ3 marks
Consider a character set Q, which consists of only those characters used in the sentence, "the five boxing wizards jump quickly" If this sentence is to be saved in a document with minimum encoding, what will be the size of the document given that no other information or context is to be saved?
  1. 175 bits
  2. 180 bits
  3. 252 bits
  4. 256 bits
Q10MCQ3 marks
We are trying to create two models ‘Student’ and ‘Assignment’ and they are related by one-to-many relationship(i.e., one student will attempt multiple assignments). Assuming that flask_sqlalchemy is to be used to create data models, which of the following will correctly achieve the requirements?
  1. question figure
    text
    ```python
    class Student(db.Model):
        id=db.Column(db.Integer, primary_key=True)
        name=db.Column(db.String(50))
    
    class Assignment(db.Model):
        id=db.Column(db.Integer, primary_key=True)
        type=db.Column(db.String(4))
        marks=db.Column(db.Integer)
        student_id=db.Column(db.Integer)
    ```
  2. question figure
    text
    ```python
    class Student(db.Model):
        id=db.Column(db.Integer, primary_key=True)
        name=db.Column(db.String(50))
        assignments=db.relationship('Assignment', backref='student')
    
    class Assignment(db.Model):
        id=db.Column(db.Integer, primary_key=True)
        type=db.Column(db.String(4))
        marks=db.Column(db.Integer)
        student_id=db.ForeignKey('student.id')
    ```
  3. question figure
    text
    ```python
    class Student(db.Model):
        id=db.Column(db.Integer, primary_key=True)
        name=db.Column(db.String(50))
        assignments=db.relationship('Assignment', backref='student')
    
    class Assignment(db.Model):
        id=db.Column(db.Integer, primary_key=True)
        type=db.Column(db.String(4))
        marks=db.Column(db.Integer)
        student_id=db.Column(db.Integer, db.ForeignKey('student.id'))
    ```
  4. question figure
    text
    ```python
    class Student(db.Model):
        id=db.Column(db.Integer, primary_key=True)
        name=db.Column(db.String(50))
        assign_id=db.Column(db.Integer, db.Foreignkey('Assignment.id'))
    
    class Assignment(db.Model):
        id=db.Column(db.Integer, primary_key=True)
        type=db.Column(db.String(4))
        marks=db.Column(db.Integer)
    ```
Comprehension passage - the questions below it refer to this
Consider the following resource created using Flask, assume that the application is running on a terminal 1 and being accessed using CURL on terminal 2. Answer the given subquestions. question figure Consider the following resource created using Flask, assume that the application is running on a terminal 1 and being accessed using CURL on terminal 2. Answer the given subquestions.
Q11MCQ4.5 marks
What will be returned on the terminal 2 for the command: question figure What will be returned on the terminal 2 for the command:
Text of the picture (copyable)
```
curl http://127.0.0.1:5000/delete/val1
```
  1. question figure
    text
    ```json
    {"message": "Value deleted successfully", "value": "val1"}
    ```
  2. question figure
    text
    ```json
    {"message": "Value updated successfully", "value": "val1"}
    ```
  3. question figure
    text
    ```json
    {"val1": "value1"}
    ```
  4. question figure
    text
    None of these.
Q12MCQ3 marks
What will be returned on the terminal 2 for the command: question figure What will be returned on the terminal 2 for the command:
Text of the picture (copyable)
```
curl http://127.0.0.1:5000/delete/va11 -X PUT
```
  1. question figure
    text
    ```json
    {
      "message": "Value deleted successfully",
      "value": "val1"
    }
    ```
  2. question figure
    text
    ```json
    {"message": "Value updated successfully", "value": "val1"}
    ```
  3. question figure
    text
    ```json
    {"val1": "value1"}
    ```
  4. question figure
    text
    None of these.
Q13MSQ2 marksselect all that apply
Which of the following statements are correct?
  1. HTML defines the styling, while CSS defines the content
  2. HTML defines the content, while CSS defines the styling
  3. JavaScript is always the core part of an application’s frontend
  4. JavaScript provides additional functionality at the frontend
Q14MCQ2 marks
question figure
Text of the picture (copyable)
Identify the correct order of tasks that take place when a client makes a request on the URL: https://example.com/home.html.

1. The web browser sends an HTTPS request to the server, requesting a copy of home.html.
2. The web browser assembles the response and displays it.
3. The server responds either with the requested resource or an error code.
4. The web browser connects to the DNS server to get the server IP address, for example.com.
  1. 1-4-3-2
  2. 4-1-3-2
  3. 1-3-4-2
  4. 4-3-1-2
Q15MCQ2 marks
Consider the following statements and select the correct option. Statement 1: Redundancy is used to improve performance and decrease server load. Statement 2: Replication ensures data is not lost if a copy gets destroyed.
  1. Statement 1 is true & statement 2 is false
  2. Statement 2 is true & statement 1 is false
  3. Both statements 1 and 2 are true
  4. Both statements 1 and 2 are false
Q16MCQ2 marks
The term “stateless” in the context of a server means that _________
  1. it is not physically located on any particular machine
  2. it does not have any information about the state of the client
  3. it is ephemeral
  4. All of these

Answer key

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

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. Computer Architecture and Memory Bandwidth

2. Database Management and SQLAlchemy

3. Flask and RESTful APIs

4. HTML and Frontend Validation

5. Character Encoding and Information Theory

6. Database Relationships and Flask-SQLAlchemy

7. CURL Commands and HTTP Methods

8. Web Development Concepts

9. Networking and HTTP Requests

10. Server and Data Management

Graph 1: Computer Architecture and Memory Bandwidth

Graph 2: Database Management and SQLAlchemy

Graph 3: Flask and RESTful APIs

Graph 4: HTML and Frontend Validation

Graph 5: Character Encoding and Information Theory

Graph 6: Database Relationships and Flask-SQLAlchemy

Graph 7: CURL Commands and HTTP Methods

Graph 8: Web Development Concepts

Graph 9: Networking and HTTP Requests

Graph 10: Server and Data Management

These graphs and summaries should help you understand the core topics and their relationships, making it easier to study for the exam.