MAD Study Hub

Home / Past papers / MAD1 End Term / this paper

IIT M DIPLOMA AN EXAM QDD4 13 Apr 2025 - 13 Apr 2025

MAD1 End Term32 questions100 marks24 MCQ · 8 MSQDiploma / afternoon / QDD4
Elapsed 00:00
Q1MCQ2 marks
A certain text document consisting of only alphanumeric characters (including spaces) takes 320000 bits, when encoded with UCS-2 encoding. How many bits will the same document take if encoded with ASCII 7-bit encoding?
  1. 20000 bits
  2. 1,40,000 bits
  3. 22,40,000 bits
  4. 320000 bits
Q2MCQ2 marks
Which of the following is true about the term “stateful” in the client-server model?
  1. The server keeps the state of the client to respond to the required request.
  2. Server is ready to respond to the client's request without knowing anythingabout the client.
  3. Server uses various HTTP methods to respond to the client's request.
  4. Server uses the URL to convey context to the client.
Q3MCQ2 marks
Consider the following git branches for a remote repository. question figure Consider the following git branches for a remote repository.
Text of the picture (copyable)
```
feature1
* feature2
main
```
Choose the correct git command sequence to merge *feature1* and *feature2* into the *main* branch.
  1. question figure
    text
    ```
    git merge feature1
    git merge feature2
    git merge main
    ```
  2. question figure
    text
    ```
    git checkout feature1
    git merge feature2
    git merge main
    ```
  3. question figure
    text
    ```
    git merge main
    git merge feature1
    git merge feature3
    ```
  4. question figure
    text
    ```
    git checkout main
    git merge feature1
    git merge feature2
    ```
Q4MCQ3 marks
The Quiz Master application at IITM BS allows students to attempt quizzes online. To prevent automated bots from mass-submitting quiz answers and ensure fair participation, the admin decides to implement a CAPTCHA verification system before allowing users to start a quiz. The admin decides to integrate Google reCAPTCHA into the Quiz Master app using Flask. Which Flask extension is best suited for implementing reCAPTCHA verification?
  1. Flask-Mail
  2. Flask-WTF
  3. Flask-SQLAlchemy
  4. Flask-Migrate
Q5MCQ3 marks
A mobile client starts from and is cruising away continuously at 120 kmph from the network tower whose network range is 80 km and bandwidth is 240 Mbps. How much data (in Gigabytes) will be consumed by the client who is continuously using the entire bandwidth before completely moving out of the network? [Take 1 Byte = 8 bits, 1 KB = 1000 Bytes, 1 MB = 1000 Kilobytes and so on.] [Consider the speed of light in air to be 3 x 10 8 m/sec.]
  1. 48
  2. 57.6
  3. 72
  4. 576
Q6MCQ3 marks
question figure
Text of the picture (copyable)
Consider the code below in a file called test_students.py

```python
test_students.py

import pytest

@pytest.fixture
def students():
    return { "names": ["ravi", "raj"], "ages": [12, 9]}

def test_name(students):
    assert "ravi" in students['names']

def test_age(students):
    assert students['ages'][0] > 9
```

Which of these is the correct output when the command "pytest -k name" is run in the terminal?
  1. question figure
    text
    ```
    ===== 1 passed, 1 deselected in 0.02s =====
    ```
  2. question figure
    text
    ```
    ======== 1 passed, 2 deselected in 0.02s ========
    ```
  3. question figure
    text
    ```text
    ======== 1 failed, 1 deselected in 0.02s ========
    ```
  4. question figure
    text
    ```
    ======== 1 failed, 2 deselected in 0.02s ========
    ```
Q7MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following models Department and Student corresponding to tables
department and student in SQLite database.

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

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

Based on the model schemas, what relationship do the classes Department and
Student 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 statements and choose the correct option Statement 1: It is always mandatory to implement server-side validations and client-side validations to create web applications. Statement 2: Server-side validations can be implemented using HTML5.
  1. Statement 1 is false, while statement 2 is true
  2. Statement 1 is true, while statement 2 is false
  3. Both statements are false
  4. Both statements are true
Q9MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following HTML code.

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Home page</title>
    <style>
        /* Missing CSS code */
    </style>
</head>
<body>
    <div id="mybox">
        IITM Online Degree
    </div>
