MAD Study Hub

Home / Past papers / MAD1 End Term / this paper

IIT M FOUNDATION DIPLOMA ENDTERM QPD1 07 Aug 2022 - 07 Aug 2022

MAD1 End Term33 questions100 marks26 MCQ · 6 MSQ · 1 SAFoundation / Diploma / QPD1
Elapsed 00:00
Q1MCQ0 marks
question figure
Text of the picture (copyable)
THIS IS QUESTION PAPER FOR THE SUBJECT "DIPLOMA LEVEL: MODERN APPLICATION DEVELOPMENT 1"

ARE YOU SURE YOU HAVE TO WRITE EXAM FOR THIS SUBJECT?
CROSS CHECK YOUR HALL TICKET TO CONFIRM THE SUBJECTS TO BE WRITTEN.

(IF IT IS NOT THE CORRECT SUBJECT, PLS CHECK THE SECTION AT THE TOP FOR THE SUBJECTS REGISTERED BY YOU)
  1. Yes
  2. No
Q2MCQ2 marks
Which of the following correctly represents the components of the given URL? question figure Which of the following correctly represents the components of the given URL?
Text of the picture (copyable)
```
https://www.mywebsite.com/home?user=Mad1&key=madcs2003
```
  1. question figure
    text
    ```
    https : Domain name;
    www.mywebsite.com : Request parameter;
    /home : Directory;
    user=Mad1&key=madcs2003 : domain name
    ```
  2. question figure
    text
    ```
    https : Protocol;
    www.mywebsite.com : Directory;
    /home : Domain name;
    user=Mad1&key=madcs2003 : Request parameters
    ```
  3. question figure
    text
    ```
    https : Protocol;
    www.mywebsite.com : Domain name;
    /home : Directory;
    user=Mad1&key=madcs2003 : Request parameters
    ```
  4. question figure
    text
    ```
    https : IP Address;
    www.mywebsite.com : Domain name;
    /home : Directory;
    user=Mad1&key=madcs2003 : Local Host
    ```
Q3MCQ2 marks
Consider the following flask app and an HTML file in templates folder: question figure Consider the following flask app and an HTML file in templates folder: question figure Consider the following flask app and an HTML file in templates folder:
Text of the picture (copyable)
Python file: app.py

```python
from flask import Flask, render_template
app = Flask(__name__)

my_list = ['Web development', 'onlinedegree', 'cs2003',
           'MAD-I', 'Data_science']

@app.route('/')
def render():
    return render_template('index.html', my_list = my_list)

app.run(debug = True)
```
Template file:

```html
<!DOCTYPE html>
<head>
    <style>
        body{width: 200px;
            border: 2px solid black}
        #one{color:red;}
        #two{color:blue;}
    </style>
</head>
<body>
    {% for item in my_list %}
        {% set Length = item|length %}
        {% if Length%2 == 0 %}
            <h3 id = "one">{{ item }}</h3>
        {% else %}
            <h3 id = "two">{{ item }}</h3>
        {% endif %}
    {% endfor %}
</body>
```

If the above flask app is running locally on http://127.0.0.1:5000/, what will be rendered by the browser for the base URL?
  1. question figure
    text
    Web development
    onlinedegree
    cs2003
    MAD-I
    Data_science
  2. question figure
    text
    Web development
    onlinedegree
    cs2003
    MAD-I
    Data_science
  3. question figure
    text
    Web development
    onlinedegree
    cs2003
    MAD-I
    Data_science
  4. question figure
    text
    Web development
    onlinedegree
    cs2003
    MAD-I
    Data_science
Q4MCQ2 marks
Consider the flask code given below. question figure Consider the flask code given below. Which of the following code snippets must be added in the given space of above application, in order to create a new shop in ‘my_shops’ list on the server side apart from the existing one?
Text of the picture (copyable)
Python file: app.py
```python
from flask import Flask, jsonify, request

app = Flask(__name__)

my_shops= [
    {
        'name of the shop' : 'Grocery',
        'items' : [
            {
                'item1' : 'Toothpaste',
                'item2' : 'Snacks',
                'item3' : 'Biscuits',
                'item4' : 'Soaps'
            }
        ]
    }
]

@app.route('/')
def show_shop():
    return jsonify({"shops" : my_shops})

#===========================
#        CODE HERE
#===========================

if __name__ == '__main__':
    app.run()
```
  1. question figure
    text
    ```python
    @app.route('/myshop')
    def create_shop():
        new_data = request.get_json()
        new_shop = [
            {
                'New shop' : new_data['name of the shop']
            }
        ]
        my_shops[new_shop]
        return jsonify(new_shop)
    ```
  2. question figure
    text
    ```python
    @app.route('/myshop', methods=['POST'])
    def create_shop():
        new_data = request.get_json()
        new_shop = {
            'New shop' : new_data['name of the shop']
        }
        my_shops.append(new_shop)
        return jsonify(new_shop)
    ```
  3. question figure
    text
    ```python
    @app.route('/myshop', methods=['POST'])
    def create_shop():
        new_data = request.get_json()
        new_shop = {
            'New shop' : new_data['name of the shop']
        }
        return jsonify(new_shop)
    ```
  4. question figure
    text
    All of these
Q5MCQ2 marks
A table ‘person’ is created in the database using model class “Person” with fields and their properties given in the table below. question figure A table ‘person’ is created in the database using model class “Person” with fields and their properties given in the table below.
Text of the picture (copyable)
| id | firstname | lastname | email | age | occupation |
|---|---|---|---|---|---|
| 1 | Rahul | Mishra | rahul@gmail.com | 23 | Engineer |
| 2 | Ishan | Vadhera | vadhera@gmail.com | 35 | Lawyer |
| 3 | Abhilasha | Verma | vermaa@gmail.com | 25 | Teacher |

