Quiz Space

May 2023 term · Modern Application Development I · BSCS2003

MAD 1 End Term: 3 September 2023, Set QPD1-S1 (May 2023 term)

The IIT Madras BS Modern Application Development I (MAD 1) End Term paper sat on 3 Sept 2023, in the May 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
22
MSQ
9
Numerical
1

Updated

Official paper: IIT M DIPLOMA ET1 EXAM QPD1 S2 03 Sep · No negative marking.

Question 1

+2 marksOne correct option

Consider three components of a todo list app based on an MVC architecture.
A - stores a list of all the tasks that the user has submitted along with attributes like completion status.
B - can display which tasks were completed, which tasks are pending, receive new tasks from the user etc.
C - can set a task in the list of tasks as completed, add a new task to the list of tasks, delete old tasks, retrieve a list of pending tasks and so on.
Given the above capabilities of the different components, choose the correct option:

  1. A

    model - A, view - B, controller - C

  2. B

    model - B, view - A, controller - C

  3. C

    model - C, view - B, controller - A

  4. D

    model - A, view - C, controller - B

Show answer

Correct answer

  • A

    model - A, view - B, controller - C

Question 2

+2 marksOne correct option

Which of the following statements is/are correct?
Statement 1: In client-server architecture, the client and the server MUST be on separate machines
Statement 2: In peer-to-peer architecture, the network is always more fault-tolerant

  1. A

    Both statement 1 and statement 2 are correct.

  2. B

    Statement 1 is correct but statement 2 is incorrect.

  3. C

    Statement 2 is correct but statement 1 is incorrect.

  4. D

    Neither statement 1 nor statement 2 is correct.

Show answer

Correct answer

  • D

    Neither statement 1 nor statement 2 is correct.

Question 3

+2 marksOne correct option

In relational databases, a column stores (1) _______ and a row stores (2) ________.

  1. A

    a field, multiple entries

  2. B

    a field, a single entry

  3. C

    a single entry, a field

  4. D

    multiple entries, a field

Show answer

Correct answer

  • B

    a field, a single entry

Question 4

+2 marksOne correct option

Which of the following helps us to create custom HTML elements?

  1. A

    SVG

  2. B

    Web Components

  3. C

    Web API

  4. D

    None of these

Show answer

Correct answer

  • B

    Web Components

Question 5

+2 marksOne correct option

Which of the following git command will remove a file from the staged area but keeps the file in the directory?

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

Correct answer

  • B

Question 6

+4.5 marksOne correct option

Consider the following graph that represents the variation in bandwidth and number of users connected to a network for an entire day (24 hours). What will be the total data consumed (in Gigabytes) by the user that is connected to the internet network throughout the day?

  1. A

    5.216

  2. B

    52.16

  3. C

    6.52

  4. D

    65.20

Show answer

Correct answer

  • C

    6.52

Question 7

+3 marksOne or more correct options

Consider a client ‘C’ and a server ‘S’, separated by distance ‘D’ are connected by a fictitious medium in which the speed of light is ‘v’ m/sec. If ‘N’ is the number of consecutive requests that can made in a second by the client ‘C’ (i.e A new request can be made only after receiving the response from the previous request.), Which of the following changes would double the number ‘N’?

Select all that apply.

  1. A

    A change of medium where the speed of light is v/2 m/sec.

  2. B

    A change of medium where the speed of light is 2v m/sec.

  3. C

    Reduce the distance between C and S from D to D/2.

  4. D

    Increase the distance between C and S from D to 2D.

Show answer

Correct answers

  • B

    A change of medium where the speed of light is 2v m/sec.

  • C

    Reduce the distance between C and S from D to D/2.

Question 8

+3 marksOne or more correct options

Consider the following flask app.

