MAD Study Hub

Home / Past papers / MAD1 End Term / this paper

2023 Dec24: IIT M FN EXAM FDD2 - 24 Dec 2023

MAD1 End Term32 questions100 marks27 MCQ · 5 MSQforenoon
Elapsed 00:00
Q1MCQ2 marks
question figure
Text of the picture (copyable)
Consider the given URL below.

```
https://seek.onlinedegree.iitm.ac.in/courses/ns_23t3_cs2003?type=lesson&tab
=courses
```

Select the appropriate option that correctly identifies different components of a given URL.
  1. question figure
    text
    ```
    Protocol: https
    Domain: seek
    Sub-Domain: onlinedegree.iitm.ac.in
    Path: /courses
    Parameters: ns_23t3_cs2003?type=lesson&tab=courses
    ```
  2. question figure
    text
    ```
    Protocol: https
    Domain: seek
    Sub-Domain: onlinedegree.iitm.ac.in/courses
    Path: /ns_23t3_cs2003
    Parameters: ?type=lesson&tab=courses
    ```
  3. question figure
    text
    ```
    Protocol: https
    Domain: onlinedegree.iitm.ac.in
    Sub-Domain: seek
    Path: /courses/ns_23t3_cs2003
    Parameters: ?type=lesson&tab=courses
    ```
  4. question figure
    text
    ```
    Protocol: https
    Domain: onlinedegree.iitm.ac.in/courses
    Sub-Domain: seek
    Path: /ns_23t3_cs2003
    Parameters: ?type=lesson&tab=courses
    ```
Q2MCQ2 marks
Read the statements given below carefully and select the correct option. Statement 1: If an element is styled externally using two different classes and an ID, then for the same attribute, it will always acquire styling from the latest style in order. Statement 2: If an element is styled internally using ID and class selector as well as using inline styling for the same style attribute, then it will acquire styling from the ID selector.
  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
Q3MCQ2 marks
question figure
Text of the picture (copyable)
Consider two python files, one.py and two.py with following code snippets.
File1: one.py

```python
import sys
import two
print(f'{sys.argv[0]} {sys.argv[1]}')
```

File2: two.py

```python
import sys
print(f'{sys.argv[3]} {sys.argv[2]}')
```

What is the output of the following command "python one.py two.py one.py two.py "?
  1. question figure
    text
    one.py two.py
    one.py two.py
  2. question figure
    text
    two.py one.py
    one.py two.py
  3. question figure
    text
    two.py one.py
    two.py one.py
  4. question figure
    text
    one.py two.py
    two.py one.py
Q4MCQ2 marks
What is the primary purpose of curl?
  1. Web server configuration
  2. Making requests to the web server
  3. Database management
  4. HTML parsing
Q5MCQ2 marks
What is template inheritance in Jinja2 used for?
  1. To establish a database connection
  2. To create a new database table
  3. To define a base template with a common structure and placeholders that canbe extended by child templates
  4. To insert CSS styles
Q6MCQ2 marks
Which of the following is a common method to achieve data persistence in web applications?
  1. Storing data in volatile cache
  2. Saving data to temporary files
  3. Writing data to a database
  4. Using data stored in RAM
Q7MCQ2 marks
Which of the following helps us to create custom HTML elements?
  1. SVG
  2. Web Components
  3. Web API
  4. None of these
Q8MCQ3 marks
How will the browser render the following HTML document? question figure How will the browser render the following HTML document?
Text of the picture (copyable)
```html
<!DOCTYPE html>
<html>
<head>
    <title>Document</title>
    <style>
        div{
            border: 1px solid black;
            color:pink;
            display: inline-block;
        }
        span{
            border: 1px solid pink;
        }
    </style>
</head>
<body>
    <div>Div 1</div>
    <div>Div 2</div>
    <span>Span 1</span>
    <span>Span 2</span>
</body>
</html>
```
  1. question figure
    text
    The image displays four text elements, arranged horizontally.
    The first element is "Div 1 Div 2", enclosed in a black rectangular border. The text "Div 1" is in a light pink color, and "Div 2" is also in a light pink color.
    The second element is "Span 1", enclosed in a light pink rectangular border. The text "Span 1" is in black.
    The third element is "Span 2", enclosed in a light pink rectangular border. The text "Span 2" is in black.
  2. question figure
    text
    The image displays four text elements, each enclosed in a rectangular border.
    From left to right:
    1. "Div 1" with a black border and light pink text.
    2. "Div 2" with a black border and light pink text.
    3. "Span 1" with a light pink border and black text.
    4. "Span 2" with a light pink border and black text.
  3. question figure
    text
    The image displays two rectangular boxes side-by-side.
    The left box has a black border and contains the text "Div 1 Div 2" in a light pink color.
    The right box has a light pink border and contains the text "Span 1 Span 2" in a black color.
  4. question figure
    text
    The image displays three rectangular boxes arranged horizontally.
    The first box, on the left, contains the text "Div 1" in light pink color with a black border.
    The second box, in the middle, contains the text "Div 2" also in light pink color with a black border.
    The third box, on the right, contains the text "Span 1 Span 2" in black color with a light pink border.
