Quiz Space

January 2023 term · Modern Application Development I · BSCS2003

MAD 1 End Term: 30 April 2023, Set QPD1-S1 (January 2023 term)

The IIT Madras BS Modern Application Development I (MAD 1) End Term paper sat on 30 Apr 2023, in the January 2023 term, set QPD1-S1: 32 questions for 100 marks in 180 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
32
Marks
100
Duration
180 min
MCQ
28
MSQ
4

Updated

Official paper: IIT M DIPLOMA ET1 EXAM QPD1 S2 30 Apr 2023 · No negative marking.

Question 1

+2 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 2

+2 marksOne correct option

Consider the following statements regarding Continuous Integration and Continuous Deployment and select the correct option.
Statement 1: As part of continuous integration, frequent, isolated changes are tested and reported on as soon as they are added to a larger code base.
Statement 2: When a change is made to an application, it is automatically deployed into production using a continuous deployment strategy.

  1. A

    Statement 1 is correct and statement 2 is incorrect.

  2. B

    Statement 1 is incorrect and statement 2 is correct.

  3. C

    Statement 1 and statement 2 both are correct.

  4. D

    Statement 1 and statement 2 both are incorrect.

Show answer

Correct answer

  • C

    Statement 1 and statement 2 both are correct.

Question 3

+2 marksOne correct option

A linked list is used to store data elements in an unsorted manner. What is the worst time complexity for searching an element in memory? [N is the number of elements in the linked list]

  1. A

    O(1)

  2. B

    O(logN)

  3. C

    O(N)

  4. D

    O(NlogN)

Show answer

Correct answer

  • C

    O(N)

Question 4

+2 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 5

+2 marksOne correct option
  1. A

    Controller function

  2. B

    Model class

  3. C

    Template Inheritance

  4. D

    View function

Show answer

Correct answer

  • C

    Template Inheritance

Question 6

+2 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 7

+2 marksOne correct option

Read the following statements regarding web accessibility principles and choose the correct option.
Statement 1: The web pages with captions and alternative for multimedia makes the user interface operable and easy to navigate
Statement 2: A web page with robust content and reliable interpretation refers to its content being compatible with current and future user tools

  1. A

    Both statement 1 and statement 2 are correct.

  2. B

    Both statement 1 and statement 2 are incorrect

  3. C

    Statement 1 is correct but statement 2 is incorrect.

  4. D

    Statement 1 is incorrect but statement 2 is correct.

Show answer

Correct answer

  • D

    Statement 1 is incorrect but statement 2 is correct.

Question 8

+3 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 9

+3 marksOne correct option

Consider the two python files main.py and test_sample.py.

main.py

python
from flask import Flask
app = Flask(__name__)
@app.route('/hello')
def hello():
return 'Hello World'
@app.route('/home')
def home():
return 'Hello Home'
if __name__ == '__main__':
app.run(debug = True)

test_sample.py

python
import pytest, requests
@pytest.fixture
def get_url_response():
response = requests.get('http://127.0.0.1:5000/hello')
return response
def test_statuscode(get_url_response):
assert get_url_response.status_code == 200
def test_text(get_url_response):
assert get_url_response.text == 'Hello Home'

Assuming main.py is running locally in the terminal. In another local terminal run “pytest” command. What will be the output of the test_sample.py file?

  1. A

    2 passed

  2. B

    1 failed 1 passed

  3. C

    2 failed

  4. D

    No tests

Show answer

Correct answer

  • B

    1 failed 1 passed

Question 10

+3 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 11

+3 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 12

+3 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 13

+3 marksOne correct option

What will be the output on the terminal for the given Python code snippet.

python
def f1(a=4,b=5):
def f2(x, y):
if y==5:
print("HiFive")
print("inside f2_func")
print("inside f1_func")
f2(a,b)
@f1
def f3():
pass
print(f3)
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 14

+3 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 15

