MAD Study Hub

Home / Past papers / MAD1 End Term / this paper

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

MAD1 End Term32 questions100 marks24 MCQ · 7 MSQ · 1 SAFoundation / QPF1
Elapsed 00:00
Q1MCQ3 marks
Consider the following snippet of HTML and its output rendered on the browser: question figure Consider the following snippet of HTML and its output rendered on the browser:
Text of the picture (copyable)
index.html

```html
<form action="/">
    <label for="fname">What is your first name?</label><br>
    <input type="text" name="fname" id="fname"><br>
    <input type="submit" value="Submit">
</form>
```

A web browser window is displayed.
The title bar shows "Form" on the left and "Private browsing" in the center.
The address bar shows "localhost:5000".
The main content area displays:
"What is your firstname?"
Below this is an empty text input field.
Below the text input field is a button labeled "Submit".

Which HTTP request would be sent to the server if the user enters "Mahesh" into the text box and clicks submit?
  1. GET
  2. POST
  3. PUT
  4. DELETE
Q2MCQ3 marks
A 6000 rpm magnetic disk is being used to store data. The disk can only spin in one direction and is operating at 6000 revolutions per minute. If the operating system sends a request to the disk controller to fetch data from the disk, but by the time the request reached the disk controller, the information had already moved 35 degrees passed the reader, what will be the latency (in milliseconds) before it can start retrieving data?
  1. 0.97
  2. 9.03
  3. 90.3
  4. 97
Q3MCQ3 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 {
            "value_1": arg1["val"],
            "value_2": arg2["val"],
            "value_3": val
        }