Q9MCQ3 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.
    ```
Q10MCQ3 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) == 10

    def test_case3(self):
        assert func(4,2) == 21

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

    def case_test2(self):
        assert func(4,3) == 25
```
What will be the output on the terminal for the command below?
pytest test_file.py -k Test_class
  1. question figure
    text
    ```
    == 3 failed, 2 passed in 0.17s ===
    ```
  2. question figure
    text
    ```
    == 2 failed, 1 passed, 2 deselected in 0.04s ===
    ```
  3. question figure
    text
    ```
    === 1 failed, 1 passed, 1 deselected in 0.04s ===
    ```
  4. question figure
    text
    ```
    == 2 failed, 1 passed in 0.17s ===
    ```
Q11MCQ3 marks
Consider the statements given below and choose the correct option. Statement 1: 100% condition coverage automatically implies 100% branch coverage. Statement 2: 100% branch coverage automatically implies 100% condition coverage.
  1. Both statement 1 and 2 are correct.
  2. Both statement 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.
Q12MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following box model of an element `<div>` with Id = "box".

Diagram: Box Model
- Outermost layer (light orange, dashed border): Margin. Values: Top 5, Right 10, Bottom 5, Left 10.
- Second layer (yellow, solid border): Border. Values: Top 3, Right 3, Bottom 3, Left 3.
- Third layer (green, dashed border): Padding. Values: Top 8, Right 4, Bottom 8, Left 4.
- Innermost layer (blue, solid border): Content. Values: 200x20.

Which of the following CSS styling would correctly create the box model of the element given above?
  1. question figure
    text
    ```css
    #box {
      width: 200px;
      border: 3px solid red;
      margin: 5px 10px;
      padding: 8px 4px;
    }
    ```
  2. question figure
    text
    ```css
    #box {
        width: 200px;
        height: 20px;
        border: 3px solid red;
        margin: 5px 10px;
        padding: 8px 4px;
    }
    ```
  3. question figure
    text
    ```css
    #box {
        width: 200px;
        height: 20px;
        border: 3px solid red;
        padding: 5px 10px;
        margin: 8px 4px;
    }
    ```
  4. question figure
    text
    ```css
    #box {
        width: 200px;
        height: 20px;
        border: 3px solid red;
        margin: 10px 5px;
        padding: 4px 8px;
    }
    ```
Q13MCQ3 marks
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(12) == 144

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

@pytest.mark.marker3
def testcase_3():
    assert square(3) == 27
```

On running this file on the terminal using pytest, the summary of the output is:
`========== 1 passed, 2 deselected, 3 warnings in 0.02s ==========`

What command will result into the outcome given above?
  1. question figure
    text
    ```
    pytest test_file.py -k marker1
    ```
  2. question figure
    text
    ```
    pytest test_file.py -m marker3
    ```
  3. question figure
    text
    ```
    pytest test_file.py -m marker2
    ```
  4. question figure
    text
    ```
    pytest test_file.py -m marker1
    ```
Q14MCQ3 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
Q15MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following models Creator and Song corresponding to tables
creator and song in SQLite database.

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

class Song(db.Model):
    id = db.Column(db.Integer(), primary_key = True)
    s_title = db.Column(db.String(), unique = True)
    singer = db.Column(db.Integer(), db.ForeignKey("singer.id"))
```

Based on the model schemas, what relationship do the table creator and song
share?
  1. Many-to-Many
  2. One-to-Many
  3. One-to-One
  4. The tables are not at all related
