MAD Study Hub

Home / Past papers / MAD1 End Term / this paper

IIT M FOUNDATION DIPLOMA FN EXAM - 01 Sep 2024

MAD1 End Term32 questions100 marks23 MCQ · 9 MSQFoundation / Diploma / forenoon
Elapsed 00:00
Q1MCQ3 marks
Consider the following Python code snippet. question figure Consider the following Python code snippet.
Text of the picture (copyable)
file.py
```python
from jinja2 import Template
import sys
input_list = sys.argv
var_a, var_b = input_list[1], input_list[2]

if input_list[1]=="Meera":
    var_b = "Data Analyst"
elif input_list[1]=="Radha":
    var_b = "Scientist"
else:
    pass
template = "{{{var_a}}} is {{{var_b}}}"
t = Template(template)
print(t.render(var_a = var_a, var_b = var_b))
```

Map the commands in column A with the output on the terminal in column B.

| Column A                               | Column B                  |
| :------------------------------------- | :------------------------ |
| a) python file.py Radha Data Analyst   | 1) Meera is Scientist     |
| b) python file.py Meera Scientist      | 2) Sneha is Web           |
| c) python file.py Sneha Web Developer  | 3) Meera is Data Analyst  |
|                                        | 4) Radha is Data Analyst  |
|                                        | 5) Radha is Scientist     |
|                                        | 6) Sneha is Web developer |
  1. a - 4, b - 1, c - 6
  2. a - 5, b - 3, c - 6
  3. a - 5, b - 1, c - 2
  4. a - 5, b - 3, c - 2
Q2MCQ3 marks
Consider the following HTML document. question figure Consider the following HTML document.
Text of the picture (copyable)
```html
<!DOCTYPE html>
<html>
<head>
    <style>
        span {
            background-color: yellow;
            color: red;
        }
        #id {
            border: 2px solid purple;
            color:blue ;
            display: inline-block;
        }
        .class {
            background-color: aqua;
            color: red;
            display: block;
            width:20%;
        }
    </style>
</head>
<body>
    <span class="class" id="id">SPAN</span>
    <span class="class" >SPAN</span>
    <span>SPAN</span>
</body>
</html>
```
How will the browser render above HTML file?
  1. question figure
    text
    The image displays three rectangular boxes arranged horizontally.
    
    1.  The first box is wide, filled with a bright cyan color, and has a dark purple border. Inside, the word "SPAN" is written in blue text.
    2.  The second box is narrower, filled with a bright cyan color, and has no visible border. Inside, the word "SPAN" is written in red text.
    3.  The third box is also narrower, filled with a bright yellow color, and has no visible border. Inside, the word "SPAN" is written in orange text.
  2. question figure
    text
    The image displays three rectangular blocks, each containing the text "SPAN".
    1. The first block has a cyan background with a purple border. The text "SPAN" is dark blue.
    2. The second block has a cyan background with no visible border. The text "SPAN" is red with a slight shadow effect.
    3. The third block has a yellow background with no visible border. The text "SPAN" is orange.
  3. question figure
    text
    The image displays three horizontal rectangular blocks stacked vertically.
    The top block has a cyan background with the word "SPAN" in blue text. It has a purple border around it.
    The middle block has a cyan background with the word "SPAN" in red text.
    The bottom block has a yellow background with the word "SPAN" in orange text.
  4. question figure
    text
    The image displays three horizontal rectangular blocks, stacked vertically.
    1. The top block has a light blue background with a purple border. Inside, the word "SPAN" is written in blue text.
    2. The middle block has a light blue background. Inside, the word "SPAN" is written in red text.
    3. The bottom block has a yellow background. Inside, the word "SPAN" is written in orange text.
Q3MCQ3 marks
Consider the following flask application. question figure Consider the following flask application.
Text of the picture (copyable)
app.py
```python
from flask import Flask, request
app = Flask(__name__)
@app.route('/calculate')
def calculate():
    a = request.args.get('a')
    b = request.args.get('b')
    operator = request.args.get('operator')
    if a and b and operator:
        if operator == 'one':
            return f'{a} + {b} = {int(a)+int(b)}'
        elif operator == 'two':
            return f'{a} - {b} = {int(a) - int(b)}'
        elif operator == 'three':
            return f'{a} x {b} = {int(a)*int(b)}'
    else:
        return 'Error: Insufficient arguments'
app.run(debug=True)
```

If the application is running locally on http://127.0.0.1:5000 then match the URLs with their rendered output?

| | URLs | | Output |
|---|---|---|---|
| 1 | http://localhost:5000/calculate?a=4&b=2&operator=two | a | 4 x 2 = 8 |
| 2 | http://localhost:5000/calculate?a=4&b=2&operator=three | b | 4 + 2 = 6 |
| 3 | http://localhost:5000/calculate?a=4&b=2&operator=one | c | 4 - 2 = 2 |
| | | d | 4 + 2 = 42 |
| | | e | 4 x 2 = 2222 |
  1. 1-c, 2-a, 3-b
  2. 1-c, 2-a, 3-d
  3. 1-c, 2-e, 3-d
  4. 1-c, 2-a, 3-e
