MAD Study Hub

Home / Past papers / MAD1 Quiz 2 / this paper

IIT M DIPLOMA QUIZ2 EXAM QPG1 10 July 2022 IBA - 10 Jul 2022

MAD1 Quiz 217 questions50 marks16 MCQ · 1 MSQDiploma / QUIZ2
Elapsed 00:00
Q1MCQ0 marks
question figure
Text of the picture (copyable)
THIS IS QUESTION PAPER FOR THE SUBJECT "MODERN APPLICATION DEVELOPMENT 1"

ARE YOU SURE YOU HAVE TO WRITE EXAM FOR THIS SUBJECT?
CROSS CHECK YOUR HALL TICKET TO CONFIRM THE SUBJECTS TO BE WRITTEN.

(IF IT IS NOT THE CORRECT SUBJECT, PLS CHECK THE SECTION AT THE TOP FOR THE SUBJECTS REGISTERED BY YOU)
  1. Yes
  2. No
Q2MSQ3 marksselect all that apply
Consider the Python file and a template given below. Python file: app.py question figure Consider the Python file and a template given below. Python file: app.py Template file: index.html question figure Consider the Python file and a template given below. Python file: app.py Template file: index.html If the above flask application is running locally on the URL ‘http://127.0.0.1:5000’, which of the following statements is/are true about the above code snippet?
Text of the picture (copyable)
```python
from flask import Flask, url_for, redirect, render_template
app = Flask(__name__)

@app.route("/<name>/")
def index1(name):
    return "Hi" + " " + name + "!" + " " + "This is your home page."

@app.route("/first_index/<string:name>")
def index2(name):
    if name == "XYZ":
        return redirect(url_for("index1", name = "XYZ"))
    else:
        return redirect( url_for("index3"))

@app.route("/second_index")
def index3():
    return render_template("index.html")

if __name__ == "__main__":
    app.run(debug=True)
```
```html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>My Document</title>
</head>
<body>
    <h2>You are on the incorrect page.</h2>
    <a href="{{ url_for("index1", name="ABC") }}">Go back</a>
</body>
</html>
```
  1. question figure
    text
    For the endpoint '/XYZ', the browser will show 'Not Found' error.
  2. question figure
    text
    On clicking the link "Go back" in "index.html", the browser will render:
    
    Hi ABC! This is your home page.
  3. question figure
    text
    For the endpoint '/first_index/XYZ', the browser will redirect to the URL for the function index3, i.e., '/second_index'.
  4. question figure
    text
    For the endpoint '/first_index/ABC', the browser will redirect to the URL for the
    function 'index3' i.e., '/second_index'.
Q3MCQ3 marks
A flask application is given below. question figure A flask application is given below. If the above flask application is running locally on the URL ‘http://127.0.0.1:5000’, which of the following statement is true about the above flask application?
Text of the picture (copyable)
```python
from flask import Flask, jsonify

app = Flask(__name__)

Gadgets = [
    {"tech":"Smartwatch, Digital camera"},
    {"mobile":"Headphones, Speakers"},
    {"Laptop":"Keyboard, Mouse"}
]

@app.route("/home", methods=["GET"])
def func1():
    return jsonify({"The list of gadgets": Gadgets})

@app.route("/")
def rest_lists():
    return {
        "Restaurant 1" : "Hotel Alpine",
        "Restaurant 2" : "Maurya Vihar",
        "Restaurant 3" : "Royal Garden"
    }

if __name__ == "__main__":
    app.run(debug=True)
```
  1. question figure
    text
    For the endpoint "/", The content type of the response is 'application/json'
  2. question figure
    text
    For the endpoint '/home', the application returns:
    ```json
    "The list of gadgets":
    {
        "tech":"Smartwatch, Digital camera",
        "mobile":"Headphones, Speakers",
        "Laptop":"Keyboard, Mouse"
    }
    ```
  3. question figure
    text
    None of the endpoints, i.e., '/' or '/home' can be considered as access URIs of an API.
  4. question figure
    text
    For the endpoint '/home', the application returns:
    ```
    "The list of gadgets":
    {
        "tech": "Smartwatch, Digital camera"
    },
    {
        "mobile": "Headphones, Speakers"
    },
    {
        "Laptop": "Keyboard, Mouse"
    }
    ```
