MAD 1 End Term: 30 April 2023, Set QPD1-S2 (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-S2: 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
- 26
- 6
Show answer
Correct answer
Question 2
Show answer
Correct answer
Question 3
Consider the following two statements and select the correct option.
Statement 1: Server-level logging can only indicate which URLs were accessed
Statement 2: Server-level logging can indicate if large number of requests were made in a short duration of time such as in DDoS attacks
Statement 1 is true, while statement 2 is false
Statement 2 is true, while statement 1 is false
Both statements 1 and 2 are correct
Both statements 1 and 2 are incorrect
Show answer
Correct answer
Both statements 1 and 2 are correct
Question 4
Consider the following statements about HTML4 and HTML5 and select the correct option. Statement 1: The HTML gets separated out from SGML from its fourth version, HTML4. Statement 2: HTML5 has additional support for latest features like multimedia support, canvases etc. and it has its own parsing rules.
Both statements 1 and 2 are correct.
Both statements 1 and 2 are incorrect.
Statement 1 is correct but statement 2 is incorrect.
Statement 2 is correct but statement 1 is incorrect.
Show answer
Correct answer
Statement 2 is correct but statement 1 is incorrect.
Question 5
Consider the following statements and select the correct option.
Statement 1: Replication is used to improve performance and decrease server load.
Statement 2: Redundancy ensures data is not lost if a copy gets destroyed.
Statement 1 is true & statement 2 is false
Statement 2 is true & statement 1 is false
Both statements 1 and 2 are true
Both statements 1 and 2 are false
Show answer
Correct answer
Both statements 1 and 2 are true
Question 6
Read the following statements regarding web accessibility principles and choose the correct option.
Statement 1: Understandable information and users interface helps developers to avoid and correct mistakes in their content.
Statement 2: Perceivable information ensures that the content does not cause any seizures and physical reaction to its users.
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 correct but statement 2 is incorrect
Question 7
1-C, 2-D, 3-A, 4-B
1-C, 2-A, 3-D, 4-B
1-B, 2-A, 3-D, 4-C
1-A, 2-D, 3-B, 4-C
Show answer
Correct answer
1-C, 2-A, 3-D, 4-B
Question 8
A customer can exist without having any orders
An order can exist without belonging to any customer
A customer needs to have at least one order
An order must belong to one and only one customer
Show answer
Correct answers
A customer can exist without having any orders
An order must belong to one and only one customer
Question 9
Consider the following code snippet.
@app.route('/user/<username>')def profile(username): # CODE BLOCK HEREAssume the database has a "User" table which has a TEXT column "username". If we want the server to return a 404 status code when a user goes to the route '/user/<username>' with a username that does not exist in the database, which of the following lines would give us the desired output?
Show answer
Correct answers
Question 10
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 11
Consider the following users list.
users = [{ "id":1, "name": "user_1", "role": "manager"}, { "id":2, "name": "user_2", "role": "manager"}, { "id":3, "name": "user_3", "role": "manager"}]An ordered HTML list is to be created for users where every list item should have a clickable “name” attribute redirecting to the endpoint “/show_users/<id>” where “id” is the “id” attribute of the same user dictionary. The correct way of doing it with jinja and HTML is ________.
Show answer
Correct answers
Question 12
Consider the following code snippet.
def foo(x,y): if x < 0: y += 1 if y > 0: x -= 1 return x + yTest:
foo(-1, 1)foo(1, -1)Which of the following is correct regarding the coverage of the test?
100% statement coverage
100% function coverage
100% branch coverage
100% condition coverage
Show answer
Correct answers
100% statement coverage
100% function coverage
100% branch coverage
Question 13
a = 8; b = 10; c = 16;
a = 10; b = 2; c = 16;
a = 8; b = 16; c = 10;
a = 2; b = 16; c = 8;
Show answer
Correct answer
a = 8; b = 16; c = 10;
Question 14
Consider the following HTML file and select the correct option.
<!DOCTYPE html><html lang="en"><body> <table id="rows"> <tr> <th>Name</th> <th>City</th> </tr> </table> <button onclick="perform()">action</button> <script> function perform(){ let row = document.createElement("tr") let td1 = document.createElement("td") td1.innerText = "name_1" let td2 = document.createElement("td") td2.innerText = "city_1" row.appendChild(td1) row.appendChild(td2) let rows = document.getElementById("rows") rows.appendChild(row) } </script></body></html>The action button when clicked adds a new column to the table with value “city_1”.
The action button when clicked adds a new column to the table with value “name_1”.
The action button when clicked adds a new row to the table with values “name_1” in the first column and “city_1” in the second column.
The action button when clicked adds a new row to the table with values “city_1” in the first column and “name_1” in the second column.
Show answer
Correct answer
The action button when clicked adds a new row to the table with values “name_1” in the first column and “city_1” in the second column.
Question 15
Consider a discourse forum where a user unlocks the ability to post images once he makes more than 25 posts. What kind of access control is this?
Role-based access control
Attribute-based access control
Both role-based and attribute-based access control
None of these
Show answer
Correct answer
Attribute-based access control
Question 16
Show answer
Correct answer
Question 17
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 and statement 2 both are correct.
Statement 1 and statement 2 both are incorrect.
Statement 1 is correct and statement 2 is incorrect.
Statement 1 is incorrect and statement 2 is correct.
Show answer
Correct answer
Statement 1 and statement 2 both are correct.
Question 18
A → 1, B → 2, C → 4, D → 3
A → 4, B → 3, C → 2, D → 1
A → 4, B → 1, C → 2, D → 3
A → 3, B → 2, C → 1, D → 4
Show answer
Correct answer
A → 1, B → 2, C → 4, D → 3
Question 19
Show answer
Correct answer
Question 20
Show answer
Correct answer
Question 21
Consider the following Python code snippet.
from math import factorial
def prettify(func): def wrapper(num): try: return func(num) except: return "Please check your number!" return wrapper
@prettifydef fact(num): return factorial(num)
out = fact(-4)print(out)What will the output if the above Python code is run on the terminal?
Show answer
Correct answer
Question 22
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 correct but statement 2 is incorrect
Question 23
Consider a function remainder, and a set of test cases given below.
Filename: test_file.py
def remainder(numerator, denominator): rem = numerator % denominator return rem
def test_func0(): assert remainder(5,7) == 5
def test_function1(): assert remainder(20,4) == 3
def test_func2(): assert remainder(31,8) == 6
def test_function3(): assert remainder(2,3) == 2What will be the output on the terminal for the command pytest test_file.py -k func ?
Show answer
Correct answer
Question 24
Consider the following models Library and Book corresponding to tables library and book in SQLite database.
class Library(db.Model): id = db.Column(db.Integer(), primary_key = True) name = db.Column(db.String(), unique = True)
class Book(db.Model): id = db.Column(db.Integer(), primary_key = True) name = db.Column(db.String(), unique = True) library = db.Column(db.Integer(), unique = True, db.ForeignKey("library.id"))Based on the model schemas, what relationship do the classes Library and Book share?
Many-to-Many
One-to-Many
One-to-One
The tables are not at all related
Show answer
Correct answer
One-to-One
Question 25
Consider the <span> element and the styling given to it in <style> tag using element selector in the HTML file below.
<!DOCTYPE html><html lang="en"><head> <title>Span</title> <style> span{ color: red; border:1px solid blue; } </style></head><body> <span id="this_span">Hello Students! MAD-I welcomes you! </span></body></html>What will be the final style applied to <span> tag if an additional style is added via the ID selector given below?
#this_span{ width: 1200px; border: 2px solid pink; }Show answer
Correct answer
Question 26
Software package A
Software package B
Both Software packages A and B will take same time to process 10⁶ items
Both Software packages A and B will take infinitely long time to process 10⁶ items
Show answer
Correct answer
Software package A
Question 27
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[::-1])print(rendered)How will the browser render the output of the above given Python code?
Show answer
Correct answer
Question 28
Based on the above data, answer the given subquestions.
At what distance (kms) should the router be placed from the client so that round-trip latency of the network remains as low as 110 milliseconds?
6000 kilometers
4500 kilometers
7500 kilometers
8000 kilometers
Show answer
Correct answer
4500 kilometers
Question 29
Based on the above data, answer the given subquestions.
What will be the round-trip latency (milliseconds) of the network if the router is placed at exactly midway from the client and the server?
6
60
110
120
Show answer
Correct answer
120
Question 30
Consider the Amazon Alexa device. Which of the following would constitute the view of the application behind such a device?
The AI voice
The LED light around the device
The body of the device
None of these
Show answer
Correct answers
The AI voice
The LED light around the device
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, '/india','/india/<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, '/india','/india/<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