Q4MCQ3 marks
question figure
Text of the picture (copyable)
Which of the following flask view functions will return a 200 OK for the URL:
http://127.0.0.1:5000/details/1001/Michael ?
  1. question figure
    text
    ```python
    @app.route('/details/<int:id>/<string:name>')
    def show(id, name):
        details = {'student_id': id, 'student_name': name}
        return details
    ```
  2. question figure
    text
    ```python
    @app.route('/details/<string:id>/<string:name>')
    def show(id, name):
        details = {'student_id': id, 'student_name': name}
        return details
    ```
  3. question figure
    text
    ```python
    @app.route('/details/<id>/<name>')
    def show(id, name):
        details = {'student_id': id, 'student_name': name}
        return details
    ```
  4. question figure
    text
    All of these
Q5MCQ3 marks
question figure
Text of the picture (copyable)
Consider a function func, and a set of test cases given below.
Filename: test_file.py

```python
import pytest
def func(x,y):
    out = x**2+y**2
    return out

class Test_class0():
    def test_case1(self):
        assert func(1,2) == 5

    def case_test2(self):
        assert func(2,3) == 13

    def case_test3(self):
        assert func(6,2) == 38

class Test_class1():
    def test_case1(self):
        assert func(5,2) == 29

    def case_test2(self):
        assert func(1,1) == 2
```

What will be the output on the terminal for the command below?
pytest test_file.py -k Test_class
  1. question figure
    text
    ```
    == 1 failed, 4 passed in 0.17s ===
    ```
  2. question figure
    text
    ```
    == 2 passed, 3 deselected in 0.17s ===
    ```
  3. question figure
    text
    ```text
    == 2 passed in 0.07s ===
    ```
  4. question figure
    text
    ```
    == 3 failed, 2 passed in 0.17s ===
    ```
Q6MCQ3 marks
The lens of an HDD can read data on the rotating disk with the speed of 42,000 bits per second. The disk is designed such that 600 bits pass under the lens for every revolution of the disk, what should be the maximum speed of disk in RPM so that the lens does not miss any data?
  1. 70 RPM
  2. 100 RPM
  3. 4200 RPM
  4. 6000 RPM
Q7MCQ3 marks
question figure
Text of the picture (copyable)
Consider the below two python files code snippets *app.py* and *test_app_route.py*.

**app.py**
```python
from flask import Flask
app = Flask(__name__)

@app.route("/greet/<string:name>")
def home(name):
    return "Hello, " + name

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

**test_app_route.py:**
```python
import pytest, requests

@pytest.fixture
def get_response():
    resp = requests.get("http://127.0.0.1:5000/greet/IITM")
    return resp

def test_response(get_response):
    assert get_response.text == "Hello, IITM"
```

Assume that *app.py* and *test_app_route.py* are running on two different terminals. And also all required modules are installed. Which of the below statement(s) are True?

i) Executing the command `pytest test_app_route.py` on the terminal returns
`========== 1 passed ==========`

ii) Executing the command `pytest test_app_route.py` on the terminal returns
`========== 1 failed ==========`

iii) Executing the command `pytest test_app_route.py` on the terminal returns
`========== 1 selected, 1 passed ==========`

iv) Executing the command `pytest test_app_route.py` on the terminal returns
`========== 1 deselected ==========`
  1. Only statement i is correct
  2. Only statement ii is correct
  3. Statements i and iii are correct
  4. Statements ii and iv are correct
Q8MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following flask resource created using flask_restful.

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

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

parser = reqparse.RequestParser()
parser.add_argument("val")

class RestApi(Resource):
    def post(self, val):
        arg1 = parser.parse_args()
        arg2 = request.args
        return {
            "Course_1": arg1["val"],
            "Course_2": arg2["val"],
            "Course_3": val
        }

api.add_resource(RestApi, "/api/courses/<val>")
app.run(debug = True)
```

If the application is running locally on http://127.0.0.1:5000, What will be the output on the terminal for the command:

```bash
curl http://127.0.0.1:5000/api/courses/DBMS?val=JAVA -d "{\"val\":\"PDSA\"}" -X POST -H "Content-Type: application/json"
```
  1. question figure
    text
    ```json
    {
        "Course_1": "JAVA",
        "Course_2": "PDSA",
        "Course_3": "DBMS"
    }
    ```
  2. question figure
    text
    ```json
    {
        "Course_1": "DBMS",
        "Course_2": "JAVA",
        "Course_3": "PDSA"
    }
    ```
  3. question figure
    text
    ```json
    {
      "Course_1": "PDSA",
      "Course_2": "JAVA",
      "Course_3": "DBMS"
    }
    ```
  4. question figure
    text
    ```json
    {
        "Course_1": "PDSA",
        "Course_2": "DBMS",
        "Course_3": "JAVA"
    }
    ```