</body>
</html>
```

Which of the following code should replace `/* Missing CSS code */` so that it renders the below output?

UI screenshot: A rectangular box with an orange background and a thin dark border. Inside the box, the text "IITM Online Degree" is displayed in a dark, bold font.
  1. question figure
    text
    ```css
    #mybox{
        width: 140px;
        height: 40px;
        background-color: orange;
        stroke: black;
    }
    ```
  2. question figure
    text
    ```css
    #mybox {
        width: 140px;
        height: 40px;
        background-color: orange;
        border-colour: 1px solid black;
    }
    ```
  3. question figure
    text
    ```css
    #mybox{
        width: 140px;
        height: 40px;
        background-color: orange;
        foreground-color: black;
    }
    ```
  4. question figure
    text
    ```css
    #mybox {
        width: 140px;
        height: 40px;
        background-color: orange;
        border:1px solid black;
    }
    ```
Q10MCQ3 marks
Consider the following example: question figure Consider the following example:
Text of the picture (copyable)
```html
<form>
    <label for="search-input">Search for a word:</label>
    <input
        type="text"
        id="search-input"
        placeholder="Type a word to search"
        aria-describedby="search-help"
        required
    />
    <small id="search-help">Enter a word to find relevant results.</small>
    <button type="submit">Start Search</button>
</form>
```
Which of the following accessibility principles is followed in this example?
  1. Perceivable
  2. Operable
  3. Robust
  4. Understandable
Q11MCQ3 marks
question figure
Text of the picture (copyable)
Let L = { 'a', 'b', 'c', 'd', 'A', 'B', 'C', 'D', '^', '*', '#', '!', '$' } be a complete character set (i.e., only these characters can be used to represent text in the document). If a document that uses fixed encoding with optimal number of bits for all characters is created using the character set L and has a disk size of 3 Kilobytes, the number of characters in the documents would be _____. [Take 1 Byte = 8 bits, 1 KB = 1000 Bytes, 1 MB = 1000 Kilobytes and so on.]
  1. 3000
  2. 9000
  3. 6000
  4. 12000
Q12MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following flask app. Given that test_request_context() allows text to be printed on the terminal, which of the following statements is correct?

```python
from flask import Flask, url_for

app = Flask(__name__)

@app.route('/hello')
def hello():
    return 'Hello World!'

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

with app.test_request_context():
    #== print statement ==#
```
  1. question figure
    text
    If `print statement` is replaced by `print(url_for('user', username='John'))`, the output on the terminal will be `/user?username=John`
  2. question figure
    text
    If `print statement` is replaced by `print(url_for('user', username='John', id='101'))`, the output on the terminal will be
    `/user/John/101`
  3. question figure
    text
    If `print statement` is replaced by `print(url_for('hello', username='John'))`,
    the output on the terminal will be `/hello?username=John`
  4. question figure
    text
    If `print statement` is replaced by `print(url_for('hello', username='John'))`, the output on the terminal will be Hello World!
Q13MCQ3 marks
Consider the following Python code. question figure Consider the following Python code.
Text of the picture (copyable)
File name: main.py

```python
def funA(func):
    def inner_wrapper():
        print("Wrapper function of funA")
        res1 = func()
        res2 = func()
        return res1, res2

    return inner_wrapper

@funA
def funB():
    return "I am from funB"

print(funB())
```

What will be the output, when running the above code using the command "python main.py"?
  1. question figure
    text
    ```
    ('I am from funB', 'I am from funB')
    Wrapper function of funA
    ```
  2. question figure
    text
    ```
    Wrapper function of funA
    I am from funB
    I am from funB
    ```
  3. question figure
    text
    ```
    wrapper function of funA
    ('I am from funB', 'I am from funB')
    ```
  4. question figure
    text
    I am from funB
    I am from funB
    Wrapper **function** of funA
Q14MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following Python code
File name: main_test.py
```python
import pytest

class TestGroup:

    def do_something(self, x, y):
        return x % y

    def test_one(self):
        assert self.do_something(10, 5) == 0, " Is 5 factor of 10? "

    def test_two(self):
        assert self.do_something(32, 5) == 0, " Is 5 factor of 32 "