Q4MCQ3 marks
Consider the table “production” in SQLite database given below: question figure Consider the table “production” in SQLite database given below:
Text of the picture (copyable)
| Manufacturer | Product | Quantity | Cost |
|---|---|---|---|
| Industry A | Biscuits | 3 | 100 |
| Industry B | Shoes | 2 | 500 |
| Industry A | Chocolate | 10 | 200 |
| Industry C | Pen | 20 | 50 |
| Industry B | Shirts | 5 | 700 |
| Industry D | Beverages | 30 | 150 |
| Industry C | Notebook | 40 | 250 |

What will be the output of the SQL query given below?

```sql
SELECT Manufacturer, COUNT(*)
FROM production
WHERE Quantity>10
GROUP BY Manufacturer
HAVING COUNT(*)=2;
```
  1. question figure
    text
    ```
    | Manufacturer | COUNT(*) |
    |---|---|
    | Industry D | 1 |
    ```
  2. question figure
    text
    ```
    Manufacturer|COUNT(*)
    Industry C  |2
    ```
  3. question figure
    text
    ```
    Manufacturer|COUNT(*)
    Industry C  |2
    Industry D  |1
    ```
  4. question figure
    text
    ```
    Manufacturer|COUNT(*)
    Industry C  |1
    Industry D  |2
    ```
Q5MCQ3 marks
Consider the table “employee” given below. The model class “Employee” corresponds to table “employee” in the database. question figure Consider the table “employee” given below. The model class “Employee” corresponds to table “employee” in the database.
Text of the picture (copyable)
| id | first_name | last_name | email |
|---|---|---|---|
| 1 | Ruhil | Verma | verma@gmail.com |
| 2 | Monica | gulati | manisha@gmail.com |
| 3 | Sandeep | Sharma | sharma@gmail.com |
| 4 | Taapsi | Uma | uma@gmail.com |

What will be the output of the flask_sqlalchemy command given below?

```python
>>> user1= Employee.query.filter_by(first_name="Monica").first()
>>> user1.first_name= "Manisha"
>>> db.session.commit()
>>> emp = Employee.query.all()
>>> for emp1 in emp:
...print(first_name)
```
  1. question figure
    text
    Ruhil
    Monica
    Sandeep
    Taapsi
  2. question figure
    text
    Ruhil
    Sandeep
    Taapsi
  3. question figure
    text
    Ruhil
    Manisha
    Sandeep
    Taapsi
  4. question figure
    text
    None of these
Q6MCQ3 marks
Which of the following is the correct Python object representation of the given SQL query with declarative_base() class. question figure Which of the following is the correct Python object representation of the given SQL query with declarative_base() class.
Text of the picture (copyable)
```sql
CREATE TABLE "Items" (
  "ID" INTEGER,
  "name" TEXT,
  "cost" INTEGER,
  PRIMARY KEY("ID" AUTOINCREMENT)
)
```
  1. question figure
    text
    ```python
    Base = declarative_base()
    class User(Base):
        __tablename__ = "User"
        ID = Column(Integer, primary_key = True, autoincrement = True)
        name = Column(String)
        cost = Column(Integer)
    ```
  2. question figure
    text
    ```python
    Base = declarative_base()
    class Items(Base):
        __tablename__ = "Items"
        ID = Column(Integer, primary_key = True, autoincrement = True)
        name = Column(String)
        cost = Column(Integer)
    ```
  3. question figure
    text
    ```python
    Base = declarative_base()
    class Items(Base):
        __tablename__ = "Items"
        Item_ID = Column(Integer, primary_key = True, autoincrement = True)
        Item_name = Column(String)
        Item_cost = Column(Integer)
    ```
  4. question figure
    text
    ```python
    Base = declarative_base()
    class Items(Base):
        __tablename__ = "Items"
        cost = Column(Integer, primary_key = True, autoincrement = True)
        name = Column(String)
        ID = Column(Integer)
    ```