+3 marksOne correct option
  1. A

    a = 8; b = 10; c = 16;

  2. B

    a = 10; b = 8; c = 16;

  3. C

    a = 16; b = 8; c = 10;

  4. D

    a = 10; b = 16; c = 8;

Show answer

Correct answer

  • C

    a = 16; b = 8; c = 10;

Question 16

+3 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 17

+3 marksOne correct option

How will the browser render the following HTML document?

html
<html>
<body>
<div>Hello from div 1</div>
<div>Hello from div 2</div>
<span>Hello from span 1</span>
<span>Hello from span 2</span>
</body>
</html>
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 18

+3 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 19

+2 marksOne or more correct options

In terms of logging, which of the following statements is/are true?

Select all that apply.

  1. A

    Helps in identifying unexpected issues in the application and debugging them.

  2. B

    Maintains the source code version.

  3. C

    Detect the test file and test functions automatically.

  4. D

    Keeping track of the application's events.

Show answer

Correct answers

  • A

    Helps in identifying unexpected issues in the application and debugging them.

  • D

    Keeping track of the application's events.

Question 20

+3 marksOne or more correct options

Consider following flask app.

python
from flask import Flask
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class Testing(Resource):
def get(self):
return {'data': 'GET'}
def post(self, data):
return {'data':'POST'}
api.add_resource(Testing, '/', '/<string:data>')
if __name__ == '__main__':
app.run(debug=True)

The flask app is running locally in the terminal. Which of the following command(s) will return the response without any error?

Select all that apply.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answers

  • A
  • C

Question 21

+3 marksOne or more correct options

Consider the following flask application running on the base URL and is accessed through a browser. Select the correct option(s).

python
from flask import Flask, abort, request
app = Flask(__name__)
users = {
1 : {"Name": "Ritu", "role": "Admin", "access": True},
2 : {"Name": "Ramesh", "role": "User", "access": True},
3 : {"Name": "Tejas", "role": "Admin", "access": True},
4 : {"Name": "Manisha", "role": "User", "access": False}
}
@app.route('/login')
def auth():
cred = request.args
if users[int(cred["id"])].get("access"):
id = int(cred["id"])
user = users[id]
return "Welcome, "+ user.get("Name")+", you have
"+user.get("role")+" access"
else:
abort(403)
@app.errorhandler(403)
def no_access(error):
return "Looks like you are not an authorized user!"
app.run(debug = True)

Select all that apply.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answers

  • A
  • C

Question 22

+3 marksOne or more correct options

Which of the following statements regarding the version control system git is/are correct?

Select all that apply.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answers

  • B
  • C

Question 23

+4.5 marksOne correct option

Consider the following Python code snippet.

python
from jinja2 import Template
data = [
{"vehicle_id":"ev101", "vehicle_name":"electroN", "fuel_type":"electric"},
{"vehicle_id":"pt201", "vehicle_name":"discover", "fuel_type":"petrol"},
{"vehicle_id":"dz301", "vehicle_name":"apex", "fuel_type":"diesel"},
]
this_text = """
<h1> Ordered Vehicles </h1>
{% set keys = data[0].keys() %}
{% set keys = keys|list %}
{% for i in range(data|length) %}
{{keys[i]}} : {{data[i][keys[i]]}}
{% endfor %}
<h3> Total: {{ data|length }} </h3>
"""
this_temp = Template(this_text)
rendered = this_temp.render(data = data)
print(rendered)

How will the browser render the output of the above given Python code?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 24

+4.5 marksOne correct option

An API resource created using flask_restful is shown below. Answer the given subquestions if the app is running locally on http://127.0.0.1:5000

