uiz Space

January 2025 term · Modern Application Development I · BSCS2003

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.

Questions
32
Marks
100
Duration
180 min
MCQ
26
MSQ
6

Updated

Official paper: IIT M DIPLOMA AN EXAM QDD3 13 Apr 2025 · No negative marking.

Question 1

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

Correct answer

  • C

Question 2

+2 marksOne correct option

Consider the following Python code snippet.

python
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?

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

Correct answer

  • B

Question 3

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

Correct answer

  • C

Question 4

+2 marksOne correct option
  1. A

    1-c, 2-a, 3-d, 4-b

  2. B

    1-d, 2-c, 3-a, 4-b

  3. C

    1-c, 2-d, 3-b, 4-a

  4. D

    1-c, 2-d, 3-a, 4-b

Show answer

Correct answer

  • D

    1-c, 2-d, 3-a, 4-b

Question 5

+3 marksOne correct option

Consider the following example:

html
<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?

  1. A

    Perceivable

  2. B

    Operable

  3. C

    Understandable

  4. D

    Robust

Show answer

Correct answer

  • C

    Understandable

Question 6

+3 marksOne correct option

A Flask application and its absolute path is given below.

text
C:\home\mad_1>

app.py

python
from flask import Flask, url_for
import 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?

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

Correct answer

  • D

Question 7

+3 marksOne correct option
  1. A

    1- b, 2 - a, 3- d, 4 - c

  2. B

    1- c, 2 - d, 3- d, 4 - b

  3. C

    1- c, 2 - a, 3- d, 4 - b

  4. D

    1- a, 2 - c, 3- b, 4 - d

Show answer

Correct answer

  • C

    1- c, 2 - a, 3- d, 4 - b

Question 8

+3 marksOne correct option

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)

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

Correct answer

  • D

Question 9

+3 marksOne correct option
  1. A

    3000

  2. B

    6000

  3. C

    9000

  4. D

    12000

Show answer

Correct answer

  • B

    6000

Question 10

+3 marksOne correct option
  1. A

    64.8

  2. B

    18

  3. C

    5.4

  4. D

    22.5

Show answer

Correct answer

  • C

    5.4

Question 11

+3 marksOne correct option

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?

python
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 ==#
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 12

+3 marksOne correct option

Consider the following Python code snippet.

python
from flask import Flask
from 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?

  1. curl http://127.0.0.1:5000/api/get -X get
  2. curl http://127.0.0.1:5000/api/put -X put
  3. curl http://127.0.0.1:5000/api/post -X post
  4. curl http://127.0.0.1:5000/api/get -X put
  5. curl http://127.0.0.1:5000/api/put -X get
  6. curl http://127.0.0.1:5000/api/post -X get
  1. A

    Only 3

  2. B

    Only 3 and 4

  3. C

    Only 5 and 6

  4. D

    Only 3, 4, 5 and 6

Show answer

Correct answer

  • A

    Only 3

Question 13

+3 marksOne correct option

Consider the following HTML code .

File name: login.html

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?

  1. A

    GET

  2. B

    POST

  3. C

    PUT

  4. D

    DELETE

Show answer

Correct answer

  • A

    GET

Question 14

+3 marksOne correct option

Consider the code below in a file called test_students.py.

test_students.py

python
import pytest
@pytest.fixture
def students():
return {"names": ["ravi", "raj"], "ages": [12, 9]}
@pytest.mark.check
def test_name(students):
assert "ravi" in students['names']
@pytest.mark.check
def 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)

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

Correct answer

  • A

Question 15

+3 marksOne correct option

Consider the following Python code.

File name: main.py

python
def funA(func):
def inner_wrapper():
print("Wrapper function of funA")
res1 = func()
res2 = func()
return res1, res2
return inner_wrapper
@funA
def funB():
return "I am from funB"
print(funB())

What will be the output, when running the above code using the command “python main.py”?

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

Correct answer

  • B

Question 16

+3 marksOne correct option

Consider the following Python code

File name: main_test.py

python
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”?

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

Correct answer

  • A

Question 17

+4.5 marksOne correct option

Consider the following Jinja2 templating code:

python
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?

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

Correct answer

  • A

Question 18

+4.5 marksOne correct option

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.py contains a fixture that provides test data.
  • test_multiples_of_3_and_6.py has two functions: one checks divisibility by 3, and the other by 6.
  • test_multiples_of_13.py contains a function to check divisibility by 13.

Here is the content of each file:

conftest.py