Assuming that flask_sqlalchemy is to be used in the 'main.py' file, which of the following statements is/are true?
  1. question figure
    text
    Both the queries i.e.,
    ```
    Person.query.filter_by(firstname="Ishan").all() and
    Person.query.filter_by(firstname="Ishan").first() will produce the
    same result.
    ```
  2. question figure
    text
    Both the queries i.e.,
    ```
    Person.query.filter_by(id=3).first() and
    Person.query.get(3) will produce the same result.
    ```
  3. question figure
    text
    If person1 = Person.query.get(1) then, Both the inputs i.e.,
    ```
    >>>person1
    >>>person1.firstname
    ```
    will produce the same result.
  4. question figure
    text
    Both the queries i.e.,
    ```
    Person.query.filter_by(firstname="Ishan").first(), and
    Person.query.get(3)
    ```
    will produce the same result
Q6MCQ2 marks
A flask app and a template files are given below. question figure A flask app and a template files are given below. If the above flask application is running locally on “http://127.0.0.1:5000”, which of the following statement is true?
Text of the picture (copyable)
Python file: app.py
```python
from flask import Flask, render_template
app = Flask(__name__)

@app.route('/home')
def HomePage():
    return "Welcome, folks! This is the Home Page!"

@app.route('/about')
def AboutPage():
    users = [
        {"user":"Shobhit","gender" : "Male", "age" : 23, "score": 90},
        {"user":"Deepak", "gender" : "Male", "age" : 17, "score": 88},
        {"user":"Nikita", "gender" : "Female", "age" : 20, "score": 87}
    ]
    return render_template('home.html', condition=True, users=users)

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

Templates file: home.html
```html
<!DOCTYPE html>
<html>
<body>
<p><a href="{{ url_for('HomePage') }}">Go back to home page?</a></p>
<h2>About page</h2>
{% if condition %}
    <h3>You are landed on about page.</h3>
    {% for user in users %}
    <ul>
        <li>Username : {{user.user}}, Age : {{user.age}}, Gender : {{user.gender}}, Score : {{user.score}}</li>
    </ul>
    {% endfor %}
{% else %}
    <h3> Please Go back.</h3>
{% endif %}
</body>
</html>
```
  1. question figure
    text
    For URL: "http://127.0.0.1:5000/home", the rendered output will be "Welcome, folks! This is the Home Page!"
  2. question figure
    text
    For URL: "http://127.0.0.1:5000/about", the rendered output will be:
    Go back to home page?
    
    **About page**
    
    **You are landed on about page.**
    
    * Username : Shobhit, Age : 23, Gender : Male, Score : 90
    * Username : Deepak, Age : 17, Gender : Male, Score : 88
    * Username : Nikita, Age : 20, Gender : Female, Score : 87
  3. question figure
    text
    For URL: "http://127.0.0.1:5000/about", the rendered output will be:
    
    Go back to home page?
    
    **About page**
    
    **You are landed on about page.**
    
    * Username : Shobhit
    * Age : 23
    * Gender : Male
    * Score : 90
    
    * Username : Deepak
    * Age : 17
    * Gender : Male
    * Score : 88
    
    * Username : Nikita
    * Age : 20
    * Gender : Female
    * Score : 87
  4. question figure
    text
    For URL: "http://127.0.0.1:5000/about", the rendered ouptut will be:
    Go back to home page?
    
    About page
    
    You are landed on about page.
    
    Username : Shobhit
    Age : 23
    Gender : Male
    Score : 90
    
    Username : Deepak
    Age : 17
    Gender : Male
    Score : 88
    
    Username : Nikita
    Age : 20
    Gender : Female
    Score : 87
Q7MCQ2 marks
An HTML document is given below. question figure An HTML document is given below. Suppose, if we want to give red color to the text within the heading element having id="id1” and green color to the text within the heading element having class="class1”, what will be the correct way to do that?
Text of the picture (copyable)
```html
<!DOCTYPE html>
<html>
<body>
    <h1 id="id1">Welcome to IITM</h1>
    <h3 class="class1">Welcome to the world's first online degree program.</h3>
    <a href="">Go back to main link</a>
    <p class="class1">Lorem ipsum dolor sit amet consectetur adipisicing elit. Earum, rerum?</p>
    <p class="class1">Have you enrolled in BSc in Data science and Programming?</p>
    <p id="id2">Go to the IITM online degree website and enroll now!</p>
</body>
</html>
```
  1. question figure
    text
    By using external CSS as follows:
    
    ```css
    #id1{
        color:green;
    }
    h3.class1{
        color:red;
    }
    ```
  2. question figure
    text
    By using internal CSS as follows:
    
    ```html
    <style>
        .id1{
            color:red;
        }
        p.class1{
            color:green;
        }
    </style>
    ```
  3. question figure
    text
    By using inline CSS as follows:
    ```html
    <h1 id="id1" style="color:red;">Welcome to IITM</h1>
    <h3 class="class1" style="color:green;">Welcome to the world's
    first online degree program.</h3>
    ```
  4. question figure
    text
    All of these
Q8MCQ2 marks
Consider the following HTML document with internal CSS. question figure Consider the following HTML document with internal CSS. How will the browser render the above HTML document?
Text of the picture (copyable)
```html
<!DOCTYPE html>
<html>
<head>
    <style type="text/css">
        *{
            margin: 0px;
            width: 253px;
        }
        div{
            margin: 10px;
            padding: 20px;
            border-style: dotted;
            border-width: 10px;
            font-size: 30px;
            color: blue;
            background-color: pink;
            border-color: red;
        }
    </style>
    <title>End Sem</title>
</head>
<body>
    <div>This is my content</div>
    <div>Another content</div>