python
from flask import Flask, make_response
from flask_restful import Resource, Api, reqparse
from werkzeug.exceptions import HTTPException
app = Flask(__name__)
api = Api(app)
objects = {
"bot101": {"obj_code": "BOT01", "obj_name": "bottles"},
"sop109": {"obj_code": "SOP09", "obj_name": "soaps"},
"can103": {"obj_code": "CAN03", "obj_name": "candles"}
}
to_parse = reqparse.RequestParser()
to_parse.add_argument("obj_code")
to_parse.add_argument("obj_name")
class NoObjectError(HTTPException):
def __init__(self, status, error):
self.response = make_response({"Error": error}, status)
class BadRequest(HTTPException):
def __init__(self, status, error):
self.response = make_response({"Error": error}, status)
class Objects(Resource):
def get(self, id):
args = to_parse.parse_args()
if id in objects:
my_obj = objects[id]
if args["obj_code"] == None:
raise BadRequest(404, "Object code missing.")
if args["obj_name"] == None:
raise BadRequest(404, "Object name missing.")
else:
my_obj["obj_code"] = args["obj_code"]
my_obj["obj_name"] = args["obj_name"]
return my_obj
else:
raise NoObjectError(404, "Object doesn't exist in the database.")
api.add_resource(Objects, "/get_object/<id>")
app.run(debug = True)
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 25

+4.5 marksOne correct option

An API resource created using flask_restful is shown below. Answer the given subquestions if the app is running locally on http://127.0.0.1:5000

python
from flask import Flask, make_response
from flask_restful import Resource, Api, reqparse
from werkzeug.exceptions import HTTPException
app = Flask(__name__)
api = Api(app)
objects = {
"bot101": {"obj_code": "BOT01", "obj_name": "bottles"},
"sop109": {"obj_code": "SOP09", "obj_name": "soaps"},
"can103": {"obj_code": "CAN03", "obj_name": "candles"}
}
to_parse = reqparse.RequestParser()
to_parse.add_argument("obj_code")
to_parse.add_argument("obj_name")
class NoObjectError(HTTPException):
def __init__(self, status, error):
self.response = make_response({"Error": error}, status)
class BadRequest(HTTPException):
def __init__(self, status, error):
self.response = make_response({"Error": error}, status)
class Objects(Resource):
def get(self, id):
args = to_parse.parse_args()
if id in objects:
my_obj = objects[id]
if args["obj_code"] == None:
raise BadRequest(404, "Object code missing.")
if args["obj_name"] == None:
raise BadRequest(404, "Object name missing.")
else:
my_obj["obj_code"] = args["obj_code"]
my_obj["obj_name"] = args["obj_name"]
return my_obj
else:
raise NoObjectError(404, "Object doesn't exist in the database.")
api.add_resource(Objects, "/get_object/<id>")
app.run(debug = True)
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 26

+4.5 marksOne correct option

An API resource created using flask_restful is shown below. Answer the given subquestions if the app is running locally on http://127.0.0.1:5000

python
from flask import Flask, make_response
from flask_restful import Resource, Api, reqparse
from werkzeug.exceptions import HTTPException
app = Flask(__name__)
api = Api(app)
objects = {
"bot101": {"obj_code": "BOT01", "obj_name": "bottles"},
"sop109": {"obj_code": "SOP09", "obj_name": "soaps"},
"can103": {"obj_code": "CAN03", "obj_name": "candles"}
}
to_parse = reqparse.RequestParser()
to_parse.add_argument("obj_code")
to_parse.add_argument("obj_name")
class NoObjectError(HTTPException):
def __init__(self, status, error):
self.response = make_response({"Error": error}, status)
class BadRequest(HTTPException):
def __init__(self, status, error):
self.response = make_response({"Error": error}, status)
class Objects(Resource):
def get(self, id):
args = to_parse.parse_args()
if id in objects:
my_obj = objects[id]
if args["obj_code"] == None:
raise BadRequest(404, "Object code missing.")
if args["obj_name"] == None:
raise BadRequest(404, "Object name missing.")
else:
my_obj["obj_code"] = args["obj_code"]
my_obj["obj_name"] = args["obj_name"]
return my_obj
else:
raise NoObjectError(404, "Object doesn't exist in the database.")
api.add_resource(Objects, "/get_object/<id>")
app.run(debug = True)
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 27

+4.5 marksOne correct option