Q9MCQ3 marks
question figure question figure
Text of the picture (copyable)
A flask application shown below is running locally on http://127.0.0.1:5000.

```python
from flask import Flask, request, session, abort

app = Flask(__name__)
app.config['SECRET_KEY'] = "yekterces"

@app.route('/login')
def log_in():
    user = request.args['user']
    role = request.args['role'] if 'role' in request.args else \
           'general'
    session['user'], session['role'] = user, role
    return "Logged in successfully!"

@app.route('/home')
def land():
    if 'user' in session:
        if session['role'] == 'admin':
            return f"Welcome {session['user']}"
        return abort(401)
    return abort(404)

@app.route('/logout')
def log_out():
    session.pop('user', None)
    session.pop('role', None)
    return "Logged out sucessfully!"

app.run(debug=True)
```

If the application is running locally on http://127.0.0.1:5000. What will be the correct sequence of response status codes if the client visits the URLs one by one in the sequence given below?
1. http://127.0.0.1:5000/home
2. http://127.0.0.1:5000/login/admin
3. http://127.0.0.1:5000/login?user=admin
4. http://127.0.0.1:5000/home
5. http://127.0.0.1:5000/logout
  1. question figure
    text
    401
    401
    200
    404
    200
  2. question figure
    text
    404
    200
    200
    200
    200
  3. question figure
    text
    404
    404
    200
    401
    200
  4. question figure
    text
    404
    200
    404
    200
    200
Q10MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following flask application.

Python file: app.py

```python
from flask import Flask, render_template, request

app = Flask(__name__)

emp = {'admin':'manoj', 'user':'sumit'}

@app.route('/profile/<user>')
def profile(user):
    access = request.args.get('access')
    if emp[access] != user:
        return render_template("profile.html", user = user,
                               access = access, error = True)
    return render_template("profile.html", user = user,
                           access = access, error = False)

app.run()
```

Template file: profile.html

```html
<body>
    <div>
        {% if error %}
            <h3>Hi {{user}}, {{access}} access denied</h3>
        {% else %}
            <h3>Hi {{user}}, you are logged in as {{access}}.</h3>
        {% endif %}
    </div>
</body>
```

If the application is running locally on http://127.0.0.1:5000, then what will be rendered by the browser for URL,
http://127.0.0.1:5000/profile/sumit?access=admin ?
  1. question figure
    text
    Hi sumit, you are logged in as admin.
  2. question figure
    text
    Hi sumit, you are logged in as user.
  3. question figure
    text
    Hi sumit, admin access denied.
  4. question figure
    text
    Hi sumit, user access denied.
Q11MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following models Library and Book corresponding to tables
library and book in SQLite database.

```python
class Library(db.Model):
    id = db.Column(db.Integer(), primary_key = True)
    name = db.Column(db.String(), unique = True)

class Book(db.Model):
    id = db.Column(db.Integer(), primary_key = True)
    name = db.Column(db.String(), unique = True)
    library = db.Column(db.Integer(), db.ForeignKey("library.id"))
```

Based on the model schemas, what relationship do the classes Library and Book
share?
  1. Many-to-Many
  2. One-to-Many
  3. One-to-One
  4. The tables are not at all related
Q12MCQ3 marks
Read the statements given below carefully and select the correct option. Statement 1:If an element having an ID and a class is styled externally using both its ID and the class, then for the same attribute, it will acquire styling from the latest selector in order. Statement 2: If an element that belongs to two different classes is styled externally using both the classes, then for the same attribute, it will acquire styling from the latest class in order.
  1. Both statements 1 and 2 are correct
  2. Both statements 1 and 2 are incorrect
  3. Statement 1 is correct but statement 2 is incorrect
  4. Statement 2 is correct but statement 1 is incorrect
Q13MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following Python code snippet.
log.py

```python
import logging
import sys

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

def check_val(value):
    if value < 0:
        raise ValueError("Invalid value: Please enter a positive value.")
    else:
        logging.info("Value added: %s", value)

try:
    input_value = -int(sys.argv[1])
    check_val(input_value)
except ValueError as ve:
    logging.exception("Exception occurred: %s", str(ve))
```

What will be the output on the terminal for the command: `python log.py -12`?
  1. question figure
    text
    2023-08-14 21:01:05,684 - INFO - Value added: 12
  2. question figure
    text
    2023-08-14 21:01:05,684 - WARNING - Value added: -12
  3. question figure
    text
    Error: Exception occurred: Invalid value: Please enter a positive value.
  4. question figure
    text
    None of these
