MAD Study Hub

Home / Past papers / MAD1 End Term / this paper

IIT M FOUNDATION ET1 EXAM QPF1 S1 03 Sep - 03 Sep 2023

MAD1 End Term32 questions100 marks22 MCQ · 9 MSQ · 1 SAFoundation / QPF1
Elapsed 00:00
Q1MCQ2 marks
Consider three components of a todo list app based on an MVC architecture. A - stores a list of all the tasks that the user has submitted along with attributes like completion status. B - can display which tasks were completed, which tasks are pending, receive new tasks from the user etc. C - can set a task in the list of tasks as completed, add a new task to the list of tasks, delete old tasks, retrieve a list of pending tasks and so on. Given the above capabilities of the different components, choose the correct option:
  1. model - A, view - B, controller - C
  2. model - B, view - A, controller - C
  3. model - C, view - B, controller - A
  4. model - A, view - C, controller - B
Q2MCQ2 marks
Which of the following statements is/are correct? Statement 1: In client-server architecture, the client and the server MUST be on separate machines Statement 2: In peer-to-peer architecture, the network is always more fault-tolerant
  1. Both statement 1 and statement 2 are correct.
  2. Statement 1 is correct but statement 2 is incorrect.
  3. Statement 2 is correct but statement 1 is incorrect.
  4. Neither statement 1 nor statement 2 is correct.
Q3MCQ2 marks
In relational databases, a column stores (1) _______ and a row stores (2) ________.
  1. a field, multiple entries
  2. a field, a single entry
  3. a single entry, a field
  4. multiple entries, a field
Q4MCQ2 marks
Which of the following helps us to create custom HTML elements?
  1. SVG
  2. Web Components
  3. Web API
  4. None of these
Q5MCQ2 marks
Which of the following git command will remove a file from the staged area but keeps the file in the directory?
  1. question figure
    text
    ```
    git rm <filename>
    ```
  2. question figure
    text
    ```
    git rm --cached <filename>
    ```
  3. question figure
    text
    ```
    git del <filename>
    ```
  4. question figure
    text
    ```
    git del --cached <filename>
    ```
Q6MCQ4.5 marks
Consider the following graph that represents the variation in bandwidth and number of users connected to a network for an entire day (24 hours). What will be the total data consumed (in Gigabytes) by the user that is connected to the internet network throughout the day? question figure Consider the following graph that represents the variation in bandwidth and number of users connected to a network for an entire day (24 hours). What will be the total data consumed (in Gigabytes) by the user that is connected to the internet network throughout the day?
Text of the picture (copyable)
The image displays two step-function graphs, one above the other, sharing the same x-axis scale for "Time (Hours)".

**Top Graph:**
*   **Y-axis label:** BandWidth
*   **Y-axis units:** Megabits/s
*   **Y-axis scale:** 0, 2, 4, 6, 8, 10
*   **X-axis label:** Time (Hours)
*   **X-axis scale:** 0, 4, 8, 12, 16, 20, 24
*   **Plot (orange line):**
    *   From 0 to 8 hours: Bandwidth is 8 Megabits/s.
    *   From 8 to 16 hours: Bandwidth is 6 Megabits/s.
    *   From 16 to 24 hours: Bandwidth is 2 Megabits/s.

**Bottom Graph:**
*   **Y-axis label:** Users
*   **Y-axis scale:** 0, 3, 6, 9, 12, 15
*   **X-axis label:** Time (Hours)
*   **X-axis scale:** 0, 4, 8, 12, 16, 20, 24
*   **Plot (green line):**
    *   From 0 to 8 hours: Users are 15.
    *   From 8 to 20 hours: Users are 6.
    *   From 20 to 24 hours: Users are 9.
  1. 5.216
  2. 52.16
  3. 6.52
  4. 65.20
Q7MSQ3 marksselect all that apply
Consider a client ‘C’ and a server ‘S’, separated by distance ‘D’ are connected by a fictitious medium in which the speed of light is ‘v’ m/sec. If ‘N’ is the number of consecutive requests that can made in a second by the client ‘C’ (i.e A new request can be made only after receiving the response from the previous request.), Which of the following changes would double the number ‘N’?
  1. A change of medium where the speed of light is v/2 m/sec.
  2. A change of medium where the speed of light is 2v m/sec.
  3. Reduce the distance between C and S from D to D/2.
  4. Increase the distance between C and S from D to 2D.
