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.
- 32
- 100
- 180 min
- 28
- 4
Show answer
Correct answer
Question 2
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.
Statement 1 is correct and statement 2 is incorrect.
Statement 1 is incorrect and statement 2 is correct.
Statement 1 and statement 2 both are correct.
Statement 1 and statement 2 both are incorrect.
Show answer
Correct answer
Statement 1 and statement 2 both are correct.
Question 3
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]
O(1)
O(logN)
O(N)
O(NlogN)
Show answer
Correct answer
O(N)
Question 4
Show answer
Correct answer
Question 5
Controller function
Model class
Template Inheritance
View function
Show answer
Correct answer
Template Inheritance
Question 6
Show answer
Correct answer
Question 7
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
Both statement 1 and statement 2 are correct.
Both statement 1 and statement 2 are incorrect
Statement 1 is correct but statement 2 is incorrect.
Statement 1 is incorrect but statement 2 is correct.
Show answer
Correct answer
Statement 1 is incorrect but statement 2 is correct.
Question 8
Show answer
Correct answer
Question 9
Consider the two python files main.py and test_sample.py.
main.py
from flask import Flaskapp = 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
import pytest, requests
@pytest.fixturedef 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?
2 passed
1 failed 1 passed
2 failed
No tests
Show answer
Correct answer
1 failed 1 passed
Question 10
Show answer
Correct answer
Question 11
Show answer
Correct answer
Question 12
Show answer
Correct answer
Question 13
What will be the output on the terminal for the given Python code snippet.
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)
@f1def f3(): passprint(f3)Show answer
Correct answer
Question 14
Show answer
Correct answer
Question 15
a = 8; b = 10; c = 16;
a = 10; b = 8; c = 16;
a = 16; b = 8; c = 10;
a = 10; b = 16; c = 8;
Show answer
Correct answer
a = 16; b = 8; c = 10;
Question 16
Show answer
Correct answer
Question 17
How will the browser render the following HTML document?
<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>Show answer
Correct answer
Question 18
Show answer
Correct answer
Question 19
In terms of logging, which of the following statements is/are true?
Helps in identifying unexpected issues in the application and debugging them.
Maintains the source code version.
Detect the test file and test functions automatically.
Keeping track of the application's events.
Show answer
Correct answers
Helps in identifying unexpected issues in the application and debugging them.
Keeping track of the application's events.
Question 20
Consider following flask app.
from flask import Flaskfrom 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?
Show answer
Correct answers
Question 21
Consider the following flask application running on the base URL and is accessed through a browser. Select the correct option(s).
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)Show answer
Correct answers
Question 22
Which of the following statements regarding the version control system git is/are correct?
Show answer
Correct answers
Question 23
Consider the following Python code snippet.
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?
Show answer
Correct answer
Question 24
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
from flask import Flask, make_responsefrom flask_restful import Resource, Api, reqparsefrom 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)Show answer
Correct answer
Question 25
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
from flask import Flask, make_responsefrom flask_restful import Resource, Api, reqparsefrom 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)Show answer
Correct answer
Question 26
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
from flask import Flask, make_responsefrom flask_restful import Resource, Api, reqparsefrom 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)Show answer
Correct answer
Question 27
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?
20
27
83
125
Show answer
Correct answer
27
Question 28
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?
8
12
16
20
Show answer
Correct answer
16
Question 29
Consider the following tables ‘product’ and ‘category’ that represent models ‘Product’ and ‘Category’ in SQLite database and answer the given subquestions.
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?
Multiple instances of Product can belong to a single instance of Category.
Multiple instances of Category can belong to a single instance of Product but the converse in not true.
Multiple instances of Product can belong to a single instance of Category and vice versa.
One instance of Category can belong to any one instance of Product only.
Show answer
Correct answer
Multiple instances of Product can belong to a single instance of Category.
Question 30
Consider the following tables ‘product’ and ‘category’ that represent models ‘Product’ and ‘Category’ in SQLite database and answer the given subquestions.
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:
Show answer
Correct answer
Question 31
Consider the following resource API created with help of flask_restful.
from flask import Flask, requestfrom 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.
Show answer
Correct answer
Question 32
Consider the following resource API created with help of flask_restful.
from flask import Flask, requestfrom 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.
Show answer
Correct answer