Q14MCQ4.5 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 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?
Text of the picture (copyable)
This is a line graph titled "Megabits/s" on the y-axis.

The x-axis is labeled "Time (Hours)" and ranges from 0 to 24, with major ticks at 0, 4, 8, 12, 14, 16, 20, and 24.
The y-axis is labeled "BandWidth" and ranges from 0 to 12, with major ticks at 0, 2, 4, 6, 8, 10, and 12.

There is an orange step-function line representing bandwidth over time.
- From Time 0 to 4, BandWidth is 8.
- From Time 4 to 8, BandWidth is 10.
- From Time 8 to 12, BandWidth is 6.
- From Time 12 to 14, BandWidth is 8.
- From Time 14 to 16, BandWidth is 2.
- From Time 16 to 20, BandWidth is 2.
- From Time 20 to 24, BandWidth is 10.

There are three horizontal colored lines above the main graph, each labeled with a user. These lines indicate time intervals.
- A blue line labeled "user 1" extends from Time 0 to Time 4.
- A yellow line labeled "user 2" extends from Time 8 to Time 14.
- A green line labeled "user 3" extends from Time 16 to Time 24.
  1. 633.6 GB
  2. 54 GB
  3. 120 GB
  4. 432 GB
Q15MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the below flask application.

```python
from flask_sqlalchemy import SQLAlchemy
from flask import Flask

app = Flask (__name__)
app.config ['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///testdb.sqlite3'
db = SQLAlchemy(app)
app.app_context().push()

class Material(db.Model):
    m_id = db.Column('m_id', db.Integer, primary_key = True)
    name = db.Column('name', db.String(100), unique = True)

db.create_all()
material1 = Material(name = 'Steel')
db.session.add(material1)
material2 = Material(name = 'Iron')
material3 = Material(name = 'Aluminium')
db.session.add(material2)
db.session.commit()
db.session.add(material3)

all_material = Material.query.all()
print([(x.m_id, x.name) for x in all_material])
```

If you run the flask application using a terminal. What will be the output in the terminal?
  1. question figure
    text
    ```
    [(1, 'Steel'), (2, 'Iron')] will be displayed in the terminal and two records will be added in the "testdb" database.
    ```
  2. question figure
    text
    ```
    [(1, 'Steel'), (2, 'Iron'), (3, 'Aluminium')] will be displayed in the terminal
    and three records will be added in the "testdb" database.
    ```
  3. question figure
    text
    ```
    [(1, 'Steel'), (2, 'Iron'), (3, 'Aluminium')] will be displayed in the terminal
    and two records will be added in the "testdb" database.
    ```
  4. question figure
    text
    ```
    [(1, 'Steel', 2, 'Iron', 3, 'Aluminium')] will be displayed in the terminal and
    two records will be added in the "testdb" database.
    ```
Q16MCQ4.5 marks
question figure
Text of the picture (copyable)
A client machine C is 18000 kms away from the server machine S. A router R is
situated somewhere in between the client C and the server S and is connected to client
C with cable and makes aerial connection with the server S. What will be the round-trip
latency (milliseconds) of the network if the router is placed at exactly midway from the
client and the server? [Assume: The speed of light on cable is 1.5 x 10⁸ m/s and in air
is 3 x 10⁸ m/s. The client, server and the router lie on a straight line]
  1. 45
  2. 90
  3. 180
  4. 270
Q17MCQ2 marks
Consider the following flask app and Jinja2 template. question figure Consider the following flask app and Jinja2 template.
Text of the picture (copyable)
app.py
```python
from flask import Flask, render_template
app = Flask(__name__)

@app.route('/')
def index():
    return render_template("index.html", data=['Harry', 'Karl', 'John',
                                                'Jason', 'Ros'])

app.run()
```

index.html
```html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Macro</title>
</head>
<body>
    {% macro unordered_list(items)%}
    <ul>
        {% for item in items %}
            {% if item|length >= 5 %}
                <li>{{item}}</li>
            {% endif %}
        {% endfor %}
    </ul>
    {% endmacro %}
    {{ unordered_list(data) }}
</body>
</html>
```

If the flask app is running locally on http://127.0.0.1:5000. What will be the output on the browser for the base URL?
  1. question figure
    text
    - Harry
    - Karl
    - John
    - Jason
    - Ros
  2. question figure
    text
    - Karl
    - John
  3. question figure
    text
    - Harry
    - Jason
  4. question figure
    text
    - Karl
    - John
    - Ros
Q18MCQ2 marks
question figure
Text of the picture (copyable)
Match the following types of testing with their functionality.

| | |
|---|---|
| A. Regression testing | 1. Beta Testing |
| B. User Acceptance testing | 2. one step beyond integration testing, includes server and environment |
| C. System Testing | 3. Simulates actual user interaction, allows to script browser |
| D. System testing Automation | 4. Type of testing that runs after every change to ensure that the change introduces no unintended breaks. |