</body>
</html>
```
  1. question figure
    text
    This is a UI screenshot showing two rectangular boxes stacked vertically.
    
    The top box has a blue border and a light red background. Inside, it contains the text "This is my content" in red font.
    
    The bottom box also has a blue border and a light red background. Inside, it contains the text "Another content" in red font.
  2. question figure
    text
    This is a screenshot of two rectangular boxes, one above the other, with a dotted blue border and a light pink background.
    
    The top box contains the text:
    This is my content
    
    The bottom box contains the text:
    Another content
  3. question figure
    text
    This is my content
    Another content
  4. question figure
    text
    This is a UI screenshot showing two rectangular boxes, one above the other.
    Each box has a light pink background and a red dotted border.
    The top box contains the text "This is my content" in blue.
    The bottom box contains the text "Another content" in blue.
Q9MSQ2 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following table "workers" created in SQLite database corresponding to model class "Workers" using flask_sqlalchemy.

| Id | Name | Designation | Gender | Salary |
|---|---|---|---|---|
| Filter | Filter | Filter | Filter | Filter |
| 1 | Padma Raja | Supervisor | Female | 2000 |
| 2 | Sameer Gandhi | Labour | Male | 1200 |
| 3 | Latika Murthy | Labour | Female | 800 |
| 4 | Nitya Grover | Supervisor | Female | 2000 |
| 5 | Amit Saxena | Supervisor | Male | 2000 |

The correct way to increase the salary of all the female workers by 500 Rupees using the Python console is:
  1. question figure
    text
    ```python
    >>> workers = Workers.query.filter_by(Designation = 
    'Supervisor').all()
    >>> for worker in workers:
    ...     worker.Salary += 500
    ... 
    >>> db.session.commit()
    ```
  2. question figure
    text
    ```python
    >>> workers = Workers.query.filter_by(Gender = 'Female').all()
    >>> workers.Salary += 500
    >>> db.session.commit()
    ```
  3. question figure
    text
    ```python
    >>> workers = Workers.query.filter_by(Gender = 'Female').all()
    >>> for worker in workers:
    ...     worker.Salary += 500
    ... 
    >>> db.session.commit()
    ```
  4. question figure
    text
    ```python
    >>> workers = Workers.query.filter(Workers.Gender.like('F%')).all()
    >>> for worker in workers:
    ...     worker.Salary += 500
    ... 
    >>> db.session.commit()
    ```
Q10MCQ3 marks
How will the browser render the output of the following Python code snippet? question figure How will the browser render the output of the following Python code snippet?
Text of the picture (copyable)
```python
from jinja2 import Template

styles=[
    '.text{color: purple}\n #heading{color:red}\n #subhead{color:blue}',
    '.text{color: purple}\n #subhead{color:green}\n #main{color:blue}',
    '.text{color: purple}\n #main{color:red}\n #heading{color:blue}'
]

template = """
<!DOCTYPE html>
<style>
    div{border: 2px solid black;
        width: 300px;
        background-color: rgb(247, 247, 230)}
    {{styles[0]}}
</style>
<body>
    <div>
        <h2 style="color:brown;" class="text" id="heading">
Programming Degree</h2>
        <h3 class="text" id="subhead">Modern Application 1</h3>
        <p class="text" id="main">This is a course on Application
Development</p>
    </div>
</body>
"""

test_render = Template(template)
output = test_render.render(styles = styles)
print(output)
```
  1. question figure
    text
    Programming Degree
    Modern Application 1
    This is a course on Application Development
  2. question figure
    text
    Programming Degree
    Modern Application 1
    This is a course on Application Development
  3. question figure
    text
    Programming Degree
    Modern Application 1
    This is a course on Application Development
  4. question figure
    text
    Programming Degree
    Modern Application 1
    This is a course on Application Development
Q11MCQ3 marks
question figure
Text of the picture (copyable)
What will be the output of the following python code if method
test_request_context() allows flask app to print statements on the terminal?

```python
from flask import Flask, url_for

app = Flask(__name__)

@app.route('/')
def home():
    return 'base url'

@app.route('/subscribe')
def subscribe():
    return 'Please subscribe to this page.'

@app.route('/new_course/<coursename>')
def course(coursename):
    return f'The course {coursename} gives basics of web development.'

with app.test_request_context():
    print(url_for('home'))
    print(url_for('subscribe'))
    print(url_for('subscribe', username = 'user_one'))
    print(url_for('course', coursename = 'MAD_I'))
```
  1. question figure
    text
    ```
    base url
    Please subscribe to this page
    Please subscribe to this page user one.
    The course MAD_I gives basics of web development.
    ```
  2. question figure
    text
    ```
    /
    /subscribe
    /subscribe/user_one
    /new_course/MAD_I
    ```
  3. question figure
    text
    ```
    /
    /subscribe
    /subscribe?username=user_one
    /new_course/MAD_I
    ```
  4. question figure
    text
    ```
    /
    /subscribe
    /subscribe?username=user_one
    /new_course?coursename=MAD_I
    ```
Q12MCQ3 marks
An internet connection with certain bandwidth is able to serve 10,000 requests of 150 Kilobytes each. What should be the increase in bandwidth (in Gbps) if this internet connection is to handle 12,500 requests of 180 Kilobytes each? (Use relations: 1 Byte = 8 bits, 1 MB = 1000 B, 1 GB = 1000 M and so on)
  1. 600
  2. 6
  3. 0.6
  4. 12
Q13MCQ3 marks
Consider the code snippet given below. question figure Consider the code snippet given below. Which of the following statement is true about the above code snippet?
Text of the picture (copyable)
Python file: test_app.py
```python
import pytest

@pytest.fixture
def items():
    return "Books"

