Quiz Space

May 2023 term · Modern Application Development I · BSCS2003

MAD 1 End Term: 3 September 2023, Set QPD1-S2 (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-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.

Questions
32
Marks
100
Duration
180 min
MCQ
24
MSQ
7
Numerical
1

Updated

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

Question 1

+3 marksOne correct option

Consider the following snippet of HTML and its output rendered on the browser:

  1. A

    GET

  2. B

    POST

  3. C

    PUT

  4. D

    DELETE

Show answer

Correct answer

  • A

    GET

Question 2

+3 marksOne correct option

A 6000 rpm magnetic disk is being used to store data. The disk can only spin in one direction and is operating at 6000 revolutions per minute. If the operating system sends a request to the disk controller to fetch data from the disk, but by the time the request reached the disk controller, the information had already moved 35 degrees passed the reader, what will be the latency (in milliseconds) before it can start retrieving data?

  1. A

    0.97

  2. B

    9.03

  3. C

    90.3

  4. D

    97

Show answer

Correct answer

  • B

    9.03

Question 3

+3 marksOne correct option

Consider the following flask resource created using flask_restful.

python
from flask import Flask, request
from flask_restful import Api, Resource, reqparse
app = Flask(__name__)
api = Api(app)
parser = reqparse.RequestParser()
parser.add_argument("val")
class RestApi(Resource):
def post(self, val):
arg1 = parser.parse_args()
arg2 = request.args
return {
"value_1": arg1["val"],
"value_2": arg2["val"],
"value_3": val
}
api.add_resource(RestApi, "/api/games/<val>")
app.run(debug = True)

If the application is running locally on http://127.0.0.1:5000, What will be the output on the terminal for the command:

bash
curl http://127.0.0.1:5000/api/games/cricket?val=soccer -d "{\"val\":\"tennis\"}" -X POST -H "Content-Type: application/json"
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 4

+3 marksOne correct option

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

test_file.py

python
import pytest
def square(x):
sum = 0
for counter in range(x):
sum += x
return sum
@pytest.mark.marker1
def testcase_1():
assert square(11) == 121
@pytest.mark.marker2
def testcase_2():
assert square(8) == 8
@pytest.mark.marker3
def testcase_3():
assert square(5) == 36

On running this file on the terminal using pytest, the summary of the output is;

What command will result into the outcome given above?

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

Correct answer

  • C

Question 5

+3 marksOne correct option
  1. A

    C048 A865

  2. B

    C0A8 4865

  3. C

    C0A8 6548

  4. D

    C065 A848

Show answer

Correct answer

  • B

    C0A8 4865

Question 6

+3 marksOne correct option

An HTML code and CSS code is given below. Which of the following correctly represents its rendered output?

HTML Code:

html
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
<link href="style.css" rel="stylesheet">
<style>
body{background-color: aqua; text-align: center;}
h2{color: violet !important ;}
</style>
</head>
<body style="background-color:lavender;" >
<h2 style="color: blue;">Welcome to IIT</h2>
<p class="one">My content 1 </p>
<p class="two" style="color: brown;" >My content 2</p>
<p class="three">My content 3</p>
</body>
</html>
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 7

+3 marksOne correct option

Consider the following models Student and Project corresponding to tables student and project in SQLite database.

python
class Student(db.Model):
id = db.Column(db.Integer(), primary_key = True)
name = db.Column(db.String(), unique = True)
class Project(db.Model):
id = db.Column(db.Integer(), primary_key = True)
title = db.Column(db.String(), unique = True)
course = db.Column(db.Integer(), db.ForeignKey("course.id"))

Based on the model schemas, what relationship do the classes Student and Project share?

  1. A

    Many-to-Many

  2. B

    One-to-Many

  3. C

    One-to-One

  4. D

    The tables are not at all related

Show answer

Correct answer

  • D

    The tables are not at all related

Question 8

+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, get):
return {"greet":"Hello from GET Api!"}
def put(self):
return {"greet":"Hello from PUT Api!"}
api.add_resource(MyApi,'/api/<get>','/api/put')
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 get
  4. curl http://127.0.0.1:5000/api/get -X put
  1. A

    Only 2 and 4

  2. B

    Only 4

  3. C

    Only 3 and 4

  4. D

    Only 3

Show answer

Correct answer

  • B

    Only 4

Question 9

+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-b, 4-a

  3. C

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

  4. D

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

Show answer

Correct answer

  • B

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

Question 10

+3 marksOne correct option

Match the following types of testing with their functionality.

Which of the following is the correct matching?

  1. A

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

  2. B

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

  3. C

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

  4. D

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

Show answer

Correct answer

  • D

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

Question 11

+3 marksOne correct option

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

Which of the following code snippets will change the designation of male teachers to professor and will increase their salaries to 6000 correctly when typed in the Python console?

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

  • C

Question 13

+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

  • D

Question 14

+2 marksOne correct option