Which of the following is the correct matching?
  1. A → 1, B → 2, C → 3, D → 4
  2. A → 4, B → 3, C → 2, D → 1
  3. A → 4, B → 1, C → 2, D → 3
  4. A → 3, B → 2, C → 1, D → 4
Q19MCQ2 marks
question figure
Text of the picture (copyable)
Consider the following python code snippet app.py, the HTML files, base.html and home.html residing in "templates" folder.

app.py

```python
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def home():
    return render_template('home.html')
app.run(debug=True)
```

home.html

```html
{% extends "base.html" %}
{% block content %}
<p>MAD I</p>
<span>MAD II</span>
<p>DBMS</p>
{% endblock %}
```

base.html

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>IITM</title>
</head>
<body>
    <h2 style="color: violet;"> Diploma Courses </h2>
    {% block content %}
    {% endblock %}
</body>
</html>
```

What will be the rendered output for base URL if flask app is running locally on http://localhost:5000 ?
  1. question figure
    text
    MAD I
    MAD II
    DBMS
  2. question figure
    text
    Diploma Courses
    
    MAD I
    
    MAD II
    
    DBMS
  3. question figure
    text
    Diploma Courses
    MAD I
    MAD II DBMS
  4. question figure
    text
    MAD I
    MAD II DBMS
Q20MCQ2 marks
You have a DRAM module with bus width of 64 bits, clock speed of 2 GHz, and operating in DDR (double-data-rate or two values per clock cycle) mode. What is the maximum bandwidth (in Giga-bytes per second) of data transfer achievable with this module?
  1. 16
  2. 8
  3. 32
  4. 128
Q21MCQ2 marks
question figure
Text of the picture (copyable)
The hexadecimal equivalent of the IPv4 address 172.16.254.10 would be ________.
  1. AC0A FE01
  2. CA10 EF0A
  3. AC01 0AEF
  4. AC10 FE0A
Q22MCQ2 marks
Which of the following is true about the term “stateless” in the client-server model?
  1. The server keeps the state of the client to respond to the required request.
  2. Server use variant HTTP methods to respond to the client's request.
  3. Server ready to respond to the client's request without knowing anythingabout the client.
  4. Server use the URL to convey context to the client.
Q23MSQ2 marksselect all that apply
Consider the following Python code snippet “code.py”. question figure Consider the following Python code snippet “code.py”.
Text of the picture (copyable)
Filename: code.py

```python
import sys
from jinja2 import Template
vars = sys.argv

course_technologies = {'python': 'backend', 'javascript': 'frontend'}
template = Template("This course focuses on {{ technology }} development.")

if len(vars) > 2 and vars[2] in course_technologies:
    course = vars[1]
    technology = course_technologies[course]
    print(template.render(technology=technology))
else:
    print("Please specify a valid course name!")
```

Which of the following will be the correct command line input to the terminal to get the output: This course focuses on backend development. ?
  1. question figure
    text
    python code.py course python
  2. question figure
    text
    python code.py python javascript
  3. question figure
    text
    python code.py python python
  4. question figure
    text
    ```
    python code.py python backend
    ```
Q24MSQ2 marksselect all that apply
Consider the following flask application. question figure Consider the following flask application.
Text of the picture (copyable)
app.py
```python
from flask import Flask, abort, request
app = Flask(__name__)

data = {"CS2001":"DBMS", "CS2003":"MAD-I", "CS2006":"MAD-II"}
@app.route('/login')
def login():
    username = request.args.get('uname')
    if username not in data:
        abort(400, "Bad Request: Invalid Username")
    return f'<h1>Welcome to {data[username]} course!</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?uname=CS2001 the browser will render
    **Welcome to DBMS course!**
  2. question figure
    text
    For URL http://127.0.0.1:5000/login the browser will render
    **Welcome to MAD-I course!**
  3. question figure
    text
    For URL http://127.0.0.1:5000/login?uname the browser will render
    Bad Request: Invalid Username
  4. question figure
    text
    For URL http://127.0.0.1:5000/login?uname=CS2006 the browser will
    render **Welcome to MAD-II course!**
Q25MSQ3 marksselect all that apply
Consider the following flask application. question figure Consider the following flask application.
Text of the picture (copyable)
```python
from flask import Flask, request
app = Flask(__name__)

@app.route('/home')
def home():
    var_a = request.args.get('method')
    if var_a == "GET":
        return "Hello from GET method"

    elif var_a == "POST":
        return "Hello from POST method"

    else:
        return "Invalid Method"

app.run(debug=True)
```