Q16MCQ3 marks
What is the git command to change the registered e-mail of a user using CLI?
  1. question figure
    text
    ```
    git config email <new e-mail>
    ```
  2. question figure
    text
    ```
    git config user.email <new e-mail>
    ```
  3. question figure
    text
    ```
    git config --global email <new e-mail>
    ```
  4. question figure
    text
    ```
    git config --global user.email <new e-mail>
    ```
Q17MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following one-line python code snippet.
Filename: application.py

```python
print(__name__)
```

If we run the above file in a terminal using "python application.py", what will be the output?
  1. application
  2. __application__
  3. main
  4. __main__
Q18MCQ3 marks
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
Q19MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following Python code snippet.

Filename: arg.py
```python
from jinja2 import Template
import sys
input_list = sys.argv
num1, num2, input_list[3] = int(input_list[1]), int(input_list[2]), \
                            int(input_list[3])

if input_list[3]== 1:
    num3= (num1*num2)
elif input_list[3]== 2:
    num3= (num1+num2)
elif input_list[3]== 3:
    num3= (num1-num2)
else:
    num3= (num1%num2)
template = """
<!DOCTYPE html>
<html>
<div>
    Number 1: {{num1}},
    Number 2: {{num2}},
    Output : {{num3}}
</div>
</html>
"""

t = Template(template)
print(t.render(num1=num1, num2=num2, num3=num3))
```
Map the commands in column A with the correct rendered output in the browser in column B.

| Column A | Column B |
|---|---|
| a) python arg.py 1 2 1 | 1) Number 1: 1, Number 2: 2, Output : 3 |
| b) python arg.py 1 2 2 | 2) Number 1: 3, Number 2: 2, Output : 1 |
| c) python arg.py 3 2 4 | 3) Number 1: 1, Number 2: 2, Output : 2 |
| d) python arg.py 3 2 3 | 4) Number 1: 3, Number 2: 2, Output : 1 |
  1. a - 4, b - 1, c - 2, d - 3
  2. a - 3, b - 1, c - 4, d - 2
  3. a - 4, b - 1, c - 3, d - 2
  4. a - 1, b - 3, c - 2, d - 4
Q20MCQ4.5 marks
question figure
Text of the picture (copyable)
Given a Python code snippet, code.py is run on the terminal with an appropriate temp.html document.

code.py
```python
from jinja2 import Template
Products = [
    {'product_id':'101', 'prod_name':'Legion', 'producer':'Lenovo'},
    {'product_id':'102', 'prod_name':'S21pro', 'producer':'Samsung'},
    {'product_id':'103', 'prod_name':'TabA7', 'producer':'Samsung'},
    {'product_id':'104', 'prod_name':'Ideapad', 'producer':'Lenovo'},
]

file = open ('temp.html','r')
temp = file.read()
file.close()
made_temp = Template(temp)
print(made_temp.render(Products=Products))
```

What should be the content of temp.html file if the browser renders the output of the above code, as shown below;
Lenovo

| Product ID | Name    |
|:-----------|:--------|
| 101        | Legion  |
| 104        | Ideapad |

Samsung

| Product ID | Name   |
|:-----------|:-------|
| 102        | S21pro |
| 103        | TabA7  |
  1. question figure
    text
    ```html
    {% for product in Products| groupby('producer') %}
    <p> {{product.grouper}} </p>
    <table border="1">
        <tr>
            <th>Product ID</th>
            <th>Name</th>
        </tr>
        <tr>
            <td>{{product.product_id}}</td>
            <td>{{product.prod_name}}</td>
        </tr>
    </table>
    {% endfor %}
    ```
  2. question figure
    text
    ```html
    {% for product in Products| groupby('prod_name') %}
    <p>{{product.grouper}} </p>
    <table border="1">
    <tr>
    <th>Product ID</th>
    <th>Name</th>
    </tr>
    {% for item in product.list %}
    <tr>
    <td>{{item.product_id}}</td>
    <td>{{item.prod_name}}</td>
    </tr>
    {% endfor %}
    </table>
    {% endfor %}
    ```
  3. question figure
    text
    ```html
    {% for product in Products| groupby('producer') %}
    <p> {{product.grouper}} </p>
    <table border="1">
    <tr>
    <th>Product ID</th>
    <th>Name</th>
    </tr>
    {% for item in product.list %}
    <tr>
    <td>{{item.product_id}}</td>
    <td>{{item.prod_name}}</td>
    </tr>
    {% endfor %}
    </table>
    {% endfor %}
    ```
  4. question figure
    text
    ```html
    {% for product in Products| groupby('prod_name') %}
        <p>{{product.grouper}}</p>
        <table border="1">
            <tr>
                <th>Product ID</th>
                <th>Name</th>
            </tr>
            <tr>
                <td>{{item.product_id}}</td>
                <td>{{item.prod_name}}</td>
            </tr>
        </table>
    {% endfor %}
    ```