@pytest.fixture
def order():
    return "Pens"

@pytest.fixture
def order_items(order, items):
    return [order, items]

@pytest.fixture
def expected_list():
    return ["Books", "Pencils", "Pens"]

def test_1(order_items, expected_list):
    order_items.append("Pencils")
    assert order_items == expected_list

def test_2(order_items):
    order_items.append("Pencils")
    assert order_items == ["Pens", "Books", "Pencils"]
```
  1. After running pytest, test_1 will fail, whereas test_2 will pass.
  2. After running pytest, test_2 will fail, whereas test_1 will pass.
  3. Both the test cases, test_1 and test_2 will pass successfully.
  4. Both the test cases, test_1 and test_2 will fail.
Q14MCQ3 marks
Consider the Python code snippet given below. question figure Consider the Python code snippet given below.
Text of the picture (copyable)
Python file: app.py

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

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

class Add(Resource):
    def post(self):
        data_args = reqparse.RequestParser()
        data_args.add_argument('Name', help='Name is required',
                               required=True)
        data_args.add_argument('Age', help='Age is required',
                               required=True)
        args = data_args.parse_args()
        return { "Your Name": args['Name'], "Your Age" : args['Age']}

api.add_resource(Add, '/add')

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

If this flask application is running on http://127.0.0.1:5000, which of the following is the correct output when a POST request is sent to URL "http://127.0.0.1:5000/add"?
  1. question figure
    text
    The server will throw a "405 METHOD NOT ALLOWED" error.
  2. question figure
    text
    The server will throw a "404 NOT FOUND" error.
  3. question figure
    text
    For the request body;
    ```json
    {
        "Name" : "Rahul",
        "Age": 23
    }
    ```
    The application will return;
    ```json
    {
        "Your Name": "Rahul",
        "Your Age": "23"
    }
    ```
  4. question figure
    text
    None of these
Q15MCQ3 marks
Consider the Python code given below. question figure Consider the Python code given below. Which of the following statement is true?
Text of the picture (copyable)
```python
import pytest

@pytest.fixture
def first_entry():
    return "Apple"

@pytest.fixture
def order(first_entry):
    return [first_entry]

def test_string(order):
    order.append("Kiwi")
    assert order == ["Banana", "Apple"]

def test_int(order):
    order.append("Banana")
    assert order == ["Banana", "Apple", "Kiwi"]
```
  1. After running pytest, both test cases will pass successfuly.
  2. After running pytest, the first test case will fail, whereas the second test casewill pass.
  3. After running pytest, both test cases will show a failure report.
  4. None of these
Q16MCQ3 marks
Consider the flask app given below. question figure Consider the flask app given below.
Text of the picture (copyable)
```python
from flask import Flask, abort
from flask_restful import Resource, Api

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

item_list=[{"item1": "Cloths"},
           {"item2": "Shoes"},
           {"item3": "Sunglasses"}]

class ItemList(Resource):
    def get(self, item_no, item_name):
        this_item = {'item'+item_no : item_name}
        if this_item in item_list:
            return item_list, 200
        else:
            abort('400')

    def post(self, item_no, item_name):
        my_item = {'item'+item_no : item_name}
        item_list.append(my_item)
        return my_item, 201

api.add_resource(ItemList, '/items/<item_no>/<item_name>')
app.run(debug=True)
```
If the above flask application is running locally on "http://127.0.0.1:5000", what will be the output of a GET request sent to the URL: 'http://127.0.0.1:5000/items/4/watch' just after a POST request that is sent on the same URL?
  1. question figure
    text
    The server will show a "404 NOT FOUND" error.
  2. question figure
    text
    ```json
    {
      "item4": "watch"
    }
    ```
  3. question figure
    text
    ```json
    [
      {
        "item1": "Cloths"
      },
      {
        "item2": "Shoes"
      },
      {
        "item3": "Sunglasses"
      },
      {
        "item4": "watch"
      }
    ]
    ```
  4. question figure
    text
    None of these
Q17MCQ3 marks
Consider the following flask application. question figure Consider the following flask application. suppose the application is running locally on the ‘http://127.0.0.1:5000', then what will be rendered by the browser?
Text of the picture (copyable)
```python
from flask import Flask, render_template

app=Flask(__name__)

@app.route('/')
def home():
    my_items = ['Cake', 'Apple', 'Ice Cream', 'DarkChocolate',
                'Donut', 'Grape']
    l1 = []
    for i in range(len(my_items)):
        if i>2:
            l1.append(my_items[i])

    return render_template('index.html', list=l1)

app.run(debug=True)
```
Template File - index.html
```html
{% macro display(list) %}
    {% for item in list %}
        <p>{{ item }}</p>
    {% endfor %}
{% endmacro %}
<html>
<body>
    {{ display(list) }}
</body>
</html>
```
  1. CakeAppleIce Cream
  2. CakeAppleIce CreamDarkChocolateDonutGrape
  3. DarkChocolateDonutGrape
  4. Ice CreamDarkChocolateDonutGrape
Q18MCQ3 marks
Consider the following Python code snippets. question figure Consider the following Python code snippets.
Text of the picture (copyable)
File 1: main.py
```python
import sys
from new import fun
a = sys.argv[1]
b = sys.argv[2]
c = sys.argv[3]
result = fun(a, b, c)
print(result + " is greater")
```

File 2: new.py
```python
def fun(num1,num2,num3):
    if (num1 > num2) and (num1 > num3):
        return num1
    elif (num2 > num1) and (num2 > num3):
        return num2
    else:
        return num3