If the application is running locally on http://127.0.0.1:5000 then which of the following statements are correct?
  1. question figure
    text
    The command `curl -X GET http://127.0.0.1:5000/home?method=GET` will give output
    as `Hello from GET method` on terminal
  2. question figure
    text
    The command `curl -X POST http://127.0.0.1:5000/home?method=POST` will give output
    as `Method not Allowed` on terminal
  3. question figure
    text
    The command `curl -X POST http://127.0.0.1:5000/home?method=POST` will give
    output as `Hello from POST method` on terminal
  4. question figure
    text
    The command `curl -X POST http://127.0.0.1:5000/home?method` will give output as
    `Invalid Method` on terminal
Q26MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following flask_sqlalchemy data models "User" and "Role".

```python
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(), unique=True, nullable=False)
    password = db.Column(db.String(), nullable=False)
    email = db.Column(db.String())
    roles = db.relationship("Role", backref="bearer")

class Role(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    r_name = db.Column(db.String(), unique=True, nullable=False)
    user = db.Column(db.Integer, db.ForeignKey("user.id"))
```

python shell:
```python
>>> from app import *
>>> db.create_all()
>>> user1 = User(username="Rakesh",password="1234",email="user1@gmail.com")
>>> user2 = User(username="Suresh",password="123",email="user2@gmail.com")
>>> db.session.add_all([user1,user2])
>>> db.session.commit()
>>> r1=Role(r_name="instructor",user=1)
>>> r2=Role(r_name="admin",user=1)
>>> r3=Role(r_name="ops",user=2)
>>> r4=Role(r_name="student",user=2)
>>> db.session.add_all([r1,r2,r3,r4])
>>> db.session.commit()
>>> users = User.query.all()
>>> roles = Role.query.all()
```

If the above commands are run in the python shell then which of the following options is
/are correct with respect to these models?
  1. question figure
    text
    Command: >>> users
    Output: ["Ramesh", "Suresh"]
  2. question figure
    text
    Command:
    ```
    >>> u1 = users[1]
    >>> u1.roles
    ```
    Output:
    ```
    [<Role 3>, <Role 4>]
    ```
  3. question figure
    text
    Command:
    ```
    >>> roles[2].user
    ```
    Output:
    ```
    ["Suresh"]
    ```
  4. question figure
    text
    Command: >>> roles[3].user
    Output: 2
  5. question figure
    text
    ```
    Command: >>> roles[0].bearer
    Output: <User 1>
    ```
Q27MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
Suppose a request `https://xyz.com?name=amey&age=34` generates the below response on the browser's console,

```
Name : amey
```

The definition of the flask endpoint which handles the above request is given below,

```python
@app.route(code1)
def getData():
    data = code2
    print("Name :", data)
```

Which of the following options should be used to fill the placeholders "code1" and "code2", to achieve the desired result as shown above?
  1. question figure
    text
    ```
    Code1: "/"
    Code2: request.form['name']
    ```
  2. question figure
    text
    ```
    Code1: "/", methods = ['GET']
    Code2: request.form['name']
    ```
  3. question figure
    text
    ```python
    Code1: "/", methods = ['GET', 'POST']
    Code2: request.args['name']
    ```
  4. question figure
    text
    ```
    Code1: "/"
    Code2: request.args.get('name')
    ```
Q28MSQ4.5 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following function to be tested and test functions given in the Python code snippet below.

test_file.py
```python
import pytest

def square(x):
    sum = 0
    for counter in range(x):
        sum += x
    return sum

@pytest.mark.marker1
def testcase_1():
    assert square(10) == 100

@pytest.mark.marker2
def testcase_2():
    assert square(4) == 4

@pytest.mark.marker3
def testcase_3():
    assert square(5) == 25

@pytest.mark.marker4
def testcase_4():
    assert square(6) == 6
```

On running this file on the terminal using pytest, the summary of the output is;

`========= 1 passed, 3 deselected, 4 warnings in 0.04s =========`

What command will result into the outcome given above?
  1. question figure
    text
    ```
    pytest test_file.py -m marker4
    ```
  2. question figure
    text
    ```
    pytest test_file.py -m marker1
    ```
  3. question figure
    text
    ```
    pytest test_file.py -m marker2
    ```
  4. question figure
    text
    ```
    pytest test_file.py -m marker3
    ```