Q8MSQ3 marksselect all that apply
Consider the following flask app. question figure Consider the following flask app.
Text of the picture (copyable)
```python
from flask import Flask, abort, redirect, url_for, render_template
app = Flask(__name__)

@app.route('/home/<path:directory>')
def find_course(directory):
    if "ML" in directory:
        return f"Welcome to online course on Data Science!"
    else:
        abort(404)

@app.errorhandler(404)
def page_not_found(error):
    return "<h2>Sorry, No course found!<h2>"

app.run()
```
If the application is running locally on http://127.0.0.1:5000, select the correct options.
  1. question figure
    text
    For the URL:
    http://127.0.0.1:5000/home/course/data_science?course=ML
    
    The browser will render:
    **Sorry, No course found!**
  2. question figure
    text
    For the URL:
    http://127.0.0.1:5000/home/course/data_science_ML?course=DL
    
    The browser will render:
    Welcome to online course on Data Science!
  3. question figure
    text
    For the URL:
    
    http://127.0.0.1:5000/home/course/programming?course=DBMS
    
    The browser will render:
    Welcome to online course on Programming!
  4. question figure
    text
    For the URL:
    
    http://127.0.0.1:5000/home/course/DBMS?course=Data_structures
    
    The browser will render:
    **Sorry, No course found!**
Q9MSQ3 marksselect all that apply
Which of the following is/are a correct way to use for loop in jinja?
  1. question figure
    text
    ```python
    from jinja2 import Template
    t=Template("numbers divisible by 2: {% for n in range (0,10,2) %}{{n}}"{% endfor %}")
    print(t.render())
    ```
  2. question figure
    text
    ```html
    <ul>
    {% for item in seq %}
        <li>{{ item }}</li>
    {% endfor %}
    </ul>
    ```
  3. question figure
    text
    ```python
    from jinja2 import Template
    t=Template("My favourite numbers are: {% for n in [2,4,6] %}{{n}}, ""{% endfor %}")
    print(t.render())
    ```
  4. question figure
    text
    ```python
    from jinja2 import Template
    my_statement = Template("The special series is:{% for n in range(1,15) -%} {{n%3}}"{%- endfor %}")
    out = my_statement.render()
    print(out)
    ```
Q10MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following TodoSimple resource class created using flask_restful.

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

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

class TodoSimple(Resource):
    def get(self, todo_id):
        return {"todo_id": todo_id}

    def put(self):
        todo_id = request.args.get("todo_id")
        return {"todo_id": todo_id}

app.run()
```

Which of the following statements given below will correctly map the resource URLs with the TodoSimple resource class.
  1. question figure
    text
    ```python
    api.add_resource(TodoSimple, "/api")
    ```
  2. question figure
    text
    ```python
    api.add_resource(TodoSimple, "/api/<int:todo_id>")
    ```
  3. question figure
    text
    ```python
    api.add_resource(TodoSimple, "/api/<int:todo_id>", "/api")
    ```
  4. question figure
    text
    ```python
    api.add_resource(TodoSimple, "/<int:todo_id>", "/api")
    ```
Q11MCQ3 marks
Consider the following HTML Document. question figure Consider the following HTML Document. How will the browser render the HTML document given above?
Text of the picture (copyable)
```html
<!DOCTYPE html>
<html>
<head>
    <title>Test Document</title>
    <style>
        h4, span {
            display: inline-block;
            width: 200px;
        }
    </style>
</head>
<body>
    <h4>Statement 1 from Document.</h4>
    <h4>Statement 2 from Document.</h4>
    <span>Statement 3 from Document.</span>
    <span>Statement 4 from Document.</span>
</body>
</html>
```
  1. question figure
    text
    Statement 1 from Document.
    Statement 2 from Document.
    Statement 3 from Document. Statement 4 from Document.
  2. question figure
    text
    Statement 1 from Document. Statement 2 from Document.
    
    **Statement 3 from Document.**
    
    **Statement 4 from Document.**
  3. question figure
    text
    Statement 1 from Document.
    
    Statement 2 from Document.
    
    Statement 3 from Document.
    
    Statement 4 from Document.
  4. question figure
    text
    Statement 1 from Document. Statement 2 from Document. Statement 3 from Document. Statement 4 from Document.
Q12MCQ3 marks
question figure
Text of the picture (copyable)
Consider two numbers N1 = 113_a and N2 = 365_b, where a and b are the bases. If
the decimal equivalent of N1 is numerically greater than the decimal equivalent of N2,
then the possible values of a and b would be.
  1. a = 10, b = 8
  2. a = 8, b = 10
  3. a = 16, b = 8
  4. a = 16, b = 10
Q13MCQ3 marks
Consider the following flask app and Jinja2 template. question figure Consider the following flask app and Jinja2 template. question figure Consider the following flask app and Jinja2 template.
Text of the picture (copyable)
```python
app.py
from flask import Flask, render_template
app = Flask(__name__)