A machine client M makes multiple requests to three different servers A, B and C in the order A then B followed by C. However, it can make a request to server B only after receiving the response from server A and same with server C i.e the client can make a request to server C only after receiving response from server B. If the servers A, B and C are located at 1200 kms, 1800 kms and 2400 kms respectively, answer the given subquestions.[Consider speed of light in air to be 3 x 10⁸ m/s]

What is the maximum number of requests that can be made to B per second?

  1. A

    20

  2. B

    27

  3. C

    83

  4. D

    125

Show answer

Correct answer

  • B

    27

Question 28

+3 marksOne correct option

A machine client M makes multiple requests to three different servers A, B and C in the order A then B followed by C. However, it can make a request to server B only after receiving the response from server A and same with server C i.e the client can make a request to server C only after receiving response from server B. If the servers A, B and C are located at 1200 kms, 1800 kms and 2400 kms respectively, answer the given subquestions.[Consider speed of light in air to be 3 x 10⁸ m/s]

What is the round trip time (RTT) in milliseconds for server C?

  1. A

    8

  2. B

    12

  3. C

    16

  4. D

    20

Show answer

Correct answer

  • C

    16

Question 29

+4.5 marksOne correct option

Consider the following tables ‘product’ and ‘category’ that represent models ‘Product’ and ‘Category’ in SQLite database and answer the given subquestions.

python
class Product(db.Model):
product_id = db.Column(db.Integer(), primary_key = True)
product_name = db.Column(db.String(50), unique = True)
category = db.Column(db.Integer(),db.ForeignKey('category.category_id'))
cat = db.relationship('Category', back_populates = 'products')
class Category(db.Model):
category_id = db.Column(db.Integer(), primary_key = True)
category_name = db.Column(db.String(50), unique = True)
products = db.relationship('Product', back_populates = 'cat')

Which of the following statements about the tables ‘product’ and ‘category’ is correct?

  1. A

    Multiple instances of Product can belong to a single instance of Category.

  2. B

    Multiple instances of Category can belong to a single instance of Product but the converse in not true.

  3. C

    Multiple instances of Product can belong to a single instance of Category and vice versa.

  4. D

    One instance of Category can belong to any one instance of Product only.

Show answer

Correct answer

  • A

    Multiple instances of Product can belong to a single instance of Category.

Question 30

+3 marksOne correct option

Consider the following tables ‘product’ and ‘category’ that represent models ‘Product’ and ‘Category’ in SQLite database and answer the given subquestions.

python
class Product(db.Model):
product_id = db.Column(db.Integer(), primary_key = True)
product_name = db.Column(db.String(50), unique = True)
category = db.Column(db.Integer(),db.ForeignKey('category.category_id'))
cat = db.relationship('Category', back_populates = 'products')
class Category(db.Model):
category_id = db.Column(db.Integer(), primary_key = True)
category_name = db.Column(db.String(50), unique = True)
products = db.relationship('Product', back_populates = 'cat')

Consider ‘C1’, an instance of table ‘category’ whose category_id is 2. The correct way of adding a product ‘compass’ to this category is:

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 31

+4.5 marksOne correct option

Consider the following resource API created with help of flask_restful.

python
from flask import Flask, request
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class TestApi(Resource):
def post(self, state, city):
return {"state": state, "capital": city}
def get(self):
info = request.args
return info
api.add_resource(TestApi, '/united_states','/united_states/<state>/<city>')
app.run(debug = True)

If the above application is running locally on http://127.0.0.1:5000, answer the given subquestions.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 32

+4.5 marksOne correct option

Consider the following resource API created with help of flask_restful.

python
from flask import Flask, request
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class TestApi(Resource):
def post(self, state, city):
return {"state": state, "capital": city}
def get(self):
info = request.args
return info
api.add_resource(TestApi, '/united_states','/united_states/<state>/<city>')
app.run(debug = True)

If the above application is running locally on http://127.0.0.1:5000, answer the given subquestions.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B