Q21MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following function to be tested and test functions given in the Python code snippet below.

```python
# test_file.py
powers = []

for i in range(1,5):
    def powers_of_x(x):
        return x**i
    powers.append(powers_of_x)

powers_of_4 = [x(4) for x in powers]

def testcase_1():
    assert 12 in powers_of_4

def testcase_2():
    assert 64 in powers_of_4

def testcase_3():
    assert 256 in powers_of_4
```

For the command `pytest test_file.py`, what will be the output on the terminal?
  1. question figure
    text
    ```
    ======== 1 failed, 2 passed in 0.02s ========
    ```
  2. question figure
    text
    ======================================== 3 passed in 0.02s ========================================
  3. question figure
    text
    ========== 3 Failed in 0.02s ==========
  4. question figure
    text
    ```
    ========================= 2 failed, 1 passed in 0.02s =========================
    ```
Q22MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following HTML document rendered using a browser.

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
    <style>
        input:valid {
            background: green;
        }
        input:invalid {
            background: red;
        }
    </style>
</head>
<body>
    <form>
        <label for="uname">Enter a valid e-mail:</label>
        <input type="text" name="uname" minlength="5"
               maxlength="8" value="a">
    </form>
</body>
</html>
```

If a user starts typing "madcourse" letter by letter, how will the background colour of the `<input>` tag change?
  1. Red for first five letters, turns green till 8th letter and turns red back againafter next letter.
  2. Green for first five letters, turns red till 8th letter and turns green back againafter next letter.
  3. Red for first five letters, and remain green after that.
  4. Green for first five letters, and remain red after that.
Q23MSQ4.5 marksselect all that apply
question figure
Text of the picture (copyable)
An HTML code is given below, which of the following CSS code will render the output as shown below.

HTML Code:

```html
<!DOCTYPE html>
<html>
<head>
    <title>Document</title>
    <link href="style.css" rel="stylesheet">
    <style>
        body{background-color: gray; text-align: center;}
        h2{color: purple !important ;}
    </style>
</head>
<body style="background-color:lavender;" >
    <h2 style="color: blue;">CSS Selectors</h2>
    <p class="one">ID</p>
    <p class="two">Class</p>
    <p class="three" id="id">Element</p>
</body>
</html>
```

Rendered Output:

UI screenshot: A light blue rectangular box with rounded corners.
Inside the box, the text "CSS Selectors" is displayed in purple, centered.
Below it, the text "ID" is displayed in blue, centered.
Below it, the text "Class" is displayed in blue, centered.
Below it, the text "Element" is displayed in red, centered.
  1. question figure
    text
    ```css
    body{background-color: skyblue !important;}
    #id{color: green ;}
    .one{color: yellow;}
    .two{color: blue;}
    .three{color: red;}
    ```
  2. question figure
    text
    ```css
    body{background-color: skyblue !important;}
    #id{color: red ;}
    .one{color: yellow;}
    .two{color: blue;}
    .three{color: green;}
    ```
  3. question figure
    text
    ```css
    body{background-color: skyblue !important;}
    #id{color: red ;}
    .one{color: blue;}
    .two{color: yellow;}
    .three{color: green;}
    ```
  4. question figure
    text
    ```css
    body{background-color: skyblue !important;}
    #id{color: red ;}
    .one{color: yellow;}
    .two{color: blue;}
    ```
Q24MSQ4.5 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following flask application.

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

@app.route('/home/<path:url_path>')
def course(url_path):
    return 'The path is: ' + url_path

@app.route('/home/details/<student_id>/<course_id>')
def home(student_id, course_id):
    return f'The student-id and course-id are {student_id} and {course_id} respectively.'

@app.route('/home/student/<student_id>/<course_id>')
def details(student_id, course_id):
    details = {'course_id': course_id, 'student_id': student_id}
    return details

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/home/M101/CS2003 browser will render;
    The student-id and course-id are M101 and CS2003 respectively.
  2. question figure
    text
    For URL, http://127.0.0.1:5000/home/student/M101/CS2003 browser will render
    
    ```json
    {
      "course_id": "CS2003",
      "student_id": "M101"
    }
    ```
  3. question figure
    text
    For URL http://127.0.0.1:5000/home/details/M101/CS2003 browser will render,
    The student-id and course-id are M101 and CS2003 respectively.
  4. question figure
    text
    For URL, http://127.0.0.1:5000/home/M101/CS2003 browser will render;
    The path is: M101/CS2003
Q25MSQ4.5 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following python code snippet and choose the correct option.

```python
def modify(func):
    def wrapper(x):
        list = func(x, [])
        return list
    return wrapper