Q7MCQ3 marks
If the below flask application is running locally on the URL: ‘http://127.0.0.1:5000’, what will be rendered by the browser? Python file: main.py question figure If the below flask application is running locally on the URL: ‘http://127.0.0.1:5000’, what will be rendered by the browser? Python file: main.py Template: index.html question figure If the below flask application is running locally on the URL: ‘http://127.0.0.1:5000’, what will be rendered by the browser? Python file: main.py Template: index.html
Text of the picture (copyable)
```python
from flask import Flask, render_template
app=Flask(__name__)

@app.route('/')
def home():
    my_course = ['App1', 'App2', 'python', 'Data science',
                 'Database', 'machine learning']

    return render_template('index.html', list=my_course)

if __name__ == '__main__':
    app.run(debug=True)
```
```html
<html>
<head>
    <title>template file</title>
</head>
<body>
    {% macro display(list) %}
        {% for course in list %}
            <p>{{ course }}</p>
        {% endfor %}
    {% endmacro %}
    {{ display(list) }}
</body>
</html>
```
  1. question figure
    text
    ```
    ['App1',
    'App2',
    'python',
    'Data science',
    'Database',
    'machine learning']
    ```
  2. question figure
    text
    ```
    ['App1', 'App2', 'python', 'Data science', 'Database',
    'machine learning']
    ```
  3. question figure
    text
    App1
    App2
    python
    Data science
    Database
    machine learning
  4. question figure
    text
    App1 App2 python Data science Database machine learning
Q8MCQ3 marks
Consider the following table “table_A” in SQLite database. question figure Consider the following table “table_A” in SQLite database.
Text of the picture (copyable)
| | ID | First_Name | Last_Name | Course |
|---|---|---|---|---|
| | Filter | Filter | Filter | Filter |
| 1 | 1 | Raj | R | Java |
| 2 | 2 | Riya | Z | Java |
| 3 | 3 | Sam | sundar | Java |
| 4 | 4 | praneeth | k | Java |
| 5 | 5 | Kunal | T | Python |
| 6 | 6 | vimal | singh | Python |
| 7 | 7 | sethu | J | Python |
| 8 | 8 | liza | G | C++ |
| 9 | 9 | shylla | chopra | C++ |

What will be the output of the following SQL query?

```sql
SELECT Course, count(ID) AS No_Of_Students
FROM table_A GROUP BY Course
ORDER BY No_Of_Students ASC;
```
  1. question figure
    text
    | | Course | No_Of_Students |
    |---|---|---|
    | 1 | Python | 1 |
    | 2 | Java | 1 |
    | 3 | Java | 1 |
    | 4 | Java | 1 |
    | 5 | C++ | 1 |
    | 6 | Java | 1 |
    | 7 | Python | 1 |
    | 8 | C++ | 1 |
    | 9 | Python | 1 |
  2. question figure
    text
    ```
    |   | Course | No_Of_Students |
    |---|--------|----------------|
    | 1 | Python | 1              |
    | 2 | C++    | 1              |
    | 3 | Python | 1              |
    | 4 | Java   | 1              |
    | 5 | C++    | 1              |
    | 6 | Java   | 1              |
    | 7 | Java   | 1              |
    | 8 | Java   | 1              |
    | 9 | Python | 1              |
    ```
  3. question figure
    text
    | | Course | No_Of_Students |
    |---|---|---|
    | 1 | Java | 4 |
    | 2 | Python | 3 |
    | 3 | C++ | 2 |
  4. question figure
    text
    | | Course | No_Of_Students |
    |---|---|---|
    | 1 | C++ | 2 |
    | 2 | Python | 3 |
    | 3 | Java | 4 |
Q9MCQ3 marks
Consider the following HTML file with embedded JavaScript. Filename: index.html question figure Consider the following HTML file with embedded JavaScript. Filename: index.html How will the browser render the above HTML file?
Text of the picture (copyable)
```html
<!DOCTYPE html>
<html>
<body>

<h2>Creating a Json Object </h2>
<p id="jsonobj"></p>

<script>
const txt = '{"name":"icecream","type":"cup",
"flavor":"vanilla"}'

const obj = JSON.parse(txt);
document.getElementById("jsonobj").innerHTML = obj.name + ", "
+ obj.flavor + ", " + obj.type;
</script>

</body>
</html>
```
  1. question figure
    text
    Creating a Json Object
    undefined, undefined, undefined
  2. question figure
    text
    Creating a Json Object
    
    vanilla, icecream, cup
  3. question figure
    text
    Creating a Json Object
    
    cup, vanilla, icecream
  4. question figure
    text
    Creating a Json Object
    icecream, vanilla, cup