```
suppose the main.py file is executed in the terminal. What will be the output?
python main.py
python main.py 8 10 5
  1. IndexError: list index out of rangeNameError: name 'fun' is not defined
  2. 3 is greaterNameError: name 'fun' is not defined
  3. IndexError: list index out of range10 is greater
  4. NameError: name 'fun' is not defined8 is greater
Q19MCQ3 marks
Consider a server that has an Intel i5 processor, 64 GB RAM, 1 TB Hard disk with 3 Gbps network connection. If a client accesses a web page, it requires 1.5 MB. Calculate the maximum number of such requests per second the server can handle. (Use relations: 1 Byte = 8 bits, 1 MB = 1000 B, 1 GB = 1000 M and so on).
  1. 25
  2. 32
  3. 250
  4. 200
Q20MSQ3 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 flask import Flask, abort, redirect, url_for, render_template

app = Flask(__name__)

weekday_users = ['user_1', 'user_3', 'user_4', 'user_6', 'user_7']
weekend_users = ['user_2', 'user_5']

@app.route('/weekday/<username>')
def user_weekday(username):
    if username in weekday_users:
        return redirect(url_for('login', username = username))
    else:
        abort(401)

@app.route('/weekend/<username>')
def user_weekend(username):
    if username in weekend_users:
        return redirect(url_for('login', username = username))
    else:
        abort(401)

@app.route('/login/<username>')
def login(username):
    return f"<h2>Correct User Found! {username}</h2>"

@app.errorhandler(401)
def page_not_found(error):
    return "<h2>You are not authorized for this day.</h2>", 401

app.run()
```

If the above flask app is running locally on "http://127.0.0.1:5000", Which of the following statements is/are correct?
  1. question figure
    text
    For the URL, "http://localhost:5000/weekday/user_4", the browser will render:
    **Correct User Found! user_4**
  2. question figure
    text
    For the URL, "http://localhost:5000/weekend/user_3", the browser will render:
    **Correct User Found! user_3**
  3. question figure
    text
    For the URL, "http://localhost:5000/weekday/user_5", the browser will render:
    **You are not authorized for this day.**
  4. question figure
    text
    For the URL, "http://localhost:5000/weekend/user_2", the browser will render:
    **You are not authorized for this day.**
Q21MSQ3 marksselect all that apply
Consider the code given below. question figure Consider the code given below.
Text of the picture (copyable)
```python
from flask import Flask, request
from flask_restful import Api, Resource, reqparse

app = Flask(__name__)

api = Api(app)

Mytasks = {
    1: {"mytask": "Studying"},
    2: {"mytask": "Exercise"},
    3: {"mytask": "Eating"},
    4: {"mytask": "Sleeping"}
}

class Display(Resource):
    def get(self):
        return Mytasks

class DisplayAll(Resource):
    def get(self, MytaskList_id):
        return Mytasks[MytaskList_id]

    def post(self, MytaskList_id):
        data_args = reqparse.RequestParser()
        data_args.add_argument("mytask",help='This is required field', required =True)
        args = data_args.parse_args()
        Mytasks[MytaskList_id] = {"mytask" : args["mytask"]}
        return Mytasks[MytaskList_id]
api.add_resource(Display, '/mytask')
api.add_resource(DisplayAll, '/task/<int:MytaskList_id>')

if __name__ == '__main__':
    app.run(debug=True)
```
If the above flask application is running locally on "http://127.0.0.1:5000", which of the following statements is/are true?
  1. question figure
    text
    The status code that we get after sending a POST request to the URL: 'http://127.0.0.1:5000/mytask/4' will be "404 NOT FOUND".
  2. question figure
    text
    The response that we get after sending a GET request to the URL: http://127.0.0.1:5000/mytask will be:
    ```json
    {
      "1": {
        "mytask": "Studying"
      },
      "2": {
        "mytask": "Exercise"
      },
      "3": {
        "mytask": "Eating"
      },
      "4": {
        "mytask": "Sleeping"
      }
    }
    ```
  3. question figure
    text
    The response that we get after sending POST request to the
    URL:"http://127.0.0.1:5000/task/4" with a sending a request body as,
    ```json
    {
        "mytask" : "Swimming"
    }
    ```
    will be :
    ```json
    {
        "mytask" : "Swimming"
    }
    ```
  4. question figure
    text
    The response that we get after sending a GET request to the URL: "http://127.0.0.1:5000/mytask" will be:
    
    ```json
    {
      "1": {
        "mytask": "Studying"
      },
      "2": {
        "mytask": "Exercise"
      },
      "3": {
        "mytask": "Eating"
      },
      "4": {
        "mytask": "Sleeping"
      },
      "4": {
        "mytask": "Swimming"
      }
    }
    ```
Q22SA4.5 marks
What will be the decimal representation of binary number 0101011000000112?
Q23MCQ4.5 marks
A machine takes a minimum of 100 seconds to sort 500 entries in a database. What will be the approximate minimum time taken by the machine to sort 1200 entries if the sorting method employs an algorithm with time complexity of O(nlog(n)). Where “n” is the number of entries?
  1. 173 seconds
  2. 273 seconds
  3. 373 seconds
  4. 473 seconds
Q24MCQ4.5 marks
The speed vs. throughput characteristics of a typical HDD is shown in the figure below. If this HDD is to be used as a replacement of an SSD whose read/write speed is 450 MB/s. At what speed (in RPM) should the disk of HDD rotate with to deliver the same performance as that of the SSD? question figure The speed vs. throughput characteristics of a typical HDD is shown in the figure below. If this HDD is to be used as a replacement of an SSD whose read/write speed is 450 MB/s. At what speed (in RPM) should the disk of HDD rotate with to deliver the same performance as that of the SSD?
Text of the picture (copyable)
This is a 2D line graph with a light grey background.

The y-axis is labeled "Throughput -->" and "MBytes/sec". It has tick marks and labels at 0, 25, 50, 75, 100, 125, and 150.
The x-axis is labeled "Speed -->" and "RPM". It has tick marks and labels at 0, 3600, and 7200.