@modify
def expandList(x, list = []):
    list.append(x)
    return list

print(expandList(5))
print(expandList(6))
```
  1. question figure
    text
    If the code is run on the terminal directly, the output on the terminal will be;
    ```
    [5]
    [6]
    ```
  2. question figure
    text
    If the code is run on the terminal directly, the output on the terminal will be;
    ```
    [5]
    [5, 6]
    ```
  3. question figure
    text
    If `@modify` is commented and the updated code is run on the terminal, the output will be;
    
    ```
    [5]
    [6]
    ```
  4. question figure
    text
    If `@modify` is commented and the updated code is run on the terminal, the output will be;
    ```
    [5]
    [5, 6]
    ```
Q26MSQ4.5 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following flask application.

```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.**
Q27MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following flask view function definition given below.

```python
@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'GET':
        return render_template("login.html")
    if request.method == 'POST':
        #=== POST Logic ===
        return render_template("profile.html")
```

Which of the following view function definitions would work the same as that of one given above?
  1. question figure
    text
    ```python
    @app.route('/login', methods=['GET', 'POST'])
    def login():
        if request.method == 'POST':
            #=== POST logic ===
            return render_template("profile.html")
        return render_template("login.html")
    ```
  2. question figure
    text
    ```python
    @app.get('/login')
    def login_page():
        return render_template("login.html")
    
    @app.post('/login')
    def login_verify():
        #=== POST Logic ===
        return render_template("profile.html")
    ```
  3. question figure
    text
    ```python
    @app.route('/login', methods=['GET', 'POST'])
    def login():
        return render_template("login.html")
        if request.method == 'POST':
            #=== POST logic ===
            return render_template("profile.html")
    ```
  4. question figure
    text
    None of these
Comprehension passage - the questions below it refer to this
question figure
Q28MCQ3 marks
What is the maximum number of requests that can be made to B per second?
  1. 166
  2. 100
  3. 56
  4. 111
Q29MCQ2 marks
What is the round trip time (RTT) in milliseconds for server B?
  1. 10
  2. 6
  3. 18
  4. 5
Comprehension passage - the questions below it refer to this
question figure
Q30MCQ3 marks
question figure
Text of the picture (copyable)
If the curl request shown below.

```
curl http://127.0.0.1:5000/api/v1 -X GET -d "{\"movie\": \"X-men\", \"genre\": \"Action\"}" -H "Content-Type: application/json"
```

retrieves the movie only with status 200 OK,
what will come in place of GET-FUNCTION
in the code?
  1. question figure
    text
    ```python
    def get(self):
        return {'Movie': movie}
    ```
  2. question figure
    text
    ```python
    def get(self, movie):
        return {'Movie': movie}
    ```
  3. question figure
    text
    ```python
    def get(self):
        args = parser.parse_args()
        return {'Movie': args['movie']}
    ```
  4. question figure
    text
    ```python
    def get(self):
        args = parser.parse_args()
        return args
    ```
Q31MCQ3 marks
question figure
Text of the picture (copyable)
If the curl request shown below

```
curl http://127.0.0.1:5000/api/v1/fiction -X POST
```