Q10MCQ2 marks
Consider the statements given below. Statement 1: APIs usually contain SDKs, but SDKs do not contain APIs. Statement 2: The SDKs contains the group of tools that help developers to use a different product or services. Which of the following is correct in the context of statements given above?
  1. Both statement 1 and 2 are correct.
  2. Statement 1 is correct, 2 is incorrect.
  3. Both statement 1 and 2 are incorrect.
  4. Statement 1 is incorrect, 2 is correct.
Q11MCQ2 marks
Consider a situation, where a developer wants to create his own customized application and wants to deploy it for the end users. For that, he wants a development environment that consists of some programming language execution environment, an operating system, a web server and a database, such that he can build, compile and run his programs without worrying about the servers, storage, and networking. Which of the following service models he would prefer in order to do so?
  1. SaaS
  2. PaaS
  3. IaaS
  4. None of these
Q12MCQ2 marks
Consider the following table ‘flowers’ in SQLite database. question figure Consider the following table ‘flowers’ in SQLite database.
Text of the picture (copyable)
Here's the transcription of the visible text:

| ID ▼1 | Name | color |
|---|---|---|
| Filter | Filter | Filter |
| 1 | Jasmine | white |
| 2 | Rose | pink |
| 3 | Lily | pink |
| 4 | Lotus | pink |
| 5 | Red rose | red |

What will be the output of the following SQL query?

```sql
Select count(ID), Name, color from flowers
group by color HAVING count(color)<2;
```
  1. question figure
    text
    | count(ID) | Name | color |
    |---|---|---|
    | 3 | Rose | pink |
  2. question figure
    text
    | count(ID) | Name      | color |
    | :-------- | :-------- | :---- |
    | 1         | red rose  | red   |
    | 1         | Jasmine   | white |
  3. question figure
    text
    | count(ID) | Name      | color |
    | :-------- | :-------- | :---- |
    | 3         | Rose      | pink  |
    | 1         | red rose  | red   |
    | 1         | Jasmine   | white |
  4. question figure
    text
    | count(ID) | Name      | color |
    | :-------- | :-------- | :---- |
    | 1         | Red rose  | red   |
    | 1         | Jasmine   | white |
Q13MCQ2 marks
Match the following based on the memory hierarchy of computer. question figure Match the following based on the memory hierarchy of computer.
Text of the picture (copyable)
| Parameters          | Storage element |
| :------------------ | :-------------- |
| 1. Highest Latency  | a. HDD          |
| 2. Lowest Density   | b. Register     |
| 3. Lowest Throughput| c. DRAM         |
|                     | d. SSD          |
|                     | e. SRAM         |
  1. 1 - e, 2 - b, 3 - d
  2. 1 - a, 2 - b, 3 - c
  3. 1 - a, 2 - b, 3 - a
  4. 1 - b, 2 - c, 3 - d
Q14MCQ4.5 marks
Consider the HTML document given below: question figure Consider the HTML document given below: Which of the following statements is true for the above HTML document when rendered by the browser?
Text of the picture (copyable)
```html
<!DOCTYPE html>
<html>
<head>
    <style>
        [id~=out] {
            border: 10px solid red;
        }

        [class~=out]{
            border: 5px solid yellow;
        }
    </style>
</head>
<body>
    <h2>Hello World!</h2>
    <h1 id="out">Hey!</h1>
    <p id="out-text">My name is Fred.</p>
    <p class="outcontent">I am learning to develop
applications.</p>
    <p id ="out"> Are you also willing to learn?</p>
    <p class="out">Welcome to the world of Application
development!</p>
    <h3>Have a nice day!!</h3>
</body>
</html>
```
  1. The headings, i.e., ‘Hello World!’ and ‘Hey!’, both will have red border color.
  2. The paragraph with class=‘out’, will get a yellow color border.
  3. The paragraph with id=‘out’ will get a yellow color border.
  4. The two paragraphs with contents, ‘My name is Fred.’ and ‘I am learning todevelop applications.’, will both get a red color border and yellow color border.