python
import pytest
@pytest.fixture
def divisible_by_39():
return 39 # Fixture providing the number to be tested

test_multiples_of_3_and_6.py

python
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 6

test_multiples_of_13.py

python
import pytest
def test_divisible_by_13(divisible_by_39):
assert divisible_by_39 % 13 == 0 # Checks if divisible by 13

When you run pytest -k divisible , which of the following is true?

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

Correct answer

  • C

Question 19

+4.5 marksOne correct option

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 3 x 1083\ x\ 10^{8} m/s )

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

Correct answer

  • C

Question 20

+4.5 marksOne correct option
  1. A

    1-c, 2-b, 3-a, 4-d

  2. B

    1-c, 2-d, 3-a, 4-b

  3. C

    1-b, 2-a, 3-b, 4-d

  4. D

    1-b, 2-b, 3-a, 4-a

Show answer

Correct answer

  • D

    1-b, 2-b, 3-a, 4-a

Question 21

+4.5 marksOne correct option

Consider a flask app "app.py" and a template file "doc.html" given below:

Python file: app.py

python
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

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?

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

Correct answer

  • B

Question 22

+3 marksOne or more correct options

Which of the following statements about networking concepts (TCP, UDP, Proxy, Peer-to-Peer, Broadcast, Unicast, Multicast) are correct?

Select all that apply.

  1. A

    TCP is a connection-oriented protocol that ensures reliable data delivery.

  2. B

    UDP is a connectionless protocol that is faster but less reliable than TCP.

  3. C

    Proxy servers facilitate direct peer-to-peer connections between devices.

  4. D

    Broadcast sends a message to all devices in the network.

  5. E

    Unicast is a one-to-many communication model.

Show answer

Correct answers

  • A

    TCP is a connection-oriented protocol that ensures reliable data delivery.

  • B

    UDP is a connectionless protocol that is faster but less reliable than TCP.

  • D

    Broadcast sends a message to all devices in the network.

Question 23

+3 marksOne or more correct options

Consider the following route in the flask for a signup page and select the correct option:

python
@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>"

Select all that apply.

  1. A

    The signup page is dynamically generated.

  2. B

    The signup page uses server-side rendering.

  3. C

    The signup page uses frontend validation.

  4. D

    The signup page uses backend validation.

Show answer

Correct answers

  • A

    The signup page is dynamically generated.

  • B

    The signup page uses server-side rendering.

  • C

    The signup page uses frontend validation.

  • D

    The signup page uses backend validation.

Question 24

+3 marksOne or more correct options

Select all that apply.

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

Correct answers

  • A
  • B

Question 25

+4.5 marksOne or more correct options

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.

python
from flask import Flask, jsonify, request
from 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.

Select all that apply.

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

Correct answers

  • A
  • B

Question 26

+4.5 marksOne or more correct options

Consider the following Flask app code.

python
from flask import Flask, request
valid_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.

Select all that apply.

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

Correct answers

  • B
  • D

Question 27

+2 marksOne correct option

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.

python
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.

  1. A

    Students Score: 120

  2. B

    students Score : 120

  3. C

    Team not found

  4. D

    Score: students

Show answer

Correct answer

  • A

    Students Score: 120

Question 28

+4.5 marksOne correct option

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.

python
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.

  1. A

    Dr.Prashant (Instructors) Scored: 40

  2. B

    Dr.Prashant (Instructors) Scored: Player not found

  3. C

    Player not found

  4. D

    Internal Server Error

Show answer

Correct answer

  • B

    Dr.Prashant (Instructors) Scored: Player not found

Question 29

+2 marksOne correct option

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?

  1. A

    Hard Disk Drive (HDD)

  2. B

    Solid State Drive (SSD)

  3. C

    Static RAM (SRAM)

  4. D

    Registers

Show answer

Correct answer

  • C

    Static RAM (SRAM)

Question 30

+2 marksOne correct option

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?

  1. A

    Registers

  2. B

    SRAM

  3. C

    DRAM

  4. D

    Hard Disk Drive (HDD)

Show answer

Correct answer

  • D

    Hard Disk Drive (HDD)

Question 31

+3 marksOne or more correct options

Consider the following data models representing SQLite database tables and answer the given sub-questions.

python
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?

Select all that apply.

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

Correct answers

  • A
  • B
  • D

Question 32

+2 marksOne correct option

Consider the following data models representing SQLite database tables and answer the given sub-questions.

python
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?

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

Correct answer

  • B