python
from flask import Flask, abort, redirect, url_for, render_template
app = Flask(__name__)
@app.route('/home/<path:directory>')
def find_course(directory):
if "ML" in directory:
return f"Welcome to online course on Data Science!"
else:
abort(404)
@app.errorhandler(404)
def page_not_found(error):
return "<h2>Sorry, No course found!<!h2>"
app.run()

If the application is running locally on http://127.0.0.1:5000, select the correct options.

Select all that apply.

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

Correct answers

  • A
  • B

Question 9

+3 marksOne or more correct options

Which of the following is/are a correct way to use for loop in jinja?

Select all that apply.

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

Correct answers

  • A
  • B
  • D

Question 10

+3 marksOne or more correct options

Consider the following TodoSimple resource class created using flask_restful.

python
from flask import Flask, request
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class TodoSimple(Resource):
def get(self, todo_id):
return {"todo_id": todo_id}
def put(self):
todo_id = request.args.get("todo_id")
return {"todo_id": todo_id}
app.run()

Which of the following statements given below will correctly map the resource URLs with the TodoSimple resource class.

Select all that apply.

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

Correct answers

  • C
  • D

Question 11

+3 marksOne correct option

Consider the following HTML Document.

html
<!DOCTYPE html>
<head>
<title>Test Document</title>
<style>
h4, span {
display: inline-block;
width: 200px;
}
</style>
</head>
<body>
<h4>Statement 1 from Document.</h4>
<h4>Statement 2 from Document.</h4>
<span>Statement 3 from Document.</span>
<span>Statement 4 from Document.</span>
</body>
</html>

How will the browser render the HTML document given above?

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

Correct answer

  • D

Question 12

+3 marksOne correct option
  1. A

    a = 10, b = 8

  2. B

    a = 8, b = 10

  3. C

    a = 16, b = 8

  4. D

    a = 16, b = 10

Show answer

Correct answer

  • C

    a = 16, b = 8

Question 13

+3 marksOne correct option

Consider the following flask app and Jinja2 template.

app.py

python
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template("index.html", links=['hoME', 'PROfile', 'Contact', 'SITEMAP'])
app.run()

index.html

html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Macro</title>
</head>
<body>
{% macro unordered_list(items)%}
<ul>
{% for item in items %}
<li><a href="/{{item}}">{{item|capitalize}}</a></li>
{% endfor %}
</ul>
{% endmacro %}
{{ unordered_list(links) }}
</body>
</html>

If the flask app is running locally on http://127.0.0.1:5000. What will be the output on the browser for the base URL?

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

Correct answer

  • A

Question 14

+3 marksOne correct option

Consider the following Python code snippet.

file.py

python
import sys
courses = {
1: "App Dev I",
2: "App Dev II",
3: "Machine Learning",
4: "Deep learning"
}
arguments = sys.argv
if courses[int(sys.argv[2])] in "App Dev II":
print("course found",courses[int(sys.argv[2])])
else:
print("No course found!")

What will be output on the terminal for the command python file.py courses 1?

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

Correct answer

  • B

Question 15

+3 marksOne correct option

Consider the following function to be tested and test functions given in the Python code snippet below.

python
def sample_function(x):
ser = []
for i in range(x):
ser.append((i)**2)
return ser
def test_func1():
assert 36 in sample_function(7)
def test_func2():
assert 64 in sample_function(8)
def sample_test3():
assert 81 in sample_function(11)

What will be the summary of the output for the command pytest file.py on the terminal?

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

Correct answer

  • D

Question 16

+3 marksOne correct option

Consider the following Python code snippet.

log.py

python
import logging
import sys
logging.basicConfig(level=logging.WARNING,
format='%(asctime)s - %(levelname)s - %(message)s')
def check_val(value):
if value < 0:
raise ValueError("Invalid value: Please enter a positive value.")
else:
logging.info("Value added: %s", value)
try:
input_value = int(sys.argv[1])
check_val(input_value)
except ValueError as ve:
logging.exception("Exception occurred: %s", str(ve))

What will be the output on the terminal for the command: python log.py 34?

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