Q15MCQ4.5 marks
Consider the following PyHTML program. Identify the corresponding HTML file which will be generated on running the PyHTML code. question figure Consider the following PyHTML program. Identify the corresponding HTML file which will be generated on running the PyHTML code.
Text of the picture (copyable)
```python
from pyhtml import *

my_html = html(head(title("Quiz 2")),
               body(h2("Second level heading"),
                    div("This is my first div"),
                    p("Paragraph1"),
                    p("Paragraph2")
                    )
               )

output = my_html.render()
print(output)
```
  1. question figure
    text
    ```html
    <!DOCTYPE html>
    <html>
    <head>
        <title>Quiz 2</title>
    </head>
    <body>
        <h2>Second level heading</h2>
        <div>This is my first div</div>
        <p>Paragraph1</p>
        <p>Paragraph2</p>
    </body>
    </html>
    ```
  2. question figure
    text
    ```html
    <!DOCTYPE html>
    <html>
    <head>
        <h2>Second level heading</h2>
    </head>
    <body>
        <title>Quiz 2</title>
        <div>This is my first div</div>
        <p>Paragraph1</p>
        <p>Paragraph2</p>
    </body>
    </html>
    ```
  3. question figure
    text
    ```html
    <!DOCTYPE html>
    <html>
    <head>
        <title>Quiz 2</title>
        <div>This is my first div</div>
    </head>
    <body>
        <h2>Second level heading</h2>
        <p>Paragraph1</p>
        <p>Paragraph2</p>
    </body>
    </html>
    ```
  4. question figure
    text
    ```html
    <!DOCTYPE html>
    <html>
    <head>
        <title>Quiz 2</title>
    </head>
    <body>
        <h2>Second level heading</h2>
        <div>This is my first div
            <p>Paragraph1</p>
            <p>Paragraph2</p>
        </div>
    </body>
    </html>
    ```
Q16MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider two software packages A and B. The average processing time of the package A is
TA(n) = 0.001n milliseconds and the average processing time of the package B is TB(n) = 500√n
milliseconds, where n is the number of records being processed. Which of the given software
packages A and B should be chosen to process data collections, containing 10⁸ records?
  1. Package A
  2. Package B
  3. Both A and B will take same time
  4. Both A and B will infinite time to process records
Q17MCQ4.5 marks
Consider the following Python code snippet: question figure Consider the following Python code snippet:
Text of the picture (copyable)
```python
from flask import Flask
from flask_restful import Resource, Api, reqparse, fields, \
    marshal_with

app = Flask('__main__')
api = Api(app)

parser = reqparse.RequestParser()
parser.add_argument("Id")
parser.add_argument("name")
parser.add_argument("email")

out_fields = {
    "Id": fields.Integer,
    "name": fields.String
}

class MyApi(Resource):
    def get(self):
        info = parser.parse_args()
        return {"Identity": info['Id'] , "Name": info['name'], \
"E-mail": info['email']}

    @marshal_with(out_fields)
    def post(self):
        info = parser.parse_args()
        return info

api.add_resource(MyApi, '/myinfo')

app.run(debug = True)
```
If the application is running locally on the URL: "http://127.0.0.1:5000", What will be the output on the terminal for command:

```bash
curl -X POST -H "Content-Type: application/json" \
    -d "{\"Id\":3, \"name\":\"user_1\", \"email\": \
\"user_1@gmail.com\"}" http://127.0.0.1:5000/myinfo
```
  1. question figure
    text
    ```json
    {
      "Identity": "3",
      "Name": "user_1",
      "E-mail": "user_1@gmail.com"
    }
    ```
  2. question figure
    text
    ```json
    {
      "Id": 3,
      "name": "user_1"
    }
    ```
  3. question figure
    text
    ```json
    {
      "Id": "3",
      "name": "user_1"
    }
    ```
  4. question figure
    text
    ```json
    {
      "name": "user_1",
      "email": "user_1@gmail.com"
    }
    ```

Answer key

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