A solid black line starts at (0,0) and goes up to (3600, 100).
From (3600, 100), the line continues as a solid black line up to (7200, 150).
Beyond (7200, 150), the line continues as a dashed black line, indicating it extends further.

Dashed black lines are drawn from the point (3600, 100) to the x-axis at 3600 and to the y-axis at 100.
Dashed black lines are drawn from the point (7200, 150) to the x-axis at 7200 and to the y-axis at 150.
  1. 3600 RPM
  2. 7200 RPM
  3. 16,200 RPM
  4. 28,800 RPM
Q25MCQ4.5 marks
Consider the following Flask app and an HTML file. question figure Consider the following Flask app and an HTML file. Suppose the application is running locally on the ‘http://127.0.0.1:5000', then what will be rendered by the browser for ‘http://127.0.0.1:5000/?id=5', http://127.0.0.1:5000/?id=1’ and ‘http://127.0.0.1:5000/?id=4' respectively?
Text of the picture (copyable)
Flask app: app.py

```python
from flask import Flask, render_template, request
app = Flask(__name__)
users = {
    '3':{'name': 'Ram', 'Designation': 'Teacher'},
    '2':{'name': 'Dilip', 'Designation': 'student'},
    '5':{'name': 'Sonu', 'Designation': 'computer operator'},
    '1':{'name': 'Guru', 'Designation': 'clerk'}
}

@app.route('/')
def country():
    id = request.args.get('id')
    authenticated_users_id = [3, 2, 5]
    user = users.get(id)
    name = user.get('name') if user is not None else None
    Designation = user.get('Designation') if user is not None else None

    user = {'is_authenticated': False, 'name': name, 'Designation': Designation}
    if int(id) in authenticated_users_id:
        user['is_authenticated'] = True
        return render_template('index.html', data = user)
    if int(id) not in authenticated_users_id:
        user['is_authenticated'] = False
        return render_template('index.html', data = user)

app.run(debug = True)
```

HTML File: index.html
```html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
</head>
<body>
    {% if data.name == None %}
        User not found
    {% elif data.is_authenticated == True %}
        Hello {{data.name}} you can enter into this site:
        {{data.Designation}}
    {% else %}
        Hello {{data.name}} you have no access to this site:
        {{data.Designation}}
    {% endif %}
</body>
</html>
```
  1. Hello Sonu you can enter into this site: computer operatorHello Guru you have no access to this site: clerkUser not found
  2. Hello Ram you can enter into this site: TeacherHello Guru you have no access to this site: StudentHello Sonu you can enter into this site: computer operator
  3. User not foundHello Dilip you have no access to this site: StudentHello Sonu you can enter into this site: computer operator
  4. Hello Ram you can enter into this site: TeacherHello Dilip you have no access to this site: StudentUser not found
Q26MCQ4.5 marks
Consider the following Python code snippet. question figure Consider the following Python code snippet. What will be the output of the above program?
Text of the picture (copyable)
```python
from jinja2 import Template

temp = """{% set numbers = studs | map(attribute = "mark") | list %}
{{numbers | min}}{{numbers | max}}"""

studs = [
{"stud_name":"Reeta","mark":"92"},
{"stud_name":"Veena","mark":"88"},
{"stud_name":"Meena","mark":"62"},
{"stud_name":"uma","mark":"98"}
]

t1 = """{% for i in studs -%}
{{i}}
{%- endfor%}"""

output = Template(temp)
out = Template(t1)

print(output.render(studs = studs))
print(out.render(studs = studs))
```
  1. 98 62{'stud_name': 'Reeta', 'mark': '92'}{'stud_name': 'Veena', 'mark': '88'}{'stud_name': 'Meena', 'mark': '62'}{'stud_name': 'uma', 'mark': '98'}
  2. 62 98{'stud_name': 'Reeta', 'mark': '92'}{'stud_name': 'Veena', 'mark': '88'}{'stud_name':'Meena', 'mark': '62'}{'stud_name': 'uma', 'mark': '98'}
  3. 62 98{'stud_name': 'uma', 'mark': '92'}{'stud_name': 'Meena', 'mark': '88'}{'stud_name': 'Veena', 'mark': '62'}{'stud_name': 'Reeta', 'mark': '98'}
  4. 98 62{'stud_name': 'uma', 'mark': '92'}{'stud_name': 'Meena', 'mark': '88'}{'stud_name':'Veena', 'mark': '62'}{'stud_name': 'Reeta', 'mark': '98'}
Q27MCQ4.5 marks
Consider the following table “newtable” in SQLite database. question figure Consider the following table “newtable” in SQLite database.
Text of the picture (copyable)
Here is the transcription of the image:

| ID | Name | Age | Mark | course |
|---|---|---|---|---|
| Filter | Filter | Filter | Filter | Filter |
| 1 | Vishnu | 20 | 98 | M1 |
| 2 | Kumar | 18 | 90 | M2 |
| 3 | Leela | 20 | 90 | M1 |
| 4 | Naren | 18 | 98 | M2 |
| 5 | Vishal | 19 | 95 | M1 |
| 6 | Pranav | 20 | 95 | M2 |
| 7 | Vinu | 19 | 90 | M1 |
| 8 | Viki | 18 | 95 | M2 |

What will be the output of the following SQL queries given below?