Q29MSQ4.5 marksselect all that apply
Consider the following flask application. question figure Consider the following flask application.
Text of the picture (copyable)
```python
from flask import Flask, abort
app = Flask(__name__)
modules = ['python', 'react', 'node']

@app.route('/home/modules/')
def all_modules():
    return f"<h3>List of modules: {modules}</h3>"

@app.route('/get/<string:module_1>')
def get_module(module_1):
    if module_1 in modules:
        return f"<h3>One module found: {module_1}.</h3>"
    else:
        abort(400)

@app.errorhandler(400)
def module_error(error):
    return "<h3>Cannot find module</h3>"

@app.errorhandler(404)
def module_error(error):
    return "<h3>Incorrect Path</h3>"

app.run(debug=True)
```
If the application is running locally on http://127.0.0.1:5000, select the correct statement(s).
  1. question figure
    text
    For the URL, http://127.0.0.1:5000/home/modules, the browser will render,
    List of modules: ['python', 'react', 'node']
  2. question figure
    text
    For the URL, http://127.0.0.1:5000/home/modules, the browser will render,
    **Incorrect Path**
  3. question figure
    text
    For the URL, http://127.0.0.1:5000/get/vuejs, the browser will render;
    Cannot find module
  4. question figure
    text
    For the URL, http://127.0.0.1:5000/get/react/, the browser will render,
    **One module found: react.**
Q30MSQ4.5 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following code snippet.

```python
@app.route('/student/<student_id>')
def profile(student_id):
    # CODE_BLOCK_HERE
```

Assume the database has a "student" table which has a TEXT column "student_id". If we want the server to return a 404 status code when a user goes to the route '/student/<student_id>' with a student_id that does not exist in the database, which of the following lines would give us the desired output?
  1. question figure
    text
    ```python
    student = Student.query.filter_by(student_id=student_id).first()
    if student is None:
        abort(404)
    return render_template('profile.html', student=student)
    ```
  2. question figure
    text
    ```python
    student = Student.query.filter_by(student_id=student_id).first()
    if student is None:
        return render_template("404.html")
    return render_template('profile.html', student=student)
    ```
  3. question figure
    text
    ```python
    student = Student.query.filter_by(student_id=student_id).first_or_404()
    return render_template('profile.html', student=student)
    ```
  4. question figure
    text
    ```python
    student = Student.query.filter_by(student_id=student_id).first()
    if student is None:
        return render_template("404.html"), 404
    return render_template('profile.html', student=student)
    ```
Comprehension passage - the questions below it refer to this
Based on the above data, answer the given subquestions. question figure
Q31MSQ4.5 marksselect all that apply
question figure
Text of the picture (copyable)
What should be the code to run the
application, and what should be the
URL respectively such that the browser
gives output as: Welcome to Application
Development! ?
  1. question figure
    text
    Code: python app.py Application Development DBMS
    URL: http://127.0.0.1:5000/course?course=Application Development
  2. question figure
    text
    Code: python app.py "Application Development" Java
    URL: http://127.0.0.1:5000/course?course=Application
  3. question figure
    text
    Code:
    ```
    python app.py Application Development DBMS
    ```
    URL:
    ```
    http://127.0.0.1:5000/course?course=Application
    ```
  4. question figure
    text
    Code:
    ```
    python app.py "Application Development" DBMS
    ```
    URL:
    ```
    http://127.0.0.1:5000/course?course=Application Development
    ```
Q32MCQ3 marks
question figure
Text of the picture (copyable)
What will be the output given by
browser if the application is
run with command
```
python app.py Application Development DBMS
```
on terminal with URL:
```
http://127.0.0.1:5000/course?course=Application Development ?
```
  1. question figure
    text
    Welcome to Application Development!
  2. question figure
    text
    Welcome to DBMS!
  3. question figure
    text
    Invalid Data
  4. question figure
    text
    Not Found

Answer key

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

Concepts this paper tests

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

Here’s a structured summary of core topics, concepts, and principles for the "Modern Application Development I" exam, along with key equations (where applicable) and Mermaid knowledge graphs to visualize relationships.



1. Core Topics & Concepts

A. Python & Flask

Key Concepts:

  1. Flask Routing & Request Handling

    • Dynamic routes (<variable>), query parameters (request.args), form data (request.form).
    • HTTP methods (GET, POST, PUT, DELETE).
    • Error handling (abort(404), @app.errorhandler).
    • Example Route:

      @app.route('/user/<username>')
      def show_user(username):
          return f"User: {username}"
  1. Jinja2 Templating

    • Template inheritance ({% extends %}, {% block %}).
    • Conditionals ({% if %}), loops ({% for %}), macros ({% macro %}).
    • Example:

      {% if user %}
          <h1>Welcome, {{ user }}!</h1>
      {% endif %}
  1. Flask-SQLAlchemy (ORM)

    • Model definitions (db.Model), relationships (db.relationship).
    • CRUD operations (db.session.add, db.session.commit).
    • Example Model:

      class User(db.Model):
          id = db.Column(db.Integer, primary_key=True)
          username = db.Column(db.String(80), unique=True)
  1. Flask-RESTful

    • Resource-based routing (api.add_resource).
    • Request parsing (reqparse.RequestParser).
    • Example:

      class UserResource(Resource):
          def get(self, user_id):
              return {"user_id": user_id}
  1. Session Management

    • flask.session, secret keys, login/logout flows.
    • Example:

      app.secret_key = 'secret'
      session['user'] = 'admin'
  1. Testing with pytest

    • Fixtures (@pytest.fixture), assertions, markers (@pytest.mark).
    • Example Test:

      def test_add():
          assert add(2, 3) == 5

  1. Bandwidth & Data Transfer (Q7, Q15, Q21)

    • Bandwidth (bits/sec) = Data (bits) / Time (sec)
    • Data Consumption (GB) = Bandwidth (Mbps) × Time (sec) / (8 × 1024³) (For Q15: Sum bandwidth per hour × time in seconds, convert to GB.)
    • DRAM Bandwidth (Q21): \[ \text{Bandwidth (GB/s)} = \frac{\text{Bus Width (bits)} \times \text{Clock Speed (Hz)} \times 2 \text{ (DDR)}}{8 \times 10^9} \]
  1. Latency Calculation (Q17)

    • Latency (sec) = Distance (m) / Speed of Light (m/s)
    • Round-Trip Time (RTT) = 2 × Latency (For Q17: Split distance into cable/air segments, calculate RTT for each, sum them.)