```
What will be the output of running the above python script using command line
“pytest -v main_test.py”?
  1. question figure
    text
    ```
    ============ short test summary info ============
    main_test.py::TestGroup::test_one PASSED           [ 50%]
    main_test.py::TestGroup::test_two PASSED          [100%]
    
    ============ 2 passed in 0.02s ============
    ```
  2. question figure
    text
    ```
    ========== short test summary info ==========
    FAILED main_test.py::TestGroup::test_two - AssertionError: Is 5
    factor of 32
    ========== 1 failed, 1 passed in 0.12s ==========
    ```
  3. question figure
    text
    ```
    ======================== short test summary info ========================
    main_test.py::TestGroup::test_one FAILED                               [ 50%]
    main_test.py::TestGroup::test_two FAILED                              [100%]
    
    ========================== 2 failed in 0.02s===========================
    ```
  4. question figure
    text
    ```
    ============ short test summary info ============
    FAILED main_test.py::TestGroup::test_two - AssertionError: Is 5
    factor of 10
    FAILED main_test.py::TestGroup::test_two - AssertionError: Is 5
    factor of 32
    ========== 2 failed in 0.12s ============
    ```
Q15MCQ4.5 marks
Consider the schema for the Class Student. question figure Consider the schema for the Class Student.
Text of the picture (copyable)
```sql
CREATE TABLE "student" (
    "s_id"          INTEGER,
    "roll_number"   TEXT NOT NULL UNIQUE,
    "first_name"    TEXT NOT NULL,
    "last_name" TEXT NOT NULL,
    PRIMARY KEY("s_id" AUTOINCREMENT)
);
```

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

```python
>>> s1 = Student(roll_number = "M01", first_name = "John", last_name = "Dewis")
>>> db.session.add(s1)
>>> s2 = Student(roll_number = "M02", first_name = "John", last_name = "Nector")
>>> db.session.add(s2)
>>> s3 = Student(roll_number = "M03", first_name = "Nick", last_name = "Dewis")
>>> db.session.add(s3)
>>> db.session.commit()
>>> user1= Student.query.filter_by(first_name="John").first()
>>> user1.first_name= "Nick"
>>> db.session.commit()
>>> s1 = Student.query.all()
>>> for student in s1:
        print(student.first_name)
        print(student.last_name)
```
  1. question figure
    text
    John
    Dewis
    John
    Nector
    Nick
    Dewis
  2. question figure
    text
    ```
    John
    Dewis
    Nick
    Dewis
    Nick
    Dewis
    ```
  3. question figure
    text
    John
    Dewis
    Nick
    Nector
    Nick
    Dewis
  4. question figure
    text
    Nick
    Dewis
    John
    Nector
    Nick
    Dewis
Q16MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following flask application "app.py" given below.

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

app = Flask(__name__, static_folder = 'stationary')

@app.route('/')
def func():
    folder_1 = sys.argv[1]
    folder_2 = sys.argv[2]

    if app.static_folder == folder_1:
        return f"<h1>Static folder verified: {folder_1}</h1>"

    if app.static_folder == folder_2:
        return f"<h1>Static folder verified: {folder_2}</h1>"

    return "<h1>Invalid argument</h1>"

app.run(debug = True)
```

If the application is running locally on `http://127.0.0.1:5000`. What will be rendered by the browser for the command:
`python app.py /static /stationary`
  1. question figure
    text
    Static folder verified: /static
  2. question figure
    text
    Static folder verified: /stationary
  3. question figure
    text
    Invalid argument
  4. question figure
    text
    None of these
Q17MCQ4.5 marks
question figure
Text of the picture (copyable)
You are given a project with three files: `conftest.py`, `test_multiples_of_3_and_6.py`, and `test_multiples_of_13.py`. The purpose of the tests is to verify if numbers generated by each function are divisible by 39. However, there is a setup issue in this project.

* `conftest.py` contains a fixture that provides test data.
* `test_multiples_of_3_and_6.py` has two functions: one checks divisibility by 3, and the other by 6.
* `test_multiples_of_13.py` contains a function to check divisibility by 13.

Here is the content of each file:

`conftest.py`
```python
import pytest

@pytest.fixture
def divisible_by_39():
    return 39 # Fixture providing the number to be tested
```

`test_multiples_of_3_and_6.py`
```python
import pytest

def test_divisible_by_3(divisible_by_39):
    assert divisible_by_39 % 3 == 0 # Checks if divisible by 3

def test_divisible_by_6(divisible_by_39):
    assert divisible_by_39 % 6 == 0 # Checks if divisible by 6
```