api.add_resource(RestApi, "/api/games/<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:

`curl http://127.0.0.1:5000/api/games/cricket?val=soccer -d "{\"val\":\"tennis\"}" -X POST -H "Content-Type: application/json"`
  1. question figure
    text
    ```json
    {
      "value_1": "soccer",
      "value_2": "tennis",
      "value_3": "cricket"
    }
    ```
  2. question figure
    text
    ```json
    {
        "value_1": "cricket",
        "value_2": "soccer",
        "value_3": "tennis"
    }
    ```
  3. question figure
    text
    ```json
    {
        "value_1": "tennis",
        "value_2": "soccer",
        "value_3": "cricket"
    }
    ```
  4. question figure
    text
    ```json
    {
        "value_1": "tennis",
        "value_2": "cricket",
        "value_3": "soccer"
    }
    ```
Q4MCQ3 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. On running this file on the terminal using pytest, the summary of the output is; question figure Consider the following function to be tested and test functions given in the Python code snippet below. On running this file on the terminal using pytest, the summary of the output is; What command will result into the outcome given above?
Text of the picture (copyable)
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(11) == 121

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

@pytest.mark.marker3
def testcase_3():
    assert square(5) == 36
```
```
======== 1 passed, 2 deselected, 3 warnings in 0.02s ========
```
  1. question figure
    text
    ```
    pytest test_file.py -k marker1
    ```
  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
    ```
Q5MCQ3 marks
question figure
Text of the picture (copyable)
The hexadecimal equivalent of the IPv4 address 192.168.72.101 would be
_________
  1. C048 A865
  2. C0A8 4865
  3. C0A8 6548
  4. C065 A848
Q6MCQ3 marks
An HTML code and CSS code is given below. Which of the following correctly represents its rendered output? question figure An HTML code and CSS code is given below. Which of the following correctly represents its rendered output? question figure An HTML code and CSS code is given below. Which of the following correctly represents its rendered output?
Text of the picture (copyable)
CSS Code:

```css
.one{color: blue;}
.two{color: red !important;}
.three{color: green;}
```
HTML Code:

```html
<!DOCTYPE html>
<html>
<head>
    <title>Document</title>
    <link href="style.css" rel="stylesheet">
    <style>
        body{background-color: aqua; text-align: center;}
        h2{color: violet !important ;}
    </style>
</head>
<body style="background-color:lavender;" >
    <h2 style="color: blue;">Welcome to IIT</h2>
    <p class="one">My content 1 </p>
    <p class="two" style="color: brown;">My content 2</p>
    <p class="three">My content 3</p>
</body>
</html>
```
  1. question figure
    text
    Welcome to IIT
    My content 1
    My content 2
    My content 3
  2. question figure
    text
    Welcome to IIT
    My content 1
    My content 2
    My content 3
  3. question figure
    text
    Welcome to IIT
    My content 1
    My content 2
    My content 3
  4. question figure
    text
    Welcome to IIT
    My content 1
    My content 2
    My content 3
Q7MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following models Student and Project corresponding to tables student and project in SQLite database.

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

class Project(db.Model):
    id = db.Column(db.Integer(), primary_key = True)
    title = db.Column(db.String(), unique = True)
    course = db.Column(db.Integer(), db.ForeignKey("course.id"))
```

Based on the model schemas, what relationship do the classes Student and Project share?
  1. Many-to-Many
  2. One-to-Many
  3. One-to-One
  4. The tables are not at all related
Q8MCQ3 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 Api, Resource

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

class MyApi(Resource):
    def get(self, get):
        return {"greet":"Hello from GET Api!"}

    def put(self):
        return {"greet":"Hello from PUT Api!"}

api.add_resource(MyApi, '/api/<get>', '/api/put')

app.run()
```

If this application is running locally on http://127.0.0.1:5000, which of the following curl commands will throw an error?

1. `curl http://127.0.0.1:5000/api/get -X get`
2. `curl http://127.0.0.1:5000/api/put -X put`
3. `curl http://127.0.0.1:5000/api/post -X get`
4. `curl http://127.0.0.1:5000/api/get -X put`
  1. Only 2 and 4
  2. Only 4
  3. Only 3 and 4
  4. Only 3
Q9MCQ3 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-b, 4-a
  3. 1-c, 2-d, 3-a, 4-b
  4. 1-b, 2-d, 3-c, 4-a
Q10MCQ3 marks
Match the following types of testing with their functionality. question figure Match the following types of testing with their functionality. Which of the following is the correct matching?
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. |
  1. A → 1, B → 2, C → 3, D → 4
  2. A → 4, B → 3, C → 2, D → 1
  3. A → 3, B → 2, C → 1, D → 4
  4. A → 4, B → 1, C → 2, D → 3
Q11MCQ3 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. 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?
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 |
  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').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", Gender="Male").all()
    >>> for staff in emp:
    ...     staff.Designation="Professor"
    ...     staff.Salary=6000
    ...
    >>> db.session.commit()
    ```
Q12MCQ3 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.
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
    Welcome to MAD I
    IITM BS Degree
  3. question figure
    text
    IITM BS Degree
    Welcome to MAD I
  4. question figure
    text
    Error
Q13MCQ3 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(), unique = True, nullable = True)
        mfd_date = db.Column(db.DateTime())
        description = db.Column(db.String(50))
    ```
  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(50), unique = True, nullable = True)
        mfd_date = db.Column(db.DateTime(), nullable = False)
        description = db.Column(db.String())
    ```
Q14MCQ2 marks
Consider the following statements and select the correct option. Statement 1: It is not necessary to implement server-side validation if client-side validation has been implemented. Statement 2: Client-side validation can be implemented with HTML5.
  1. Statement 1 is true while statement 2 is false
  2. Statement 2 is true while statement 1 is false
  3. Both statements are true
  4. Both statements are false
Q15MCQ2 marks
Consider the following statements and select the correct answer. Statement 1: In PaaS, developers are provided with an up-to-date development environment with the languages and frameworks of their choice. Statement 2: Microsoft Azure provides IaaS as well as PaaS services.
  1. Statement 1 is true, but statement 2 is false
  2. Statement 2 is true, but statement 1 is false
  3. Both statements are false
  4. Both statements are true
Q16MCQ2 marks
Consider the following statements and choose the correct option. Statement 1: If we submit the form using the GET method, then the form data is appended inside the body of the HTTP request. Statement 2: Never use GET method in form to send sensitive data while it is good for non-secure data, like query strings in Google
  1. Both statements 1 and 2 are true, and statement 2 is a correct explanation ofstatement 1
  2. Both statements 1 and 2 are true, but statement 2 is not a correct explanationof statement 1
  3. Statement 1 is true and statement 2 is false
  4. Statement 2 is true and statement 1 is false
Q17MCQ2 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 del <filename>
    ```
  3. question figure
    text
    ```
    git del --cached <filename>
    ```
  4. question figure
    text
    ```
    git rm --cached <filename>
    ```
Q18MSQ3 marksselect all that apply
Consider the following python code snippet. question figure Consider the following python code snippet.
Text of the picture (copyable)
```python
from string import Template

statement = "The four major operations on the database are $c, $r, $u and $d."

temp = Template(statement)

print(=== OUTPUT ===)
```