B. HTML/CSS

Key Concepts:

  1. CSS Specificity

    • !important > Inline > ID > Class > Element.
    • Conflict Resolution: Later rules override earlier ones for equal specificity.
  1. Box Model & Display Properties

    • display: block (full width), inline (no width/height), inline-block.
    • Example (Q3):

      span { display: block; width: 20%; }  /* Takes full width if not constrained */
  1. CSS Selectors

    • .class, #id, element, pseudo-classes (:hover).

C. Web Technologies

Key Concepts:

  1. HTTP Methods & Status Codes

    • 200 OK, 400 Bad Request, 401 Unauthorized, 404 Not Found.
    • Example (Q10, Q25):

      abort(404)  # Returns 404 status
  1. Client-Server Model

    • Statelessness (Q23): Server doesn’t retain client state between requests.
    • Stateful Workarounds: Cookies, sessions, tokens.
  1. IPv4 to Hexadecimal (Q22)

    • Convert each octet to hex (e.g., 172 → AC, 16 → 10).

D. Databases (SQLAlchemy)

Key Concepts:

  1. Relationships (Q12, Q27)

    • One-to-Many:

      class Parent(db.Model):
          children = db.relationship("Child", backref="parent")
    • Many-to-Many: Requires association table.
  1. Foreign Keys

    • db.ForeignKey("table.column").
  1. CRUD Operations

    • db.session.add(), db.session.commit().

E. Testing & Debugging

Key Concepts:

  1. pytest (Q6, Q9, Q29)

    • Run tests: pytest file.py.
    • Select tests: -k "test_name", -m "marker".
    • Example Output (Q6):

      == 2 passed in 0.07s ==  # Only selected tests run
  1. Flask Testing (Q8)

    • Use pytest + requests to test endpoints.
    • Example:

      def test_home():
          response = client.get("/")
          assert response.status_code == 200

F. Networking

Key Concepts:

  1. Bandwidth vs. Latency (Q7, Q17)

    • Bandwidth: Data transfer rate (bits/sec).
    • Latency: Delay (time for data to travel).
  1. HTTP/HTTPS

    • Statelessness (Q23): No client context stored on the server.

Graph 2: HTML/CSS Relationships

Graph 3: Testing Workflow

Graph 4: Database Relationships

Graph 5: Networking Concepts


QuestionConceptEquation
Q7HDD Read Speed\(\text{RPM} = \frac{\text{Bits/sec}}{\text{Bits/revolution}} \times 60\)
Q15Data Consumption\(\text{Data (GB)} = \sum \text{Bandwidth (Mbps)} \times \text{Time (s)} / (8 \times 1024^3)\)
Q17Latency Calculation\(\text{RTT} = 2 \times \left( \frac{\text{Distance}}{\text{Speed of Light}} \right)\)
Q21DRAM Bandwidth\(\text{Bandwidth (GB/s)} = \frac{\text{Bus Width} \times \text{Clock Speed} \times 2}{8 \times 10^9}\)

4. Exam Tips

  1. Flask:

    • Memorize route decorators (@app.route), request handling (request.args/form), and error handlers.
    • Practice Jinja2 templating (conditionals, loops, macros).
  1. HTML/CSS:

    • Understand specificity rules and the box model.
    • Know how display: block vs. inline affects layout.
  1. Databases:

    • Focus on SQLAlchemy model definitions and relationships (one-to-many, many-to-many).
  1. Testing:

    • Learn pytest basics (fixtures, markers, assertions).
    • For Flask, use pytest with requests or test_client.
  1. Networking:

    • Be comfortable with bandwidth/latency calculations.
    • Understand HTTP statelessness and status codes.
  1. Math Problems:

    • Always convert units consistently (e.g., km → m, Mbps → GB/s).
    • For data consumption, sum bandwidth over time intervals.