Correct answer

  • D

Question 17

+3 marksOne correct option

Consider the code below and match the conditions in Column A with respect to the coverage types in Column B.

  1. A

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

  2. B

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

  3. C

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

  4. D

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

Show answer

Correct answer

  • C

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

Question 18

+3 marksOne correct option

Match the following types of testing with their functionality.

  1. A

    A → 1, B → 2, C → 3, D → 4

  2. B

    A → 4, B → 3, C → 2, D → 1

  3. C

    A → 4, B → 1, C → 2, D → 3

  4. D

    A → 3, B → 2, C → 1, D → 4

Show answer

Correct answer

  • C

    A → 4, B → 1, C → 2, D → 3

Question 19

+3 marksOne correct option

Consider the following table “emp” created in SQLite database corresponding to model class “Employee” using flask_sqlalchemy.

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

Correct answer

  • C

Question 20

+3 marksOne correct option

Consider the following python code snippet app.py, the html files, base.html and home.html residing in “templates” folder.

app.py

python
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def home():
return render_template('home.html')
app.run(debug=True)

home.html

html
{% extends "base.html" %}
{% block content %}
<h3>Welcome to MAD I</h3>
{% endblock %}

base.html

html
<!DOCTYPE html>
<html lang="en">
<head>
<title>IITM</title>
</head>
<body>
<h1 style="color: violet;"> IITM BS Degree </h1>
{% block content %}
{% endblock %}
</body>
</html>

What will be the rendered output for base URL if flask app is running locally on http://localhost:5000

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

Correct answer

  • B

Question 21

+3 marksOne correct option

Consider the following SQL create statement.

sql
CREATE TABLE car (
car_id INTEGER NOT NULL,
model INTEGER NOT NULL,
name VARCHAR(50),
mfd_date DATETIME NOT NULL,
description VARCHAR,
PRIMARY KEY (car_id),
UNIQUE (model),
UNIQUE (name)
)

Which of the following flask_sqlalchemy models will create exactly the same table as created by the above SQL command?

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

Correct answer

  • C

Question 22

+2 marksOne or more correct options

What can be inferred from the Entity-Relationship Diagram below:

Select all that apply.

  1. A

    An employee can exist without having any salary slips

  2. B

    A salary slip can exist without belonging to any employee

  3. C

    An employee needs to have at least one salary slip

  4. D

    A salary slip must belong to one and only one employee

Show answer

Correct answers

  • A

    An employee can exist without having any salary slips

  • D

    A salary slip must belong to one and only one employee

Question 23

+2 marksOne or more correct options

Consider a typical Amazon Alexa device. Which of the following would constitute the view of the application behind such a device?

Select all that apply.

  1. A

    The AI voice

  2. B

    The LED light around the device

  3. C

    The body of the device

  4. D

    None of these

Show answer

Correct answers

  • A

    The AI voice

  • B

    The LED light around the device

Question 24

+2 marksOne or more correct options

Which of the following is true of “cold storage” like Amazon Glacier?

Select all that apply.

  1. A

    They have high cost and low durability.

  2. B

    They have low cost and high durability.

  3. C

    Latency of retrieval is very low.

  4. D

    Latency of retrieval is very high.

Show answer

Correct answers

  • B

    They have low cost and high durability.

  • D

    Latency of retrieval is very high.

Question 25

+4.5 marksOne or more correct options

Consider the following flask application.

app.py

python
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/', methods=['GET'])
def my_form():
if request.method == 'GET':
if(request.args.get('name') == None):
return """
<form method="GET" action ="/">
<label for="name">Enter a name: </label>
<input type="text" name="name" id="name"></input>
<input type="submit" name="btnnum"
id="btnnum"></input>
</form>
"""
elif(request.args.get('name') == ''):
return "<h1>Invalid name</h1>"
else:
name = request.args.get('name')
return f"<h2>My name is {name}</h2>"
app.run()