retrieves the genre only with status 200 OK,
what will come in place of POST-FUNCTION
in the code?
  1. question figure
    text
    ```python
    def get(self):
        return {'Genre': genre}
    ```
  2. question figure
    text
    ```python
    def get(self, movie):
        return {'Genre': genre}
    ```
  3. question figure
    text
    ```python
    def get(self):
        args = parser.parse_args()
        return {'Genre': args['genre']}
    ```
  4. question figure
    text
    ```python
    def get(self):
        args = parser.parse_args()
        return args
    ```
Q32MCQ3 marks
question figure
Text of the picture (copyable)
What will be the response from the server for the request:
```
curl http://127.0.0.1:5000/api/v1 -X PUT -d "{\"movie\" : \"X-men\", \"genre\": \"Action\"}" -H "Content-Type: application/json"
```
  1. question figure
    text
    ```json
    {
      "Movie": "X-men",
      "Genre": "Action"
    }
    ```
  2. question figure
    text
    ```json
    {
      "Movie": "X-men"
    }
    ```
  3. question figure
    text
    ```json
    {
      "Genre": "Action"
    }
    ```
  4. question figure
    text
    None of these

Answer key

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



1. Core Topics & Concepts

A. Web Development Fundamentals

  1. URL Structure

    • Components: Scheme (e.g., https), Domain (e.g., example.com), Path (e.g., /courses), Query Parameters (e.g., ?type=lesson).
    • Example:

      https://seek.onlinedegree.iitm.ac.in/courses/ns_23t3_cs2003?type=lesson&tab=courses
      • Scheme: https
      • Domain: seek.onlinedegree.iitm.ac.in
      • Path: /courses/ns_23t3_cs2003
      • Query Parameters: type=lesson, tab=courses
  1. HTTP Methods & Status Codes

    • Methods: GET, POST, PUT, DELETE.
    • Status Codes:

      • 200 OK: Success.
      • 400 Bad Request: Client error (e.g., invalid input).
      • 401 Unauthorized: Authentication failed.
      • 404 Not Found: Resource not found.
      • 500 Internal Server Error: Server-side issue.
  1. cURL

    • Command-line tool for making HTTP requests.
    • Example:

      curl http://127.0.0.1:5000/api/v1 -X GET -d "{\"movie\": \"X-men\"}" -H "Content-Type: application/json"
  1. CSS Selectors & Specificity

    • Specificity Hierarchy: !important > Inline Styles > IDs > Classes > Elements.
    • Example:

      h2 { color: blue; }          /* Element selector */
      .class { color: green; }    /* Class selector */
      #id { color: red; }          /* ID selector */
    • Pseudo-classes: :valid, :invalid (for form validation).
  1. HTML Forms & Validation

    • Attributes: minlength, maxlength, required.
    • Example:

      <input type="text" minlength="5" maxlength="8" required>

B. Backend Development (Flask & Python)

  1. Flask Basics

    • Routes: @app.route('/path').
    • Request Handling: request.args, request.method.
    • Sessions: session['key'] = value.
    • Error Handling: @app.errorhandler(404).
    • Example:

      from flask import Flask, request, session, abort
      app = Flask(__name__)
      app.secret_key = "secret"

@app.route('/login', methods=['GET', 'POST']) def login(): if request.method == 'POST': user = request.form['user'] session['user'] = user return f"Logged in as {user}" return "Login Page" ```

  1. Flask-RESTful

    • Resources: class Resource(Resource).
    • Parsing Arguments: reqparse.RequestParser().
    • Marshaling: @marshal_with(fields).
    • Example:

      from flask_restful import Resource, reqparse, fields, marshal_with

parser = reqparse.RequestParser() parser.add_argument('movie') parser.add_argument('genre')

class TestAPI(Resource): @marshal_with({'film': fields.String}) def put(self): args = parser.parse_args() return {'film': args['movie']} ```

  1. Database Integration (SQLAlchemy)

    • Models: db.Model.
    • Relationships: db.ForeignKey, db.relationship.
    • CRUD Operations: db.session.add(), db.session.commit().
    • Example:

      from flask_sqlalchemy import SQLAlchemy
      db = SQLAlchemy(app)

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