`test_multiples_of_13.py`
```python
import pytest

def test_divisible_by_13(divisible_by_39):
    assert divisible_by_39 % 13 == 0 # Checks if divisible by 13
```

When you run `pytest -k divisible`, which of the following is **true**?
  1. question figure
    text
    ```
    ========== 1 failed, 2 passed in 0.06s ==========
    ```
  2. question figure
    text
    ```text
    =========== 3 errors in 0.02s ===========
    ```
  3. question figure
    text
    ```
    ========== 1 passed in 0.02s ==========
    ```
  4. question figure
    text
    ```
    ========== 3 passed in 0.02s ==========
    ```
Q18MCQ4.5 marks
A client machine and a server machine located 120 kilometers apart start moving towards each other along a straight line at 400 kmph and 800 kmph respectively. At the same time, the client starts sending requests to the server and the server sends back the response to the client. This client-server network continues to send requests and receive responses (with a new request being sent only after the response is received by the client for the previous one) until both the server and the client collide with each other. Calculate the total distance travelled (in kms) by the request data and the response data together before the two machines collide with each other?(assume the speed of request and response to be 3 x 108m/s )
  1. question figure
    text
    54 x 10^6
  2. question figure
    text
    216 x 10⁶
  3. question figure
    text
    90 x 10⁶
  4. question figure
    text
    108 x 10⁶
Q19MSQ2 marksselect all that apply
Which of the following are benefits of using the MVC (Model-View-Controller) architecture?
  1. MVC allows for the implementation of multiple views of the same dataconcurrently.
  2. MVC supports parallel development, enabling developers to work on differentparts of the application simultaneously.
  3. MVC enforces the use of View State, increasing the bandwidth of requests.
  4. MVC is a heavyweight framework that requires significant bandwidth due toits design.
Q20MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following Python code.

```python
from string import Template

output = "List of courses in IITM BS Diploma : $c1, $c2, $c3, $c4, $c5"
my_template = Template(output)
==Missing code here===
```

Which of the following statement(s) should replace ==Missing code here=== so that it prints the output without any KeyError exception?
  1. question figure
    text
    ```python
    print(my_template.safe_substitute({
        "c1": "PDSA", "c2": "DBMS", "c3": "App Dev-I",
        "c4": "App Dev-II", "c5": "Java",}))
    ```
  2. question figure
    text
    ```python
    print(my_template.substitute({
        "c1": "PDSA", "c2": "DBMS", "c3": "App Dev-I",
        "c4": "App Dev-II", "c5": "Java",}))
    ```
  3. question figure
    text
    ```python
    print(my_template.substitute({
        "c4": "App Dev-II", "c5": "Java", "c1": "PDSA",
        "c2": "DBMS", "c3": "App Dev-I",}))
    ```
  4. question figure
    text
    ```python
    print(my_template.safe_substitute({
        "c1": "PDSA", "c3": "App Dev-I",
        "c5": "Java",}))
    ```
  5. question figure
    text
    ```python
    print(my_template.substitute({
        "c4": "App Dev-II", "c1": "PDSA",
        "c2": "DBMS", "c3": "App Dev-I",}))
    ```
Q21MSQ3 marksselect all that apply
Which of the following statements about server architectures, Apache and Nginx, is/are correct?
  1. Apache is better suited for handling a large volume of concurrent connectionsthan Nginx.
  2. Apache is versatile and supports a wide range of modules and dynamicconfigurations.
  3. Nginx is generally faster for serving static files and handling high traffic withlow memory usage.
  4. Both Apache and Nginx are open-source web servers.
Q22MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following route in the flask for a signup page and select the correct option:

```python
@app.route('/signup', methods=['GET', 'POST'])
def signup():
    if request.method == 'GET':
        return """<form action='/signup' method='POST'>
            <label for='username'>Username</label>
            <input type='text' name='username' required>
            <label for='password'>Password</label>
            <input type='text' name='password' required minlength="8">
            <input type='submit' value='Submit'>
        </form>
        """

    if request.method == 'POST':
        if request.form.get('username') is None:
            return redirect(url_for(signup))
        if request.form.get('password') is None:
            return redirect(url_for(signup))
        if len(request.form.get('password')) < 8:
            return redirect(url_for(signup))
        return f"<h1>Welcome, {request.form.get('username')}!</h1>"
```
  1. The signup page is dynamically generated.
  2. The signup page uses server-side rendering.
  3. The signup page uses frontend validation.
  4. The signup page uses backend validation.
