
Modern Application Development I End Term: 13 April 2025, Set QDD1 (January 2025 term)
The IIT Madras BS Modern Application Development I (MAD 1) End Term paper sat on 13 Apr 2025, in the January 2025 term, set QDD1: 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
Consider the following Python code snippet.
from jinja2 import Template
newlist = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig']
this_template = """ {% for item in data %} {% if item|length<6 %} {{ item }} {% endif %} {% endfor %} """
out = Template(this_template)
print(out.render(data=newlist))What will be the output on the terminal?
Show answer
Correct answer
Question 3
Show answer
Correct answer
Question 4
1-c, 2-a, 3-d, 4-b
1-d, 2-c, 3-a, 4-b
1-c, 2-d, 3-b, 4-a
1-c, 2-d, 3-a, 4-b
Show answer
Correct answer
1-c, 2-d, 3-a, 4-b
Question 5
Consider the following example:
<form> <label for="search-input">Search for a word:</label> <input type="text" id="search-input" placeholder="Type a word to search" aria-describedby="search-help" required /> <small id="search-help">Enter a word to find relevant results.</small> <button type="submit">Start Search</button></form>Which of the following accessibility principles is followed in this example?
Perceivable
Operable
Understandable
Robust
Show answer
Correct answer
Understandable
Question 6
A Flask application and its absolute path is given below.
C:\home\mad_1>app.py
from flask import Flask, url_forimport sys
def create_path(): if len(sys.argv) < 2: return '/static' else: return f'/{sys.argv[1]}'
app = Flask(__name__, static_url_path = create_path())
@app.route('/home')def display(): return f"<h3>static url path: {app.static_url_path}</h3>\ <h3>static folder: {app.static_folder}</h3>"
app.run(debug = True)If the application is run locally on http://127.0.0.1:5000 using the command python app.py stable, what will be rendered by the browser for URL http://127.0.0.1:5000/home?
Show answer
Correct answer
Question 7
1- b, 2 - a, 3- d, 4 - c
1- c, 2 - d, 3- d, 4 - b
1- c, 2 - a, 3- d, 4 - b
1- a, 2 - c, 3- b, 4 - d
Show answer
Correct answer
1- c, 2 - a, 3- d, 4 - b
Question 8
A Server S needs to retrieve data from two datacenters D1 and D2 located at 1500 kilometres and 3000 kilometres respectively. Server S and D1 are connected via medium M1 through which information can be transferred with the speed of 1.5×10⁸ m/sec, and server S and D2 are connected via medium M2. If the server received data from both the data centres at the same time, what must be the speed of information transfer in medium M2(overheads should be ignored)?
(Concept: Performance parameters of a network)
Show answer
Correct answer
Question 9
3000
6000
9000
12000
Show answer
Correct answer
6000
Question 10
64.8
18
5.4
22.5
Show answer
Correct answer
5.4
Question 11
Consider the following flask app. Given that test_request_context() allows text to be printed on the terminal, which of the following statements is correct?
from flask import Flask, url_for
app = Flask(__name__)
@app.route('/hello')def hello(): return 'Hello World!'
@app.route('/user/<username>')def user(username): return f'Welcome {username}!'
with app.test_request_context(): #== print statement ==#Show answer
Correct answer
Question 12
Consider the following Python code snippet.
from flask import Flaskfrom flask_restful import Api, Resource
app = Flask(__name__)api = Api(app)
class MyApi(Resource): def get(self): return {"message":"Hello user!"}
def put(self): return {"message":"Hello World!"}
api.add_resource(MyApi, '/api/get', '/api/put', '/api/post')
app.run()If this application is running locally on http://127.0.0.1:5000, which of the following curl commands will throw an error?
curl http://127.0.0.1:5000/api/get -X getcurl http://127.0.0.1:5000/api/put -X putcurl http://127.0.0.1:5000/api/post -X postcurl http://127.0.0.1:5000/api/get -X putcurl http://127.0.0.1:5000/api/put -X getcurl http://127.0.0.1:5000/api/post -X get
Only 3
Only 3 and 4
Only 5 and 6
Only 3, 4, 5 and 6
Show answer
Correct answer
Only 3
Question 13
Consider the following HTML code .
File name: login.html
<!DOCTYPE html><html lang="en"><head> <title>Login Page</title></head><body> <form action="/"> <label for="uname">Username</label><br> <input type="text" name="uname" id="uname"><br> <label for="pwd">Password</label><br> <input type="password" name="pwd" id="pwd"><br> <input type="submit" value="Login"> </form></body></html>When the user clicks on the “Login” button the form data will be sent to the server using which HTTP method?
GET
POST
PUT
DELETE
Show answer
Correct answer
GET
Question 14
Consider the code below in a file called test_students.py.
test_students.py
import pytest
@pytest.fixturedef students(): return {"names": ["ravi", "raj"], "ages": [12, 9]}
@pytest.mark.checkdef test_name(students): assert "ravi" in students['names']
@pytest.mark.checkdef test_age(students): assert students['ages'][0] > 9
def test_check(students): assert "raj" not in students['names']What will be the output on the terminal on running the command “pytest -m check”? (assume that the tests ran in 0.03s and that the markers have been registered)
Show answer
Correct answer
Question 15
Consider the following Python code.
File name: main.py
def funA(func): def inner_wrapper(): print("Wrapper function of funA") res1 = func() res2 = func() return res1, res2
return inner_wrapper
@funAdef funB(): return "I am from funB"
print(funB())What will be the output, when running the above code using the command “python main.py”?
Show answer
Correct answer
Question 16
Consider the following Python code
File name: main_test.py
import pytest
class TestGroup:
def do_something(self, x, y): return x % y
def test_one(self): assert self.do_something(10, 5) == 0, " Is 5 factor of 10? "
def test_two(self): assert self.do_something(32, 5) == 0, " Is 5 factor of 32 "What will be the output of running the above python script using command line “pytest -v main_test.py”?
Show answer
Correct answer
Question 17
Consider the following Jinja2 templating code:
from jinja2 import Template
template_str = """{% set gifts = [ {'name': 'Teddy Bear', 'price': 250, 'rating': 4.2}, {'name': 'Coffee Mug', 'price': 150, 'rating': 4.5}, {'name': 'Keychain', 'price': 100, 'rating': 3.9}, {'name': 'Notebook', 'price': 180, 'rating': 4.7}, {'name': 'Wall Clock', 'price': 300, 'rating': 4.0}] %}
<ul> {% for gift in gifts if gift.price < 200 and gift.rating > 4 %} <li>{{ gift.name }} - {{ gift.price }} - {{ gift.rating }}</li> {% endfor %}</ul>"""
template = Template(template_str)rendered_str = template.render()print(rendered_str)Will the above Jinja templating code return the correct output? If yes, what will be the result?
Show answer
Correct answer
Question 18
You are given a project with three files: conftest.py, test_multiples_of_3_and_6.py, and test_multiples_of_13.py. The purpose of the tests is to verify if numbers generated by each function are divisible by 39. However, there is a setup issue in this project.
conftest.pycontains a fixture that provides test data.test_multiples_of_3_and_6.pyhas two functions: one checks divisibility by 3, and the other by 6.test_multiples_of_13.pycontains a function to check divisibility by 13.
Here is the content of each file:
conftest.py
import pytest
@pytest.fixturedef divisible_by_39(): return 39 # Fixture providing the number to be testedtest_multiples_of_3_and_6.py
import pytest
def test_divisible_by_3(divisible_by_39): assert divisible_by_39 % 3 == 0 # Checks if divisible by 3
def test_divisible_by_6(divisible_by_39): assert divisible_by_39 % 6 == 0 # Checks if divisible by 6test_multiples_of_13.py
import pytest
def test_divisible_by_13(divisible_by_39): assert divisible_by_39 % 13 == 0 # Checks if divisible by 13When you run pytest -k divisible , which of the following is true?
Show answer
Correct answer
Question 19
A client machine and a server machine located 120 kilometers apart start moving towards each other along a straight line at 400 kmph and 800 kmph respectively. At the same time, the client starts sending requests to the server and the server sends back the response to the client. This client-server network continues to send requests and receive responses (with a new request being sent only after the response is received by the client for the previous one) until both the server and the client collide with each other. Calculate the total distance travelled (in kms) by the request data and the response data together before the two machines collide with each other?(assume the speed of request and response to be m/s )
Show answer
Correct answer
Question 20
1-c, 2-b, 3-a, 4-d
1-c, 2-d, 3-a, 4-b
1-b, 2-a, 3-b, 4-d
1-b, 2-b, 3-a, 4-a
Show answer
Correct answer
1-b, 2-b, 3-a, 4-a
Question 21
Consider a flask app "app.py" and a template file "doc.html" given below:
Python file: app.py
from flask import Flask, render_template
app = Flask(__name__)
itemlist = [ {'value': '0', 'content': 'zero'}, {'value': '1', 'content': 'one'}, {'value': '2', 'content': 'two'}, {'value': '3', 'content': 'three'}, ]
@app.route('/')def func(): return render_template('doc.html', itemlist = itemlist)
app.run()Template file: doc.html
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"></head><body> {% macro render_field(value='field value', content='content value') %} <option value="{{value}}">{{content}}</option> {% endmacro %}
{% for item in itemlist %} {{ render_field(item.content) }} {% endfor %}</body></html>If the application is running locally on http://127.0.0.1:5000. What will be the raw HTML body of the file rendered by the flask app for base url?
Show answer
Correct answer
Question 22
Which of the following statements about networking concepts (TCP, UDP, Proxy, Peer-to-Peer, Broadcast, Unicast, Multicast) are correct?
TCP is a connection-oriented protocol that ensures reliable data delivery.
UDP is a connectionless protocol that is faster but less reliable than TCP.
Proxy servers facilitate direct peer-to-peer connections between devices.
Broadcast sends a message to all devices in the network.
Unicast is a one-to-many communication model.
Show answer
Correct answers
TCP is a connection-oriented protocol that ensures reliable data delivery.
UDP is a connectionless protocol that is faster but less reliable than TCP.
Broadcast sends a message to all devices in the network.
Question 23
Consider the following route in the flask for a signup page and select the correct option:
@app.route('/signup', methods=['GET', 'POST'])def signup(): if request.method == 'GET': return """<form action='/signup' method='POST'> <label for='username'>Username</label> <input type='text' name='username' required> <label for='password'>Password</label> <input type='text' name='password' required minlength="8"> <input type='submit' value='Submit'> </form> """ if request.method == 'POST': if request.form.get('username') is None: return redirect(url_for(signup)) if request.form.get('password') is None: return redirect(url_for(signup)) if len(request.form.get('password')) < 8: return redirect(url_for(signup)) return f"<h1>Welcome, {request.form.get('username')}!</h1>"The signup page is dynamically generated.
The signup page uses server-side rendering.
The signup page uses frontend validation.
The signup page uses backend validation.
Show answer
Correct answers
The signup page is dynamically generated.
The signup page uses server-side rendering.
The signup page uses frontend validation.
The signup page uses backend validation.
Question 24
Show answer
Correct answers
Question 25
The following Flask-RESTful API code snippet is intended to create a RESTful API for managing student registrations in an IITM BS degree program. However, there is an error in the code that prevents it from functioning correctly.
from flask import Flask, jsonify, requestfrom flask_restful import Api, Resource
app = Flask(__name__)api = Api(app)
students = []
class Student(Resource): def get(self, student_id): for student in students: if student["id"] == student_id: return jsonify(student) return jsonify({"message": "Student not found"}), 404
def post(self): data = request.get_json() new_student = { "id": data["id"], "name": data["name"] } students.append(new_student) return jsonify({"message": "Student added successfully"})
api.add_resource(Student, "/student/<int:student_id>")
if __name__ == "__main__": app.run(debug=True)Error:
When trying to use the POST method to add a student, it throws a TypeError stating that the route does not match the method. Identify the correct option to fix the error in the code.
Show answer
Correct answers
Question 26
Consider the following Flask app code.
from flask import Flask, requestvalid_users = [ {"uid": "student", "pwd": "12345"}, {"uid": "professor", "pwd": "54321"}, {"uid": "hod", "pwd": "abcde"},]
app = Flask(__name__)
@app.route("/signin")def login(): args = request.args for vu in valid_users: if vu["uid"] == args["uid"] and vu["pwd"] == args["pwd"]: return "You are authorized!!" else: return "You are unauthorized!!"
app.run(debug=True)Assume the above flask app runs on “http://127.0.0.1:5000/” and is accessed through the web browser. Select the URL(s) that render Not Found error.
Show answer
Correct answers
Question 27
The students of IITM BS challenged their instructors to a cricket match. A Flask web application is built to track the scores. Below is the Flask app code that defines multiple routes for fetching scores dynamically.
from flask import Flask
app = Flask(__name__)
@app.route('/')def home(): return "Welcome to the IITM BS Cricket Match Scoreboard!"
@app.route('/score/<team>')def team_score(team): scores = {"students": 120, "instructors": 115} return f"{team.capitalize()} Score: {scores.get(team, 'Team not found')}"
@app.route('/score/<team>/<player>')def player_score(team, player): players = { "students": {"Rahul": 45, "Ananya": 30, "Karthik": 25}, "instructors": {"Prof.Prashant": 40, "Prof.Mayur": 35, "Dr.Subendu": 20} } return f"{player} ({team.capitalize()}) Scored: {players.get(team, {}).get(player, 'Player not found')}"
if __name__ == "__main__": app.run(debug=True)Based on the above data, answer the given subquestions.
Students Score: 120
students Score : 120
Team not found
Score: students
Show answer
Correct answer
Students Score: 120
Question 28
The students of IITM BS challenged their instructors to a cricket match. A Flask web application is built to track the scores. Below is the Flask app code that defines multiple routes for fetching scores dynamically.
from flask import Flask
app = Flask(__name__)
@app.route('/')def home(): return "Welcome to the IITM BS Cricket Match Scoreboard!"
@app.route('/score/<team>')def team_score(team): scores = {"students": 120, "instructors": 115} return f"{team.capitalize()} Score: {scores.get(team, 'Team not found')}"
@app.route('/score/<team>/<player>')def player_score(team, player): players = { "students": {"Rahul": 45, "Ananya": 30, "Karthik": 25}, "instructors": {"Prof.Prashant": 40, "Prof.Mayur": 35, "Dr.Subendu": 20} } return f"{player} ({team.capitalize()}) Scored: {players.get(team, {}).get(player, 'Player not found')}"
if __name__ == "__main__": app.run(debug=True)Based on the above data, answer the given subquestions.
Dr.Prashant (Instructors) Scored: 40
Dr.Prashant (Instructors) Scored: Player not found
Player not found
Internal Server Error
Show answer
Correct answer
Dr.Prashant (Instructors) Scored: Player not found
Question 29
A college counseling system is designed to store and retrieve student records efficiently. The system uses different types of storage based on latency, throughput, and density. During peak counseling sessions, thousands of students access their academic records, appointment schedules, and previous counseling notes. The system needs to optimize storage selection for different types of data:
1. Frequently accessed small data (e.g., currently active student records)
2. Large archives of past counseling records (rarely accessed but need long-term storage) 3. Temporary session data that needs to be quickly read and updated during counseling sessions Based on the above data, answer the given subquestions.
Which of the following storage types should be used for storing frequently accessed small student records that need low latency and high-speed access?
Hard Disk Drive (HDD)
Solid State Drive (SSD)
Static RAM (SRAM)
Registers
Show answer
Correct answer
Static RAM (SRAM)
Question 30
A college counseling system is designed to store and retrieve student records efficiently. The system uses different types of storage based on latency, throughput, and density. During peak counseling sessions, thousands of students access their academic records, appointment schedules, and previous counseling notes. The system needs to optimize storage selection for different types of data:
1. Frequently accessed small data (e.g., currently active student records)
2. Large archives of past counseling records (rarely accessed but need long-term storage) 3. Temporary session data that needs to be quickly read and updated during counseling sessions Based on the above data, answer the given subquestions.
The college wants to store archived counseling records from past students for future reference. These records are rarely accessed, but cost efficiency and storage density are important. Which storage type is best suited?
Registers
SRAM
DRAM
Hard Disk Drive (HDD)
Show answer
Correct answer
Hard Disk Drive (HDD)
Question 31
Consider the following data models representing SQLite database tables and answer the given sub-questions.
class Student(db.Model): __tablename__ = "student" id=db.Column(db.Integer, primary_key=True) name=db.Column(db.String,not_null=False) tests=db.relationship('TestMarks',backref="student")
class TestMarks(db.Model): __tablename__ = "test_marks" id=db.Column(db.Integer, primary_key=True) test_name=db.Column(db.String,not_null=False) marks=db.Column(db.Integer,not_null=True) student_id=db.Column(db.Integer,db.ForeignKey('student.id'))Which of the following statements is/are True?
Show answer
Correct answers
Question 32
Consider the following data models representing SQLite database tables and answer the given sub-questions.
class Student(db.Model): __tablename__ = "student" id=db.Column(db.Integer, primary_key=True) name=db.Column(db.String,not_null=False) tests=db.relationship('TestMarks',backref="student")
class TestMarks(db.Model): __tablename__ = "test_marks" id=db.Column(db.Integer, primary_key=True) test_name=db.Column(db.String,not_null=False) marks=db.Column(db.Integer,not_null=True) student_id=db.Column(db.Integer,db.ForeignKey('student.id'))Which of the following is the correct way of adding records into the ‘student’ and the ‘test_marks’ tables?
Show answer
Correct answer