```sql
CREATE UNIQUE INDEX IF NOT EXISTS index_name
ON newtable (Name ASC, Mark ASC) WHERE Age>18;
SELECT ID, Name, Age, Mark, course FROM newtable WHERE Age>18;
```
  1. question figure
    text
    index_name will be created
    
    | ID | Name | Age | Mark | course |
    |---|---|---|---|---|
    | 2 | Kumar | 18 | 90 | M2 |
    | 4 | Naren | 18 | 98 | M2 |
    | 8 | Viki | 18 | 95 | M2 |
  2. question figure
    text
    index_name will be created
    
    | ID | Name | Age | Mark | course |
    |---|---|---|---|---|
    | 3 | Leela | 20 | 90 | M1 |
    | 6 | Pranav | 20 | 95 | M2 |
    | 7 | Vinu | 19 | 90 | M1 |
    | 5 | Vishal | 19 | 95 | M1 |
    | 1 | Vishnu | 20 | 98 | M1 |
  3. question figure
    text
    index_name will not be created
    
    | ID | Name | Age | Mark | course |
    |---|---|---|---|---|
    | 2 | Kumar | 18 | 90 | M2 |
    | 4 | Naren | 18 | 98 | M2 |
    | 8 | Viki | 18 | 95 | M2 |
    | 3 | Leela | 20 | 90 | M1 |
    | 6 | Pranav | 20 | 95 | M2 |
    | 7 | Vinu | 19 | 90 | M1 |
    | 5 | Vishal | 19 | 95 | M1 |
    | 1 | Vishnu | 20 | 98 | M1 |
  4. question figure
    text
    index_name will not be created
    
    | ID | Name | Age | Mark | course |
    |---|---|---|---|---|
    | 1 | Vishnu | 20 | 98 | M1 |
    | 2 | Kumar | 18 | 90 | M2 |
    | 3 | Leela | 20 | 90 | M1 |
    | 4 | Naren | 18 | 98 | M2 |
Q28MCQ4.5 marks
Consider the following Python snippet. question figure Consider the following Python snippet.
Text of the picture (copyable)
```python
@app.route("/search", methods = ["GET"])
def search():
    q = request.args.get('q')
    query = "%"+q+"%"
    results = Details.query.filter(Details.Content.like(query)).all()
    Return render_template("result.html", q=q, Details = results)
```
File : result.html
```html
{% for item in results %}
    {{item["Title"]}}
{% endfor %}
```
SQLite table: details