Q23MSQ3 marksselect all that apply
Consider the following HTML code. question figure Consider the following HTML code.
Text of the picture (copyable)
File name: home.html

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Home page</title>
    <script>
        //Missing JS code
    </script>
</head>
<body>
    <form>
        Your name : <input type="text" id="txt1" value="Welcome to IITM Online BS Degree" size="35">
        <br>
        <input type="button" onclick="doSomething()" value="Click me!">
    </form>
</body>
</html>
```

If the user clicks on the “**Click me!**” button, then which of the following JS codes should be added in the `<script>` tag that will bold the content of `<input>` tag as given in the image below?

UI screenshot:
- Label: Your name :
- Input field: Welcome to IITM Online BS Degree (text is bolded)
- Button: Click me!
  1. question figure
    text
    ```javascript
    function doSomething(){
        txt1=document.getElementById("txt1");
        txt1.style="bold";
    }
    ```
  2. question figure
    text
    ```javascript
    function doSomething(){
        document.getElementById("txt1").style="bold";
    }
    ```
  3. question figure
    text
    ```javascript
    function doSomething(){
        txt1=document.getElementById("txt1");
        txt1.style.fontWeight="bold";
    }
    ```
  4. question figure
    text
    ```javascript
    function doSomething(){
        document.getElementById("txt1").style.fontWeight="bold";
    }
    ```
Q24MSQ4.5 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following Flask app code.

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

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

class MyApiResource(Resource):
    def get(self):
        return {"response": "GET"}, 200

    def post(self, value):
        return {"response": "POST", "value": value}, 200

api.add_resource(MyApiResource, "/", "/<int:value>")

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

The above flask app is running on "http://127.0.0.1:5000". Which of the following commands will return a runtime error?
  1. question figure
    text
    ```
    curl http://127.0.0.1:5000/1025 -X GET
    ```
  2. question figure
    text
    ```
    curl http://127.0.0.1:5000/1025 -X POST
    ```
  3. question figure
    text
    ```
    curl http://127.0.0.1:5000/ -X POST
    ```
  4. question figure
    text
    ```
    curl http://127.0.0.1:5000/ -x GET
    ```
Q25MSQ4.5 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following Jinja2 templating code:

```python
from jinja2 import Template

template_str = """
{% set gifts = [
    {'name': 'Teddy Bear', 'price': 250, 'rating': 4.2},
    {'name': 'Coffee Mug', 'price': 150, 'rating': 4.5},
    {'name': 'Keychain', 'price': 100, 'rating': 3.9},
    {'name': 'Notebook', 'price': 180, 'rating': 4.7},
    {'name': 'Wall Clock', 'price': 300, 'rating': 4.0}
] %}

<ul>
{% for gift in gifts if gift.price < 200 and gift.rating > 4 %}
    <li>{{ gift.name }} - {{ gift.price }} - {{ gift.rating }}</li>
{% endfor %}
</ul>
"""