If this flask app is running locally on http://localhost:5000, then which of the following statements is/are incorrect?

Select all that apply.

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

Correct answers

  • B
  • C
  • D

Question 26

+4.5 marksOne or more correct options

Follow the code given below

python
from flask import Flask, request
from flask_restful import Resource, Api, fields, marshal, marshal_with
app = Flask(__name__)
api = Api(app)
class User:
def __init__(self, id, username, email):
self.id=id
self.username=username
self.email=email
output={"id": fields.Integer,"username": fields.String,"email": fields.String}
#== Resource Class Here ======
api.add_resource(Userapi, '/')
if __name__ == '__main__':
app.run()

What code should be written in place of #== Resource Class Here ======, so that we get;

json
{
"id": 1,
"username": "iitm",
"email": "bs@ds.study.iitm.ac.in"
}

as output on running the command curl -X GET 'http://127.0.0.1:5000' in the terminal?

Select all that apply.

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

Correct answers

  • A
  • B

Question 27

+3 marksNumerical answer

Consider the following flask application.

python
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/')
def out():
val = request.args
if val['num'] == '':
return "<h1>Enter a valid number</h1>"
elif val['num'].isalpha()==True:
return "<h1>Invalid number</h1>"
else:
out = (val['num']) + (val['num'])
return f'<h1>{out}</h1>'
if(__name__ == "__main__"):
app.run(debug=True)

If this flask app is running locally on http://localhost:5000, what is the output for the following URL?
For input: http://localhost:5000/?num=121

Show answer

Correct answer: 121121

Question 28

+4.5 marksOne correct option

Consider the following python code snippet. What will be the rendered output?

python
from jinja2 import Template
persons=[
{"Gender":"Male", "Age":40, "Name":"John"},
{"Gender":"Female", "Age":16, "Name":"Samantha"},
{"Gender": "Male", "Age":20, "Name":"Kim"}
]
t="""
<ul>
{% for group in persons|groupby('Gender') %}
<li>
{{ group.grouper }}
<ul>
{% for person in group.list %}
<li>{{ person.Name }} is {{ person.Age }} years old</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
"""
temp=Template(t)
print(temp.render(persons=persons))
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 29

+4.5 marksOne correct option

Consider a function func, and a set of test cases given below.

Filename: test_file.py

python
import pytest
def func(x,y):
out = x+y**2
return out
class Test_class0():
def test_case1(self):
assert func(1,2) == 5
def case_test2(self):
assert func(2,3) == 10
def test_case3(self):
assert func(6,2) == 8
class Test_class1():
def test_case1(self):
assert func(5,2) == 9
def case_test2(self):
assert func(4,3) == 14

What will be the output on the terminal for the command below?

bash
pytest test_file.py -k Test_class0
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 30

+4.5 marksOne correct option

What will be the output of the following Python code snippet?

python
def decor(func):
def wrapper(x):
y=func(x)
return x*y
return wrapper
@decor
def output(x, optional="hello world!"):
return x, optional
print(output(5))
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 31

+4.5 marksOne correct option

Consider the following flask application.

  1. A

    a-2, b-1, c-5, d-6

  2. B

    a-5, b-1, c-2, d-6

  3. C

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

  4. D

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

Show answer

Correct answer

  • C

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

Question 32

+4.5 marksOne correct option

Consider the following sorting algorithm which sorts any given unsorted array of numbers in ascending order. What would be its time complexity? (Assume appending and deleting an element from an array does not affect time complexity)
Step 1: Create an empty array.
Step 2: Find the element in the unsorted array with the minimum value.
Step 3: Append this element to the array created in step 1.
Step 4: Delete this element from the unsorted array.
Step 5: Repeat steps 1 to 4 until the unsorted array is empty.

  1. A

    O(logN)

  2. B

    O(N)

  3. C

    O(NlogN)

  4. D

    O(N²)

Show answer

Correct answer

  • D

    O(N²)