| ID | Title         | Content                                     |
|----|---------------|---------------------------------------------|
| 1  | Introduction  | Java is a powerful general-purpose ...      |
| 2  | learn python  | Python is a powerful general-purpose ...    |
| 3  | Basics        | Java works on different platforms (Windo    |
| 4  | Code          | Python is currently the most widely used    |

If the flask application is running locally on URL: http://127.0.0.1:5000, what will be rendered by the web browser for URL http://127.0.0.1:5000/search?q=Java?
  1. IntroductionCode
  2. Java is a powerful general purpose …Java works on different platforms(windows)
  3. Introduction - Java is a powerful general purpose …learn python - Python is a powerful general purpose …Basics - Java works on different platforms(windows)
  4. IntroductionBasics
Q29MSQ4.5 marksselect all that apply
Consider the HTML code given below. question figure Consider the HTML code given below. To obtain the output as given in figure above, which of the following snippets of CSS code must be used?
Text of the picture (copyable)
HTML file: index.html

```html
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<h1>
    <h1>CSS Selectors</h1>
</h1>
<div>
    <h2 id="header-id1" class="header-class">Hi, Folks!</h2>
    <p id="paragraph-id1" class="paragraph-class">Welcome to IITM.</p>
    <a href="https://iitm.ac.in">
        IIT Bsc Degree Website</a>
    <p class="class1 class2">We are launching World's first online
        degree course.</p>
</div>
<div>
    <h2 id="header-id2">Have you enrolled to the program?</h2>
    <p id="paragraph-id2">If not, enroll now!</p>
    <a href="https://mywebsite.com
        ">Link to Enroll</a>
    <p class="class2 class3">Happy Learning!</p>
</div>
</body>
</html>
```

CSS Selectors

Hi, Folks!

Welcome to IITM.

IIT Bsc Degree Website

We are launching World's first online degree course.

Have you enrolled to the program?

If not, enroll now!

Link to Enroll

Happy Learning!
  1. question figure
    text
    ```html
    <style>
        #header-id1, #header-id2, #header-id3
        {
            color: red;
        }
        .header-class{
            color:blue;
        }
        .paragraph-class{
            color:purple;
        }
        p.class2{
            color:green;
        }
    </style>
    ```
  2. question figure
    text
    ```html
    <style>
        #header-id1, #header-id2, #header-id3
        {
            color: red;
        }
        .header-class{
            color:blue;
        }
        p.class2{
            color:green;
        }
        #paragraph-id1, #paragraph-id2{
            color:purple;
        }
    </style>
    ```
  3. question figure
    text
    ```html
    <style>
        h2{
            color: red;
        }
        .header-class{
            color:blue;
        }
        p.class3{
            color:green;
        }
        #paragraph-id{
            color:purple;
        }
    </style>
    ```
  4. question figure
    text
    ```html
    <style>
    h2{
        color: blue;
    }
    h2{
        color: red;
    }
    #paragraph-id1, #paragraph-id2{
        color:purple;
    }
    p.class2{
        color:green;
    }
    </style>
    ```
Comprehension passage - the questions below it refer to this
Consider the following model classes “State” and “City” corresponding to tables “state” and “city” respectively in the SQLite database. question figure Consider the following model classes “State” and “City” corresponding to tables “state” and “city” respectively in the SQLite database. Based on the above data, answer the given subquestions.
Q30MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
If an object "s1" that represents an
existing record in the table "state" is
defined as
```python
s1 = State.query.get(1),
```
The correct way(s) to add a city with
the name "Chennai" that belongs to
s1 using the Python console is.
  1. question figure
    text
    ```python
    >>> c1 = City(city_name = "Chennai", state = s1)
    >>> db.session.add(c1)
    >>> db.session.commit()
    ```
  2. question figure
    text
    ```python
    >>> c1 = City(city_name = "Chennai", state = 1)
    >>> db.session.add(c1)
    >>> db.session.commit()
    ```
  3. question figure
    text
    ```python
    >>> c1 = City(city_name = "Chennai", stateof = s1)
    >>> db.session.add(c1)
    >>> db.session.commit()
    ```
  4. question figure
    text
    ```python
    >>> c1 = City(city_name = "Chennai", stateof = 1)
    >>> db.session.add(c1)
    >>> db.session.commit()
    ```
Q31MSQ3 marksselect all that apply
If “s1” and “c1” are existing objects in the tables “state” and “city” respectively where: question figure If “s1” and “c1” are existing objects in the tables “state” and “city” respectively where: Which of the following statements is/are correct?
Text of the picture (copyable)
```python
s1 = State.query.filter_by(state_name = "Maharashtra").first()

and

c1 = City.query.filter_by(city_name = "Mumbai").first()
```
  1. question figure
    text
    The input `s1.cities` on Python console will return a single object
  2. question figure
    text
    The input s1.cities on Python console will return a list of object(s)
  3. question figure
    text
    The input c1.state on Python console will return a single object
  4. question figure
    text
    The input c1.state on Python console will return a list of object(s)
Comprehension passage - the questions below it refer to this
Consider the following resource API for the employee information given below and answer the given subquestions. question figure Consider the following resource API for the employee information given below and answer the given subquestions.
Q32MCQ3 marks
question figure
Text of the picture (copyable)
If the flask application is running locally on URL "http://127.0.0.1:5000/myinfo",
what will be the output of the following curl request?

```
curl "http://127.0.0.1:5000/myinfo" -X POST -d "{\"first_name\":
\"Shrivatsa\",\"last_name\":\"Tandon\",\"role\":\"Analyst\",\"salary
\": 50000}" -H "Content-Type: application/json"
```
  1. question figure
    text
    ```json
    {
      "first_name": "Shrivatsa",
      "last_name": "Tandon"
    }
    ```
  2. question figure
    text
    ```json
    {
        "first_name": "Shrivatsa",
        "salary": 50000
    }
    ```
  3. question figure
    text
    ```json
    {
      "first_name": "Shrivatsa",
      "role": "Analyst"
    }
    ```
  4. question figure
    text
    ```json
    {
        "first_name": "Shrivatsa",
        "last_name": "Tandon",
        "role": "Analyst",
        "salary": 50000
    }
    ```
Q33MCQ3 marks
question figure
Text of the picture (copyable)
If the flask application is running locally on URL "http://127.0.0.1:5000/myinfo",
what will be the output of the following Python code snippet?

```python
import requests

data = {"first_name":"Rajnish",
        "last_name":"Dey",
        "role":"Manager",
        "salary":"10 thousand"}

response = requests.put('http://127.0.0.1:5000/myinfo', data = data)
print(response.json())
```
  1. question figure
    text
    ```
    {
        'first_name': 'Rajnish',
        'salary': '10 thousand'
    }
    ```
  2. question figure
    text
    ```
    {
        'first_name': 'Rajnish',
        'role': 'Manager'
    }
    ```
  3. question figure
    text
    ```
    {
        'first_name': 'Rajnish',
        'last_name': 'Dey'
    }
    ```
  4. question figure
    text
    None of these

Answer key

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


1. Core Topics & Concepts

A. Web Development Fundamentals

1. URL Structure

2. HTTP Methods

3. Flask Framework

4. HTML & CSS

5. Jinja2 Templating

6. RESTful APIs

7. Testing (Pytest)


B. Mathematics & Algorithms

1. Time Complexity

2. Bandwidth & Throughput

3. HDD vs. SSD Performance


C. Database (SQLite & SQLAlchemy)

1. SQL Queries

2. CRUD Operations


2. Key Equations

A. Bandwidth Calculation

\[ \text{Total Data (bits)} = \text{Number of Requests} \times \text{Request Size (Bytes)} \times 8 \] \[ \text{Bandwidth (Gbps)} = \frac{\text{Total Data (bits)}}{10^9 \text{ (for GB)} \times \text{Time (s)}} \]

B. Time Complexity Scaling

For O(n log n): \[ \frac{T_2}{T_1} = \frac{n_2 \log n_2}{n_1 \log n_1} \]

C. HDD RPM to Throughput

\[ \text{Throughput (MB/s)} \propto \text{RPM} \] \[ \text{Required RPM} = \text{Current RPM} \times \frac{\text{Desired Throughput}}{\text{Current Throughput}} \]


Graph 2: Flask Workflow

Graph 3: HTTP Methods & Status Codes

Graph 4: SQLAlchemy Relationships

Graph 5: Testing with Pytest

Graph 6: Bandwidth & Throughput

Graph 7: Time Complexity


4. Exam Preparation Checklist

TopicKey Concepts
URL StructureProtocol, domain, path, query parameters, fragments.
Flask Routing@app.route, request.args, request.json, render_template.
Jinja2 TemplatingLoops, conditionals, filters, macros.
HTTP MethodsGET, POST, PUT, DELETE, status codes.
Flask-RESTfulResource, Api, reqparse, marshal_with.
SQLAlchemyModel definition, relationships, CRUD, queries.
HTML/CSSSelectors, box model, inline/internal/external CSS.
Bandwidth CalculationRequest size, number of requests, conversion (Bytes → bits → Gbps).
Time ComplexityBig-O notation, scaling for O(n log n).
HDD vs. SSDRPM → throughput, linear scaling.
Testing (Pytest)Fixtures, assertions, test isolation.