template = Template(template_str)
rendered_str = template.render()
print(rendered_str)
```

Will the above Jinja templating code return the correct output? If yes, what will be the result?
  1. question figure
    text
    The template will not work correctly because the **for** loop condition (if `gift.price < 200` and `gift.rating > 4`) is invalid in Jinja2 syntax. This will raise a `TemplateSyntaxError`.
  2. question figure
    text
    The template will work correctly, but the output will include all gifts, not filtering by price and rating, as the condition inside the for loop will be ignored.
  3. question figure
    text
    The template will work correctly, and the output will be:
    
    ```html
    <ul>
      <li>Coffee Mug - 150 - 4.5</li>
      <li>Notebook - 180 - 4.7</li>
    </ul>
    ```
  4. question figure
    text
    The template will work correctly, and the output will be:
    ```html
    <ul>
        <li>Teddy Bear - 250 - 4.2</li>
        <li>Wall Clock - 300 - 4.0</li>
    </ul>
    ```
Q26MSQ4.5 marksselect all that apply
question figure
Text of the picture (copyable)
The following Flask-RESTful API code snippet is intended to create a RESTful API for managing student registrations in an IITM BS degree program. However, there is an error in the code that prevents it from functioning correctly.

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

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

students = []

class Student(Resource):
    def get(self, student_id):
        for student in students:
            if student["id"] == student_id:
                return jsonify(student)
        return jsonify({"message": "Student not found"}), 404

    def post(self):
        data = request.get_json()
        new_student = {
            "id": data["id"],
            "name": data["name"]
        }
        students.append(new_student)
        return jsonify({"message": "Student added successfully"})

api.add_resource(Student, "/student/<int:student_id>")

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

Error:
When trying to use the POST method to add a student, it throws a TypeError stating that the route does not match the method. Identify the correct option to fix the error in the code.
  1. question figure
    text
    Replace the **post** method with the following route in the Student class:
    
    ```python
    def post(self):
        data = request.get_json()
        new_student = {
            "id": len(students) + 1,
            "name": data["name"]
        }
        students.append(new_student)
        return jsonify({"message": "Student added successfully"}), 201
    ```
  2. question figure
    text
    Change the api.add_resource(Student, "/student/<int:student_id>") to:
    api.add_resource(Student, "/students")
  3. question figure
    text
    Change the api.add_resource(Student, "/student/<int:student_id>") to:
    ```
    api.add_resource(Student, "/student", "/student/<int:student_id>")
    ```
  4. question figure
    text
    Add the student_id parameter to the **post** method in the Student class as **def**
    ```
    post(self, student_id):
    ```
Comprehension passage - the questions below it refer to this
Based on the above data, answer the given subquestions. question figure
Q27MCQ2 marks
Which type of relationship best represents the association between students and hostels in the given scenario?
  1. One-to-One
  2. One-to-Many
  3. Many-to-One
  4. Many-to-Many
Q28MCQ3 marks
Which SQLAlchemy relationship should be used to model the many-to-many relationship between students and events in the Paradox ?
  1. question figure
    text
    ```python
    db.relationship('Event', backref='students')
    ```
    in the Student model
  2. question figure
    text
    ```python
    db.relationship('Student', back_populates='events')
    ```
    in the Event model
  3. question figure
    text
    Using an association table between
    students and events
  4. question figure
    text
    Creating a foreign key inside the
    Student model referring to Event
Comprehension passage - the questions below it refer to this
The students of IITM BS challenged their instructors to a cricket match. A Flask web application is built to track the scores. Below is the Flask app code that defines multiple routes for fetching scores dynamically. question figure The students of IITM BS challenged their instructors to a cricket match. A Flask web application is built to track the scores. Below is the Flask app code that defines multiple routes for fetching scores dynamically. Based on the above data, answer the given subquestions.
Q29MCQ2 marks
What will be the output when the following URL is accessed? question figure What will be the output when the following URL is accessed?
Text of the picture (copyable)
http://127.0.0.1:5000/score/students
  1. Score: students
  2. Students Score: 120
  3. None of these
  4. Team not found
Q30MCQ4.5 marks
What will happen if we access the following URL? question figure What will happen if we access the following URL?
Text of the picture (copyable)
```
http://127.0.0.1:5000/score/instructors/Dr.Prashant
```
  1. Dr.Prashant (Instructors) Scored: 40
  2. Player not found
  3. Internal Server Error
  4. Dr.Prashant (Instructors) Scored: Player not found
Comprehension passage - the questions below it refer to this
A college counseling system is designed to store and retrieve student records efficiently. The system uses different types of storage based on latency, throughput, and density. During peak counseling sessions, thousands of students access their academic records, appointment schedules, and previous counseling notes. The system needs to optimize storage selection for different types of data: 1. Frequently accessed small data (e.g., currently active student records) 2. Large archives of past counseling records (rarely accessed but need long-term storage) 3. Temporary session data that needs to be quickly read and updated during counseling sessions Based on the above data, answer the given subquestions.
Q31MCQ2 marks
Which of the following storage types should be used for storing frequently accessed small student records that need low latency and high-speed access?
  1. Hard Disk Drive (HDD)
  2. Solid State Drive (SSD)
  3. Registers
  4. Static RAM (SRAM)
Q32MCQ2 marks
The college wants to store archived counseling records from past students for future reference. These records are rarely accessed, but cost efficiency and storage density are important. Which storage type is best suited?
  1. Registers
  2. SRAM
  3. Hard Disk Drive (HDD)
  4. DRAM

Answer key

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

Concepts this paper tests

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

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



1. Core Topics & Concepts

A. Encoding and Data Representation

Key Concepts:

  1. Character Encoding Schemes:

    • ASCII: 7-bit encoding (128 characters), 8-bit extended ASCII (256 characters).
    • UCS-2: 2-byte (16-bit) fixed-width encoding for Unicode (supports 65,536 characters).
    • UTF-8: Variable-width encoding (1-4 bytes per character).
    • Optimal Bit Calculation:

      • For a character set of size N, optimal bits = ⌈log₂N⌉.
      • Example: For L = 13 characters, optimal bits = ⌈log₂13⌉ = 4.
  1. Data Storage Calculations:

    • Bit ↔ Byte ↔ Kilobyte ↔ Megabyte:

      • 1 Byte = 8 bits
      • 1 KB = 1000 Bytes (decimal) or 1024 Bytes (binary, KiB).
      • Example: 320,000 bits = 320,000 / 8 = 40,000 Bytes = 40 KB.
    • Conversion Between Encodings:

      • UCS-2 (2 bytes/char) → ASCII (1 byte/char): Size halves if all characters fit in ASCII.
      • Example: 320,000 bits in UCS-2 = 320,000 / 16 = 20,000 characters.
      • ASCII size = 20,000 characters * 7 bits = 140,000 bits.

Equations:


B. Client-Server Model

Key Concepts:

  1. Stateless vs. Stateful:

    • Stateless: Server treats each request as independent (e.g., HTTP).
    • Stateful: Server retains client state across requests (e.g., sessions, WebSockets).
  2. HTTP Methods:

    • GET, POST, PUT, DELETE, etc.
  3. CAPTCHA:

    • Used to distinguish humans from bots (e.g., Google reCAPTCHA).
    • Flask-WTF: Extension for form handling and CAPTCHA integration in Flask.

Flask Extensions:

ExtensionPurpose
Flask-WTFForm handling + CAPTCHA
Flask-MailEmail sending
Flask-SQLAlchemyDatabase ORM
Flask-MigrateDatabase migrations

C. Version Control (Git)

Key Concepts:

  1. Branching and Merging:

    • git checkout <branch>: Switch branches.
    • git merge <branch>: Merge branches into current branch.
    • Example:

      git checkout main
      git merge feature1
      git merge feature2
  2. Common Commands:

    • git add, git commit, git push, git pull.

D. Web Development

Key Concepts:

  1. Flask:

    • Microframework for Python.
    • Routing: @app.route('/path').
    • Templates: Jinja2 for dynamic HTML.
    • Request Context: test_request_context() for testing URLs (e.g., url_for).
  2. Jinja2 Templating:

    • Syntax: {{ variable }}, {% logic %}.
    • Example:

      {% for item in items if item.price < 200 %}
        {{ item.name }}
      {% endfor %}
  3. Flask-RESTful:

    • For building REST APIs.
    • Example:

      class MyResource(Resource):
          def get(self):
              return {"data": "value"}
      api.add_resource(MyResource, '/')
  4. SQLAlchemy ORM:

    • Relationships:

      • One-to-Many: db.ForeignKey.
      • Many-to-Many: Association table.
    • Example:

      class Student(db.Model):
          id = db.Column(db.Integer, primary_key=True)
          name = db.Column(db.String)
          department_id = db.Column(db.Integer, db.ForeignKey('department.id'))

Database Relationships:

TypeDescriptionSQLAlchemy Syntax
One-to-ManyOne department → Many studentsdb.ForeignKey('department.id')
Many-to-OneMany students → One departmentSame as above
Many-to-ManyStudents ↔ EventsAssociation table with foreign keys

E. Testing (Pytest)

Key Concepts:

  1. Fixtures:

    • Reusable test data (e.g., @pytest.fixture).
    • Example:

      @pytest.fixture
      def students():
          return {"names": ["Alice", "Bob"]}
  2. Assertions:

    • assert condition, "message".
  3. Filtering Tests:

    • pytest -k "name": Run tests with "name" in their name.
    • pytest -v: Verbose output.
  4. Test Outcomes:

    • PASSED, FAILED, DESELECTED (filtered out).

Example Outputs:


F. Networking and Data Transfer

Key Concepts:

  1. Bandwidth vs. Range:

    • Bandwidth: Data transfer rate (e.g., 240 Mbps).
    • Range: Coverage area (e.g., 80 km for a tower).
  2. Data Consumption:

    • Total Data = Bandwidth × Time in range.
    • Example:

      • Client moves at 120 km/h away from a tower with 80 km range.
      • Time in range = 80 km / 120 km/h = 2/3 hours = 40 minutes.
      • Data = 240 Mbps × 40 × 60 seconds = 576,000 Mb = 72 GB.
  3. Latency and Speed of Light:

    • Time for data to travel = Distance / Speed of light.
    • Example: 120 km / (3 × 10⁸ m/s) ≈ 0.4 ms (negligible for most calculations).

Equations:


G. Accessibility and HTML/CSS

Key Concepts:

  1. ARIA Attributes:

    • aria-describedby: Links input to descriptive text.
  2. Semantic HTML:

    • <label>, <input>, <button> for accessibility.
  3. CSS Styling:

    • Example: Bold text in input:

      document.getElementById("txt1").style.fontWeight = "bold";
  4. WCAG Principles:

    • Perceivable, Operable, Understandable, Robust (POUR).

H. MVC Architecture

Key Concepts:

  1. Model-View-Controller:

    • Model: Data logic (e.g., database).
    • View: UI (e.g., HTML templates).
    • Controller: Business logic (e.g., Flask routes).
  2. Benefits:

    • Separation of concerns.
    • Parallel development.
    • Multiple views for the same data.

I. Storage Hierarchy

Key Concepts:

Storage TypeLatencyUse Case
Registers~1 nsCPU operations
SRAM~10 nsCache, fast access
DRAM~100 nsMain memory (RAM)
SSD~100 µsFast storage (e.g., databases)
HDD~10 msLong-term storage (archives)

Choosing Storage:


J. Web Servers (Apache vs. Nginx)

FeatureApacheNginx
ConcurrencyProcess/thread-basedEvent-driven (better for high concurrency)
Static FilesSlowerFaster
Dynamic ContentModular (e.g., .htaccess)Reverse proxy (e.g., FastCGI)
Use CaseTraditional LAMP stackHigh-traffic, microservices

K. Decorators in Python

Key Concepts:


L. RESTful APIs

Key Concepts:

  1. HTTP Methods:

    • GET: Retrieve data.
    • POST: Create data.
    • PUT: Update data.
    • DELETE: Delete data.
  2. Flask-RESTful:

    • Define resources with GET, POST, etc.
    • Example:

      class User(Resource):
          def get(self, user_id):
              return {"user": user_id}
      api.add_resource(User, '/user/<int:user_id>')
  3. Error Handling:

    • 404: Not found.
    • 500: Server error.

Graph 2: Client-Server Model

Graph 3: Git Workflow

Graph 4: Flask and Web Development

Graph 5: Testing with Pytest

Graph 6: Networking and Data Transfer

Graph 7: Storage Hierarchy

Graph 8: MVC Architecture

Graph 9: Apache vs. Nginx

Graph 10: RESTful APIs


3. Key Equations Summary

TopicEquation
Optimal bits for encoding\(\text{Bits} = \lceil \log_2(\text{Number of characters}) \rceil\)
Total bits for a document\(\text{Total bits} = \text{Characters} \times \text{Bits per char}\)
UCS-2 to ASCII conversion\(\text{ASCII size} = \text{UCS-2 size} \times \frac{7}{16}\)
Time in network range\(\text{Time} = \frac{\text{Range}}{\text{Speed}}\)
Data consumed\(\text{Data (bits)} = \text{Bandwidth (bps)} \times \text{Time (s)}\)
Data in GB\(\text{Data (GB)} = \frac{\text{Data (bits)}}{8 \times 10^9}\)

4. Exam Tips

  1. Encoding:

    • Remember the difference between ASCII (7/8-bit) and UCS-2 (16-bit).
    • Calculate optimal bits using \(\log_2\).
  2. Flask:

    • Know how to use url_for, test_request_context, and Jinja2 templates.
    • Understand RESTful routes and SQLAlchemy relationships.
  3. Git:

    • Practice branching and merging commands.
  4. Networking:

    • Bandwidth × Time = Data.
    • Speed of light is usually negligible in such problems.
  5. Testing:

    • Pytest fixtures and assertions are key.
    • -k filters tests by name.
  6. Storage:

    • SRAM > DRAM > SSD > HDD in terms of speed.
  7. Accessibility:

    • Use semantic HTML and ARIA attributes.
  8. MVC:

    • Separation of concerns is the core idea.