Consider the following statements and select the correct option.
Statement 1: It is not necessary to implement server-side validation if client-side validation has been implemented.
Statement 2: Client-side validation can be implemented with HTML5.

  1. A

    Statement 1 is true while statement 2 is false

  2. B

    Statement 2 is true while statement 1 is false

  3. C

    Both statements are true

  4. D

    Both statements are false

Show answer

Correct answer

  • B

    Statement 2 is true while statement 1 is false

Question 15

+2 marksOne correct option

Consider the following statements and select the correct answer.
Statement 1: In PaaS, developers are provided with an up-to-date development environment with the languages and frameworks of their choice.
Statement 2: Microsoft Azure provides IaaS as well as PaaS services.

  1. A

    Statement 1 is true, but statement 2 is false

  2. B

    Statement 2 is true, but statement 1 is false

  3. C

    Both statements are false

  4. D

    Both statements are true

Show answer

Correct answer

  • D

    Both statements are true

Question 16

+2 marksOne correct option

Consider the following statements and choose the correct option.
Statement 1: If we submit the form using the GET method, then the form data is appended inside the body of the HTTP request.
Statement 2: Never use GET method in form to send sensitive data while it is good for non-secure data, like query strings in Google

  1. A

    Both statements 1 and 2 are true, and statement 2 is a correct explanation of statement 1

  2. B

    Both statements 1 and 2 are true, but statement 2 is not a correct explanation of statement 1

  3. C

    Statement 1 is true and statement 2 is false

  4. D

    Statement 2 is true and statement 1 is false

Show answer

Correct answer

  • D

    Statement 2 is true and statement 1 is false

Question 17

+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

  • D

Question 18

+3 marksOne or more correct options

Consider the following python code snippet.

python
from string import Template
statement = "The four major operations on the database are $c, $r, $u and $d."
temp = Template(statement)
print(=== OUTPUT ===)

Which of the following statements, when substituted in place of === OUTPUT ===, will not throw a KeyError?

Select all that apply.

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

Correct answers

  • A
  • B
  • C
  • D

Question 19

+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

  • B
  • D

Question 20

+2 marksOne or more correct options

Which of the statements are true?

Select all that apply.

  1. A

    HTML5 is based on SGML

  2. B

    XHTML is based on XML which in turn is based on SGML

  3. C

    HTML5 is not backwards compatible with older versions of HTML

  4. D

    XML is both human and machine-readable

Show answer

Correct answers

  • B

    XHTML is based on XML which in turn is based on SGML

  • D

    XML is both human and machine-readable

Question 21

+2 marksOne or more correct options

Choose the correct code snippet to implement logging by importing python logging module

Select all that apply.

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

Correct answers

  • A
  • B
  • C
  • D

Question 22

+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 body of the device

  3. C

    The LED light around the device

  4. D

    None of these

Show answer

Correct answers

  • A

    The AI voice

  • C

    The LED light around the device

Question 23

+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 low cost and high durability.

  2. B

    They have high cost and low durability.

  3. C

    Latency of retrieval is very low.

  4. D

    Latency of retrieval is very high.

Show answer

Correct answers

  • A

    They have low cost and high durability.

  • D

    Latency of retrieval is very high.

Question 24

+4.5 marksOne correct option

Consider the following graph that represents the variation in bandwidth of a network for an entire day (24 hours). Three users were connected to the network at three different times of the day. Which user has consumed the highest amount of data?

  1. A

    User 1

  2. B

    User 2

  3. C

    User 3

  4. D

    All the three users consumed same amount of data

Show answer

Correct answer

  • B

    User 2

Question 25

+4.5 marksOne correct option

Consider the following restful implementation using flask.

python
from flask import Flask, request
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
student_info = {"name": "Rahul", "Roll No":"12d2000678", "Email":"onlinedegree.iitm.ac.in"}
class Student(Resource):
def put(self):
data = request.json
student_info.update(data)
return student_info
def delete(self):
student_info.popitem()
return "success", 200
api.add_resource(Student, '/')
app.run()

If the above application is running on “http://127.0.0.1:5000” then what will be the final output on terminal on executing these two curl commands in the order mentioned?

1: curl -X DELETE 'http://127.0.0.1:5000'

2:

bash
curl -X PUT -H "Content-Type: application/json" -H "Accept-Type: application/json" -d '{"Roll No":"12f2000555", "Email": "ds.study.iitm.ac.in"}' 'http://127.0.0.1:5000/'
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 26

+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

  • C

Question 27

+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

  • C

Question 28

+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

  • C

Question 29

+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-3, c-2, d-4

  3. C

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

  4. D

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

Show answer

Correct answer

  • B

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

Question 30

+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(N²)

  2. B

    O(N)

  3. C

    O(logN)

  4. D

    O(NlogN)

Show answer

Correct answer

  • A

    O(N²)

Question 31

+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=343

Show answer

Correct answer: 343343

Question 32

+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
  • D