db.create_all() user = User(name="Alice") db.session.add(user) db.session.commit() ```

  1. Jinja2 Templating

    • Template Inheritance: {% extends 'base.html' %}.
    • Loops/Conditionals: {% for %}, {% if %}.
    • Filters: {{ variable|upper }}.
    • Example:

      <!-- base.html -->
      <html>
      <head><title>{% block title %}{% endblock %}</title></head>
      <body>{% block content %}{% endblock %}</body>
      </html>

<!-- child.html --> {% extends 'base.html' %} {% block title %}Child Page{% endblock %} {% block content %}<h1>Hello!</h1>{% endblock %} ```


C. Frontend Development

  1. Web Components

    • Custom Elements: class MyElement extends HTMLElement.
    • Shadow DOM: this.attachShadow({ mode: 'open' }).
    • Example:

      class MyComponent extends HTMLElement {
        connectedCallback() {
          this.innerHTML = `<p>Hello, World!</p>`;
        }
      }
      customElements.define('my-component', MyComponent);
  1. HTML Tables & Rendering

    • Basic Structure:

      <table>
        <tr><th>Header</th></tr>
        <tr><td>Data</td></tr>
      </table>
    • Dynamic Rendering with Jinja2:

      <table>
        {% for item in items %}
          <tr><td>{{ item.name }}</td></tr>
        {% endfor %}
      </table>

D. Testing & Debugging

  1. Pytest

    • Fixtures: @pytest.fixture.
    • Markers: @pytest.mark.marker_name.
    • Assertions: assert func(x) == expected.
    • Example:

      import pytest

@pytest.mark.parametrize("x, expected", [(2, 4), (3, 9)]) def test_square(x, expected): assert x ** 2 == expected ```

  1. Test Coverage

    • Branch Coverage: All branches (e.g., if-else) are tested.
    • Condition Coverage: All conditions (e.g., x > 0) are tested.
    • Statement: 100% branch coverage ≠ 100% condition coverage.
  1. Debugging Python

    • sys.argv: Command-line arguments.
    • Decorators: Modify function behavior.
    • Example:

      import sys
      print(sys.argv[1])  # First command-line argument

E. Version Control (Git)

  1. Git Commands

    • Configure User:

      git config --global user.email "email@example.com"
    • Basic Workflow:

      git add .
      git commit -m "Message"
      git push origin main

F. Networking Basics

  1. IPv4 to Hexadecimal

    • Convert each octet to hex.
    • Example: 172.16.254.10 → AC.10.FE.0A.
  1. Round-Trip Time (RTT)

    • Formula:

      RTT = (2 * distance) / speed_of_light
    • Example: For 900 km,

      RTT = (2 * 900,000 m) / (3 * 10^8 m/s) = 6 ms

G. Software Design Principles

  1. DRY (Don’t Repeat Yourself)

    • Avoid code duplication (e.g., use functions/classes).
  1. Separation of Concerns

    • Frontend (HTML/CSS/JS) vs. Backend (Python/Flask) vs. Database (SQL).


2. Key Equations (Mathematics/Networking)

ConceptEquationExample
Round-Trip Time (RTT)RTT = (2 * distance) / speed_of_lightdistance = 900 km → RTT = 6 ms
IPv4 to HexadecimalConvert each octet to hex172 → AC, 16 → 10, 254 → FE, 10 → 0A
CSS Specificity!important > ID > Class > Element#id { color: red; } overrides .class
Pytest Filteringpytest -m marker_nameRun tests with @pytest.mark.marker1
Flask Route Parameters@app.route('/path/<variable>')/user/<username> → def get_user(username)


Graph 2: Flask Workflow

Graph 3: Testing Pyramid

Graph 4: Git Workflow

Graph 5: HTTP Status Codes

Graph 6: CSS Specificity Hierarchy



4. Exam Tips

  1. URL Components: Memorize the structure (scheme, domain, path, query).
  2. Flask Routes: Practice writing routes with dynamic parameters (e.g., /user/<username>).
  3. Jinja2: Focus on loops ({% for %}), conditionals ({% if %}), and template inheritance.
  4. Testing: Understand pytest markers (-m), filtering (-k), and coverage types.
  5. Networking: Calculate RTT using distance and speed_of_light.
  6. Git: Know basic commands (config, add, commit, push).
  7. CSS: Remember specificity rules and pseudo-classes (:valid, :invalid).
  8. Debugging: Pay attention to sys.argv and decorator behavior.


Good luck! Let me know if you'd like a deeper dive into any topic.