@app.route('/')
def index():
    return render_template("index.html", links=['hoME', 'PROfile',
'Contact', 'SITEMAP'])

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 %}
        <li><a href="/{{item}}">{{item|capitalize}}</a></li>
        {% endfor %}
    </ul>
    {% endmacro %}
    {{ unordered_list(links) }}
</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
    - Home
    - Profile
    - Contact
    - Sitemap
  2. question figure
    text
    This is a screenshot of a web page element, specifically an unordered list of navigation links.
    
    - home
    - profile
    - contact
    - sitemap
  3. question figure
    text
    - HoME
    - PROfile
    - Contact
    - SITEMAP
  4. question figure
    text
    This is a screenshot of a web page displaying an unordered list.
    The list items are:
    * HOME
    * PROFILE
    * CONTACT
    * SITEMAP
Q14MCQ3 marks
Consider the following Python code snippet. question figure Consider the following Python code snippet.
Text of the picture (copyable)
file.py

```python
import sys

courses = {
    1: "App Dev I",
    2: "App Dev II",
    3: "Machine Learning",
    4: "Deep learning"
}

arguments = sys.argv

if courses[int(sys.argv[2])] in "App Dev II":
    print("course found",courses[int(sys.argv[2])])
else:
    print("No course found!")
```

What will be output on the terminal for the command `python file.py courses 1?`
  1. question figure
    text
    course found App Dev II
  2. question figure
    text
    course found App Dev I
  3. question figure
    text
    No course found!
  4. question figure
    text
    ```
    IndexError: list index out of range
    ```
Q15MCQ3 marks
Consider the following function to be tested and test functions given in the Python code snippet below. question figure Consider the following function to be tested and test functions given in the Python code snippet below.
Text of the picture (copyable)
```python
def sample_function(x):
    ser = []
    for i in range(x):
        ser.append(((i)**2))
    return ser

def test_func1():
    assert 36 in sample_function(7)

def test_func2():
    assert 64 in sample_function(8)

def sample_test3():
    assert 81 in sample_function(11)
```
What will be the summary of the output for the command
`pytest file.py` on the terminal?
  1. question figure
    text
    ```
    ========== 1 failed, 2 passed in 0.30s ==========
    ```
  2. question figure
    text
    ```text
    ============================= 2 failed, 1 passed in 0.30s =============================
    ```
  3. question figure
    text
    ```
    ========================= 3 failed in 0.30s =========================
    ```
  4. question figure
    text
    ```
    ============ 1 failed, 1 passed in 0.30s =============
    ```