Which of the following statements, when substituted in place of === OUTPUT ===, will not throw a KeyError?
  1. question figure
    text
    ```python
    temp.safe_substitute({"c": "CREATE", "r": "READ", "u": "UPDATE",
    "d": "DELETE"})
    ```
  2. question figure
    text
    ```python
    temp.safe_substitute({"c": "CREATE", "r": "READ", "u": "UPDATE"})
    ```
  3. question figure
    text
    ```python
    temp.safe_substitute({"c":"CREATE", "r":"READ", "u":"UPDATE",
    "d":"DELETE", "e":"TRUNCATE"})
    ```
  4. question figure
    text
    ```python
    temp.substitute({"c":"CREATE","r":"READ","u":"UPDATE",
    "d":"DELETE", "e":"TRUNCATE"})
    ```
Q19MSQ3 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>", "/api")
    ```
  3. question figure
    text
    ```python
    api.add_resource(TodoSimple, "/api/<int:todo_id>")
    ```
  4. question figure
    text
    ```python
    api.add_resource(TodoSimple, "/<int:todo_id>", "/api")
    ```
Q20MSQ2 marksselect all that apply
Which of the statements are true?
  1. HTML5 is based on SGML
  2. XHTML is based on XML which in turn is based on SGML
  3. HTML5 is not backwards compatible with older versions of HTML
  4. XML is both human and machine-readable
Q21MSQ2 marksselect all that apply
Choose the correct code snippet to implement logging by importing python logging module
  1. question figure
    text
    ```python
    import logging
    logging.basicConfig(filename='debug.log', level=logging.DEBUG,
                        format=f'%(asctime)s %(levelname)s %(name)s %(threadName)s :
                        %(message)s')
    ```
  2. question figure
    text
    ```python
    import logging
    logging.basicConfig(filename='debug.log', level=logging.NOTSET,
                        format=f'%(asctime)s %(levelname)s %(name)s %(threadName)s :
    %(message)s')
    ```
  3. question figure
    text
    ```python
    import logging
    logging(filename='debug.log', level=logging.DEBUG)
    ```
  4. question figure
    text
    ```python
    import logging
    logging.basicConfig(filename='debug.log')
    ```
Q22MSQ2 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 body of the device
  3. The LED light around the device
  4. None of these
Q23MSQ2 marksselect all that apply
Which of the following is true of “cold storage” like Amazon Glacier?
  1. They have low cost and high durability.
  2. They have high cost and low durability.
  3. Latency of retrieval is very low.
  4. Latency of retrieval is very high.
Q24MCQ4.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. Which user has consumed the highest amount of data? 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. Which user has consumed the highest amount of data?
Text of the picture (copyable)
This is a 2D line graph with a horizontal x-axis labeled "Time (Hours)" and a vertical y-axis labeled "BandWidth Megabits/s".

The x-axis ranges from 0 to 24, with major tick marks at 0, 4, 8, 12, 14, 16, 20, and 24. Vertical dashed lines extend from each of these major tick marks upwards.

The y-axis ranges from 0 to 12, with major tick marks at 0, 2, 4, 6, 8, 10, and 12.

There are three horizontal colored lines at the top of the graph, representing users:
- A blue line labeled "user 1" extends from x=0 to x=4, at y=11.
- A yellow line labeled "user 2" extends from x=8 to x=14, at y=11.
- A green line labeled "user 3" extends from x=16 to x=24, at y=11.

An orange step-function line is plotted across the graph:
- From x=0 to x=4, the line is at y=8.
- From x=4 to x=8, the line is at y=10.
- From x=8 to x=12, the line is at y=6.
- From x=12 to x=16, the line is at y=8.
- From x=16 to x=20, the line is at y=2.
- From x=20 to x=24, the line is at y=4.
  1. User 1
  2. User 2
  3. User 3
  4. All the three users consumed same amount of data
Q25MCQ4.5 marks
Consider the following restful implementation using flask. question figure Consider the following restful implementation using flask.
Text of the picture (copyable)
```python
from flask import Flask, request
from flask_restful import Resource, Api

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

student_info = {"name": "Rahul", "Roll No":"12d2000678",
"Email":"onlinedegree.iitm.ac.in"}

class Student(Resource):
    def put(self):
        data = request.json
        student_info.update(data)
        return student_info

    def delete(self):
        student_info.popitem()
        return "success", 200

api.add_resource(Student, '/')

app.run()
```

If the above application is running on "http://127.0.0.1:5000" then what will be the final output on
terminal on executing these two curl commands in the order mentioned?
1: `curl -X DELETE 'http://127.0.0.1:5000'`

2: `curl -X PUT -H "Content-Type: application/json" -H "Accept-Type:
application/json" -d '{"Roll No":"12f2000555", "Email":
"ds.study.iitm.ac.in"}' 'http://127.0.0.1:5000/'`
  1. question figure
    text
    ```json
    {"name": "Rahul", "Roll No": "12F2000555", "Email": "ds.study.iitm.ac.in"}
    ```
  2. question figure
    text
    ```json
    {"name": "Rahul", "Roll No": "12f2000555"}
    ```
  3. question figure
    text
    ```json
    {"Roll No":"12f2000555", "Email":"ds.study.iitm.ac.in"}
    ```
  4. question figure
    text
    None of these
Q26MCQ4.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
    - Male
      - John is 40 years old
      - Kim is 20 years old
    - Female
      - Samantha is 16 years old
  3. question figure
    text
    - Female
      - Samantha is 16 years old
    - Male
      - John is 40 years old
      - Kim is 20 years old
  4. question figure
    text
    - Female
      - Samantha is 16 years old
    - Male
      - John is 40 years old
    - Male
      - Kim is 20 years old
Q27MCQ4.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
    ```text
    == 2 failed, 1 passed in 0.17s ===
    ```
  2. question figure
    text
    ```text
    == 2 failed, 1 deselected in 0.17s ====
    ```
  3. question figure
    text
    ```text
    == 1 failed, 1 passed, 1 deselected in 0.17s ====
    ```
  4. question figure
    text
    ```
    == 1 failed, 2 passed in 0.17s ===
    ```
Q28MCQ4.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
    ```
    (5, 'hello world!', 5, 'hello world!', 5, 'hello world!', 5,
    'hello world!', 5, 'hello world!')
    ```
  4. question figure
    text
    25
Q29MCQ4.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-3, c-2, d-4
  3. a-5, b-1, c-2, d-6
  4. a-2, b-3, c-4, d-6
Q30MCQ4.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(N2)
  2. O(N)
  3. O(logN)
  4. O(NlogN)
Q31SA3 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=343
Q32MSQ4.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 user
    ```
  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 marshal(user, output)
    ```

Answer key

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

  1. HTML Forms & HTTP Methods

    • GET vs. POST:

      • GET: Data appended to URL (query string). Used for non-sensitive data (e.g., search queries).
      • POST: Data sent in the request body. Used for sensitive data (e.g., passwords).
    • Example:

      <form action="/submit" method="GET">
        <input type="text" name="username">
        <input type="submit">
      </form>
      • Submitting "Mahesh" sends: GET /submit?username=Mahesh.
  1. CSS Specificity & Inheritance

    • Order of precedence: !important > Inline styles > IDs > Classes > Tags.
    • Example:

      .two { color: red !important; } /* Highest priority */
      <p class="two" style="color: brown;">Text</p> /* Renders as red */
  1. Flask & RESTful APIs

    • Flask-Restful:

      • Define resources with HTTP methods (GET, POST, PUT, DELETE).
      • Example:

        from flask_restful import Resource, Api
        class Todo(Resource):
            def get(self, todo_id):
                return {"todo_id": todo_id}
        api.add_resource(Todo, "/todo/<int:todo_id>")
    • Request Handling:

      • request.args: Query parameters (e.g., ?key=value).
      • request.json: Parsed JSON body (for POST/PUT).
      • request.form: Form data (for POST with Content-Type: multipart/form-data).
  1. Jinja2 Templating

    • Syntax:

      • {{ variable }}: Output a variable.
      • {% for item in list %}: Loop.
      • {% extends "base.html" %}: Inheritance.
    • Example:

      <ul>
        {% for user in users %}
          <li>{{ user.name }}</li>
        {% endfor %}
      </ul>
  1. SQLAlchemy & Database Models

    • Define models with db.Model:

      class User(db.Model):
          id = db.Column(db.Integer, primary_key=True)
          name = db.Column(db.String(50), unique=True)
    • Relationships:

      • db.ForeignKey: One-to-many.
      • db.relationship: Many-to-many (with association tables).
  1. HTTP Status Codes

    • 200 OK: Success.
    • 201 Created: Resource created.
    • 400 Bad Request: Client error.
    • 404 Not Found: Resource missing.
    • 500 Internal Server Error: Server error.

B. Testing (Pytest, Coverage)

  1. Pytest Basics

    • Write test functions with assert.
    • Example:

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

      pytest test_file.py -v
  1. Test Selection & Markers

    • -k: Select tests by name (e.g., pytest -k "test_add").
    • -m: Select tests by marker (e.g., @pytest.mark.slow).
    • Example:

      @pytest.mark.marker1
      def test_case1():
          assert square(5) == 25

      Run with: pytest -m marker1.

  1. Coverage Types | Type | Description | Example Test Cases | |--------------------|----------------------------------------------|-----------------------------| | Function | Every function is called at least once. | foo() | | Statement | Every line of code is executed. | foo(1, 1) | | Branch | Every if/else branch is tested. | foo(1, 1) and foo(1, 0) | | Condition | Every sub-condition (e.g., x > 0 && y > 0) is tested. | foo(0, 1) and foo(1, 0) |

C. Version Control (Git)

  1. Git Commands

    • git rm --cached <file>: Remove from staging but keep locally.
    • git commit -m "message": Commit changes.
    • git push: Upload to remote.
  1. Branching & Merging

    • git branch: List branches.
    • git checkout -b new-branch: Create and switch branches.

D. Cloud Computing (PaaS, IaaS)

  1. Service Models

    • IaaS: Infrastructure as a Service (e.g., AWS EC2).
    • PaaS: Platform as a Service (e.g., Heroku, Azure App Service).
    • SaaS: Software as a Service (e.g., Gmail).
  1. Storage Types

    • Hot Storage: Low latency, high cost (e.g., S3).
    • Cold Storage: High latency, low cost (e.g., Amazon Glacier).

E. Algorithms & Complexity

  1. Time Complexity

    • Selection Sort-like Algorithm (Question 31):

      • Steps:

        1. Find min element in unsorted array: O(N).
        2. Repeat N times: O(N) * N = O(N²).
      • Answer: O(N²).

F. Networking (IPv4, Bandwidth)

  1. IPv4 to Hexadecimal

    • Convert each octet to hex:

      • 192 → C0, 168 → A8, 72 → 48, 101 → 65.
      • Answer: C0A8 4865.
  1. Disk Latency Calculation

    • Formula:

      Latency (ms) = (Degrees Missed / 360) * (60,000 / RPM)
    • Example (Question 3):

      • 35° missed, 6000 RPM:

        Latency = (35 / 360) * (60,000 / 6000) = 0.097 * 10 ≈ 0.97 ms
      • Wait for full rotation: 10 ms - 0.97 ms = 9.03 ms.
      • Answer: 9.03 ms.
  1. Bandwidth vs. Data Consumption

    • Data = Bandwidth × Time.
    • Example (Question 25):

      • User 2: 10 Mbps × 8 hours = 80 Mb (highest).

G. Software Testing Types

TypeDescriptionExample
RegressionEnsure new changes don’t break existing functionality.Re-run all tests after a bug fix.
User AcceptanceValidate software with real users.Beta testing.
SystemTest the complete system.End-to-end workflows.
AutomationScripted testing (e.g., Selenium).Automate login tests.

2. Key Equations

A. Disk Latency

Latency (ms) = (Degrees Missed / 360) × (60,000 / RPM)

B. Data Consumption

Data (Mb) = Bandwidth (Mbps) × Time (hours) × 3600

Graph 2: Testing Concepts

Graph 3: Git Workflow

Graph 4: Cloud Service Models

Graph 5: HTTP Request Flow


4. Exam Tips

  1. Flask-Restful:

    • Use @marshal_with for structured JSON responses.
    • request.args (query params) vs. request.json (body).
  1. Pytest:

    • -k for keyword filtering, -m for markers.
    • 1 passed, 2 deselected means only tests matching the marker ran.
  1. Git:

    • git rm --cached removes from staging but keeps the file locally.
  1. CSS:

    • !important overrides all other styles.
  1. IPv4 Hex Conversion:

    • Break into octets and convert each to hex.
  1. Bandwidth Calculation:

    • Multiply bandwidth by time to find data consumed.
  1. Cold Storage:

    • High latency, low cost (e.g., Amazon Glacier).