Q16MCQ3 marks
Consider the following Python code snippet. question figure Consider the following Python code snippet.
Text of the picture (copyable)
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 34`?
  1. question figure
    text
    ```
    2023-08-14 21:01:05,684 - INFO - Value added: 34
    ```
  2. question figure
    text
    2023-08-14 21:01:05,684 - WARNING - Value added: 34
  3. question figure
    text
    ```
    ValueError: Invalid value: Please enter a positive value.
    ```
  4. question figure
    text
    None.
Q17MCQ3 marks
Consider the code below and match the conditions in Column A with respect to the coverage types in Column B. question figure Consider the code below and match the conditions in Column A with respect to the coverage types in Column B.
Text of the picture (copyable)
```c
int foo(int x, int y)
{
    int z = 0;
    if((x > 0) && (y > 0))
    {
        z = x;
    }
    return z;
}
```

| Column A | Column B |
|---|---|
| 1. Test invokes foo() at least once | a. Condition coverage |
| 2. foo(1,1) | b. Branch coverage |
| 3. foo(1,1) and foo(1,0) | c. Function coverage |
| 4. foo(0,1) and foo(1,0) | d. Statement coverage |
  1. 1-d, 2-a, 3-b, 4-c
  2. 1-c, 2-d, 3-a, 4-b
  3. 1-c, 2-d, 3-b, 4-a
  4. 1-b, 2-d, 3-c, 4-a
Q18MCQ3 marks
Match the following types of testing with their functionality. question figure Match the following types of testing with their functionality.
Text of the picture (copyable)
| A. Regression testing | 1. Beta Testing |
|---|---|
| B. User Acceptance testing | 2. One step beyond integration Testing |
| 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
Q19MCQ3 marks
Consider the following table “emp” created in SQLite database corresponding to model class “Employee” using flask_sqlalchemy. question figure Consider the following table “emp” created in SQLite database corresponding to model class “Employee” using flask_sqlalchemy.
Text of the picture (copyable)
| Id | Name    | Designation      | Gender | Salary |
|----|---------|------------------|--------|--------|
| 1  | Raji    | Headmaster       | Female | 4500   |
| 2  | Ram     | Teacher          | Male   | 5000   |
| 3  | Raveena | Teacher          | Female | 3000   |
| 4  | Reshma  | Technical staff  | Female | 2000   |
| 5  | Ravi    | Teacher          | Male   | 1000   |

Which of the following code snippets will change the designation of male teachers to professor and will increase their salaries to 6000 correctly when typed in the Python console?
  1. question figure
    text
    ```python
    >>> emp = Employee.query.filter_by(Designation = 'Teacher').all()
    >>> for staff in emp:
    ...     staff.Designation="Professor"
    ...     staff.Salary = 6000
    ... 
    >>> db.session.commit()
    ```
  2. question figure
    text
    ```python
    >>> emp = Employee.query.filter_by(Designation="Teacher",Gender="Male").all()
    >>> for staff in emp:
    ...     staff.Designation="Professor"
    ...     staff.Salary +=6000
    ... 
    >>> db.session.commit()
    ```
  3. question figure
    text
    ```python
    >>>
    emp=Employee.query.filter_by(Designation="Teacher",Gender="Male").all()
    >>> for staff in emp:
    ...     staff.Designation="Professor"
    ...     staff.Salary=6000
    ...
    >>> db.session.commit()
    ```
  4. question figure
    text
    ```python
    >>> emp = Employee.query.filter_by(Designation = 'Teacher').all()
    >>> for staff in emp:
    ...    staff.Designation="Professor"
    ...    staff.Salary += 6000
    ...
    >>> db.session.commit()
    ```
Q20MCQ3 marks
Consider the following python code snippet app.py, the html files, base.html and home.html residing in “templates” folder. question figure Consider the following python code snippet app.py, the html files, base.html and home.html residing in “templates” folder. question figure Consider the following python code snippet app.py, the html files, base.html and home.html residing in “templates” folder.
Text of the picture (copyable)
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 %}
<h3>Welcome to MAD I</h3>
{% endblock %}
```
base.html

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

    <h1 style="color: violet;"> IITM BS Degree </h1>
    {% 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
    Welcome to MAD I
  2. question figure
    text
    IITM BS Degree
    Welcome to MAD I
  3. question figure
    text
    Welcome to MAD I
    IITM BS Degree
  4. question figure
    text
    Error
Q21MCQ3 marks
Consider the following SQL create statement. question figure Consider the following SQL create statement.
Text of the picture (copyable)
```sql
CREATE TABLE car (
    car_id INTEGER NOT NULL,
    model INTEGER NOT NULL,
    name VARCHAR(50),
    mfd_date DATETIME NOT NULL,
    description VARCHAR,
    PRIMARY KEY (car_id),
    UNIQUE (model),
    UNIQUE (name)
)
```

Which of the following flask_sqlalchemy models will create exactly the same table as created by the above SQL command?
  1. question figure
    text
    ```python
    class Car(db.Model):
        car_id = db.Column(db.Integer(), unique = True, nullable = False)
        model = db.Column(db.Integer(), autoincrement = True)
        name = db.Column(db.String(50), unique = True, nullable = True)
        mfd_date = db.Column(db.DateTime(), nullable = False)
        description= db.Column(db.String())
    ```
  2. question figure
    text
    ```python
    class Car(db.Model):
        car_id = db.Column(db.Integer(), primary_key = True)
        model = db.Column(db.Integer(), unique = True, nullable = True)
        name = db.Column(db.String(50), unique = False)
        mfd_date = db.Column(db.DateTime(), nullable = False)
        description = db.Column(db.String())
    ```
  3. question figure
    text
    ```python
    class Car(db.Model):
        car_id = db.Column(db.Integer(), primary_key = True)
        model = db.Column(db.Integer(), unique = True, nullable = False)
        name = db.Column(db.String(50), unique = True, nullable = True)
        mfd_date = db.Column(db.DateTime(), nullable = False)
        description = db.Column(db.String())
    ```
  4. question figure
    text
    ```python
    class Car(db.Model):
        car_id = db.Column(db.Integer(), primary_key = True)
        model = db.Column(db.Integer(), unique = True, nullable = False)
        name = db.Column(db.String(), unique = True, nullable = True)
        mfd_date = db.Column(db.DateTime())
        description = db.Column(db.String(50))
    ```
Q22MSQ2 marksselect all that apply
What can be inferred from the Entity-Relationship Diagram below: question figure What can be inferred from the Entity-Relationship Diagram below:
Text of the picture (copyable)
This is an Entity-Relationship Diagram (ERD) showing two tables: "Salary_Slip" and "Employee".

**Table: Salary_Slip**
| Column Name     | Data Type | Key |
|-----------------|-----------|-----|
| slip_id         |           | PK  |
| Year            | DateTime  |     |
| Month           | DateTime  |     |
| Salary_issued   | Boolean   |     |
| Total_salary    | Integer   |     |

**Table: Employee**
| Column Name     | Data Type | Key |
|-----------------|-----------|-----|
| Employee_id     |           | PK  |
| Employee_name   | Text      |     |

**Relationship:**
There is a relationship line connecting "Salary_Slip" to "Employee".
- The "Salary_Slip" side of the relationship has a crow's foot symbol, indicating "many".
- The "Employee" side of the relationship has a single vertical line, indicating "one".
This represents a "many-to-one" relationship, where many salary slips can belong to one employee.
  1. An employee can exist without having any salary slips
  2. A salary slip can exist without belonging to any employee
  3. An employee needs to have at least one salary slip
  4. A salary slip must belong to one and only one employee
Q23MSQ2 marksselect all that apply
Consider a typical Amazon Alexa device. Which of the following would constitute the view of the application behind such a device?
  1. The AI voice
  2. The LED light around the device
  3. The body of the device
  4. None of these
Q24MSQ2 marksselect all that apply
Which of the following is true of “cold storage” like Amazon Glacier?
  1. They have high cost and low durability.
  2. They have low cost and high durability.
  3. Latency of retrieval is very low.
  4. Latency of retrieval is very high.
Q25MSQ4.5 marksselect all that apply
Consider the following flask application. question figure Consider the following flask application.
Text of the picture (copyable)
```python
app.py
from flask import Flask, render_template, request
app = Flask(__name__)

@app.route('/', methods=['GET'])
def my_form():
    if request.method == 'GET':
        if(request.args.get('name') == None):
            return """
            <form method="GET" action="/">
                <label for="name">Enter a name: </label>
                <input type="text" name="name" id="name"></input>
                <input type="submit" name="btnnum"
                id="btnnum"></input>
            </form>
            """
        
        elif(request.args.get('name') == ''):
            return "<h1>Invalid name</h1>"
        else:
            name = request.args.get('name')
            return f"<h2>My name is {name}</h2>"

app.run()
```

If this flask app is running locally on http://localhost:5000, then which of the following statements is/are incorrect?
  1. question figure
    text
    For http://127.0.0.1:5000/?name=Will+Smith&btnnum=Submit the rendered output is:
    
    My name is Will Smith
  2. question figure
    text
    If the form rendered at http://127.0.0.1:5000/ is submitted with value “Will Smith”, then the rendered output is:
    
    **My name is Will**
  3. question figure
    text
    For the URL http://127.0.0.1:5000/?name, the app will redirect to the base URL.
  4. question figure
    text
    If the form rendered at base URL is submitted with all the fields empty, then it will throw "Not Found" error.
Q26MSQ4.5 marksselect all that apply
Follow the code given below question figure Follow the code given below
Text of the picture (copyable)
```python
from flask import Flask, request
from flask_restful import Resource, Api, fields, marshal, marshal_with

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

class User:
    def __init__(self, id, username, email):
        self.id=id
        self.username=username
        self.email=email

output={"id": fields.Integer, "username": fields.String, "email": fields.String}

## Resource Class Here ======

api.add_resource(Userapi, '/')
if __name__ == '__main__':
    app.run()
```

What code should be written in place of `## Resource Class Here ======` so that we get;

```json
{
  "id": 1,
  "username": "iitm",
  "email": "bs@ds.study.iitm.ac.in"
}
```

as output on running the command `curl -X GET 'http://127.0.0.1:5000'` in the terminal?
  1. question figure
    text
    ```python
    class Userapi(Resource):
        @marshal_with(output)
        def get(self):
            user=User(1, "iitm", "bs@ds.study.iitm.ac.in")
            return user
    ```
  2. question figure
    text
    ```python
    class Userapi(Resource):
        def get(self):
            user=User(1, "iitm", "bs@ds.study.iitm.ac.in")
            return marshal(user, output)
    ```
  3. question figure
    text
    ```python
    @marshal_with(output)
    class Userapi(Resource):
        def get(self):
            user=User(1, "iitm", "bs@ds.study.iitm.ac.in")
            return user
    ```
  4. question figure
    text
    ```python
    class Userapi(Resource):
        def get(self):
            user=User(1, "iitm", "bs@ds.study.iitm.ac.in")
            return user
    ```
Q27SA3 marks
Consider the following flask application. question figure Consider the following flask application.
Text of the picture (copyable)
```python
from flask import Flask, render_template, request
app = Flask(__name__)

@app.route('/')
def out():
    val = request.args

    if val['num'] == '':
        return "<h1>Enter a valid number</h1>"
    elif val['num'].isalpha()==True:
        return "<h1>Invalid number</h1>"
    else:
        out = (val['num']) + (val['num'])
        return f'<h1>{out}</h1>'

if __name__ == "__main__":
    app.run(debug=True)
```
If this flask app is running locally on http://localhost:5000, what is the output for the following URL?
For input: http://localhost:5000/?num=121
Q28MCQ4.5 marks
Consider the following python code snippet. What will be the rendered output? question figure Consider the following python code snippet. What will be the rendered output?
Text of the picture (copyable)
```python
from jinja2 import Template
persons=[
    {"Gender":"Male", "Age":40, "Name":"John"},
    {"Gender":"Female", "Age":16, "Name":"Samantha"},
    {"Gender":"Male", "Age":20, "Name":"Kim"}
]

t="""
<ul>
{% for group in persons|groupby('Gender') %}
    <li>
        {{ group.grouper }}
        <ul>
        {% for person in group.list %}
            <li>{{ person.Name }} is {{ person.Age }} years old</li>
        {% endfor %}
        </ul>
    </li>
{% endfor %}
</ul>
"""

temp=Template(t)
print(temp.render(persons=persons))
```
  1. question figure
    text
    - Male
      - John is 40 years old
    - Female
      - Samantha is 16 years old
    - Male
      - Kim is 20 years old
  2. question figure
    text
    - Female
      - Samantha is 16 years old
    - Male
      - John is 40 years old
      - Kim is 20 years old
  3. question figure
    text
    - Male
      - John is 40 years old
      - Kim is 20 years old
    - Female
      - Samantha is 16 years old
  4. question figure
    text
    - Female
      - Samantha is 16 years old
    - Male
      - John is 40 years old
    - Male
      - Kim is 20 years old
Q29MCQ4.5 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+y**2
    return out

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

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

    def test_case3(self):
        assert func(6,2) == 8

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

    def case_test2(self):
        assert func(4,3) == 14
```

What will be the output on the terminal for the command below?
`pytest test_file.py -k Test_class0`
  1. question figure
    text
    ```
    == 2 failed, 1 passed in 0.17s ===
    ```
  2. question figure
    text
    ```text
    == 1 failed, 1 passed, 1 deselected in 0.17s ===
    ```
  3. question figure
    text
    ```
    == 2 failed, 1 deselected in 0.17s ===
    ```
  4. question figure
    text
    ```
    == 1 failed, 2 passed in 0.17s ====
    ```
Q30MCQ4.5 marks
What will be the output of the following Python code snippet? question figure What will be the output of the following Python code snippet?
Text of the picture (copyable)
```python
def decor(func):
    def wrapper(x):
        y=func(x)
        return x*y
    return wrapper

@decor
def output(x, optional="hello world!"):
    return x, optional

print(output(5))
```
  1. question figure
    text
    ```
    ('hello world!', 'hello world!', 'hello world!', 'hello world!',
    'hello world!')
    ```
  2. question figure
    text
    ```
    (5, 5, 5, 5, 5)
    ```
  3. question figure
    text
    25
  4. question figure
    text
    ```
    (5, 'hello world!', 5, 'hello world!', 5, 'hello world!', 5,
    'hello world!', 5, 'hello world!')
    ```
Q31MCQ4.5 marks
Consider the following flask application. question figure Consider the following flask application.
Text of the picture (copyable)
```python
from flask import Flask
app = Flask(__name__)

@app.route('/user/<username>')
def show_user(username):
    return f'Hello {username} !'

@app.route("/hello/user")
def hello():
    return "Hello, user!"

@app.route("/user/")
def index():
    return "Hello user"

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

If the application is running locally on http://127.0.0.1:5000 then map the URLs in Column A with their rendered outputs in Column B.

| | Column A | | Column B |
|---|---|---|---|
| a | http://localhost:5000/hello/user | 1 | User hello ! |
| b | http://localhost:5000/user/hello | 2 | Hello user ! |
| c | http://localhost:5000/user/user | 3 | Hello hello ! |
| d | http://localhost:5000/user// | 4 | Hello user |
| | | 5 | Hello, user! |
| | | 6 | Not Found |
  1. a-2, b-1, c-5, d-6
  2. a-5, b-1, c-2, d-6
  3. a-5, b-3, c-2, d-4
  4. a-2, b-3, c-4, d-6
Q32MCQ4.5 marks
Consider the following sorting algorithm which sorts any given unsorted array of numbers in ascending order. What would be its time complexity? (Assume appending and deleting an element from an array does not affect time complexity) Step 1: Create an empty array. Step 2: Find the element in the unsorted array with the minimum value. Step 3: Append this element to the array created in step 1. Step 4: Delete this element from the unsorted array. Step 5: Repeat steps 1 to 4 until the unsorted array is empty.
  1. O(logN)
  2. O(N)
  3. O(NlogN)
  4. O(N2)

Answer key

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

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 the core topics, concepts, principles, and equations essential for the "Modern Application Development 1" exam, along with Mermaid knowledge graphs to visualize relationships.


1. Core Topics & Concepts

A. Software Architecture & Design Patterns

1. MVC (Model-View-Controller) Architecture

2. Client-Server vs. Peer-to-Peer Architecture

3. Web Components


B. Databases

1. Relational Databases

2. SQLAlchemy (Flask-SQLAlchemy)

3. Entity-Relationship (ER) Diagrams


C. Version Control (Git)

1. Key Commands

CommandDescription
git rm --cached <file>Remove from staging but keep locally.
git add <file>Stage a file for commit.
git commit -m "message"Commit staged changes.

2. Branching & Merging


D. Web Development (Flask & Jinja2)

1. Flask Routing & Request Handling

2. Jinja2 Templating

3. Flask-RESTful


E. Testing & Debugging

1. Unit Testing (Pytest)

2. Test Coverage Types

TypeDescriptionExample
FunctionEvery function is called.foo() is invoked.
StatementEvery line of code is executed.All if branches are tested.
BranchEvery if/else path is tested.foo(1,1) and foo(1,0).
ConditionEvery boolean sub-expression is tested.(x > 0) && (y > 0).

3. Logging


F. Networking & Performance

1. Bandwidth & Data Consumption

2. Latency & Throughput


G. Mathematics for Computing

1. Number Base Conversion

2. Time Complexity


2. Key Equations

ConceptEquation
Data Consumption\(\text{Data (GB)} = \frac{\text{Bandwidth (Mbps)} \times \text{Time (s)}}{8 \times 1024^3}\)
Round-Trip Time\(\text{RTT} = \frac{2 \times \text{Distance}}{\text{Speed of Light}}\)
Base Conversion\(N_a = d_n \times a^n + \dots + d_0 \times a^0\)
Time Complexity\(O(N^2)\) for nested loops (e.g., selection sort).

Graph 2: Git Workflow

Graph 3: Flask Request Lifecycle

Graph 4: Testing Pyramid

Graph 5: Client-Server vs P2P

Graph 6: SQLAlchemy Relationships

Graph 7: Jinja2 Template Inheritance