Quiz Space

January 2024 term · Modern Application Development I · BSCS2003

MAD 1 End Term: 28 April 2024, Set QDF3 (January 2024 term)

The IIT Madras BS Modern Application Development I (MAD 1) End Term paper sat on 28 Apr 2024, in the January 2024 term, set QDF3: 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
25
MSQ
7

Updated

Official paper: IIT M FOUNDATION DIPLOMA AN EXAM QDF3 28 Apr 2024 · No negative marking.

Question 1

+3 marksOne correct option

Consider the following Python code snippet.

python
from string import Template as makeTemplate
from jinja2 import Template
import sys
var = sys.argv[0]
data = {"var1": "Data scientist", "var2": "programming",
"var3": "statistical", "var4": "insights"}
temp = "{{var1}} creates $var2 code with $var3 knowledge to create
{{var4}}."
if var == "1":
temp = makeTemplate(temp)
output = temp.substitute(data)
print(output)
else:
temp = Template(temp)
output = temp.render(data)
print(output)

What will be printed on the terminal for the command python app.py 1 2 ?

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

Correct answer

  • D

Question 2

+2 marksOne correct option

Consider the following flask application running locally on http://127.0.0.1:5000 ?

python
from flask import Flask
app = Flask(__name__)
@app.route('/home/<string:url>')
def get_url_str(url):
return "string "+url
@app.route('/home/<path:url>')
def get_url_pth(url):
return "path "+url
app.run(debug = True)

Which of the following URLs will throw a 404 Not Found error?

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

Correct answer

  • B

Question 3

+2 marksOne correct option

Consider the following view function.

python
from flask import Flask, request
app = Flask(__name__)
@app.route('/student', methods = ['GET', 'POST'])
def show_details():
cred = request.args
details = {
'Stream': cred['dept'],
'Roll': cred['roll'],
'Course': cred['course']
}
return details
app.run()

If this flask app is running locally on http://127.0.0.1:5000, which of the following URLs will be handled by the controller correctly?

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

Question 4

+2 marksOne correct option

Which of the following is not a frontend framework?

  1. A

    Vue JS

  2. B

    React JS

  3. C

    Node JS

  4. D

    Angular JS

Show answer

Correct answer

  • C

    Node JS

Question 5

+2 marksOne correct option

Consider the following statements and select the correct option:
Statement 1: In a database, an index can only be created on one column of a table.
Statement 2: Indexes cannot be created on columns which have duplicate values.

  1. A

    Statement 1 is true & statement 2 is false

  2. B

    Statement 2 is true & statement 1 is false

  3. C

    Both statements 1 and 2 are true

  4. D

    Both statements 1 and 2 are false

Show answer

Correct answer

  • D

    Both statements 1 and 2 are false

Question 6

+2 marksOne correct option
  1. A

    a-2, b-3, c-1

  2. B

    a-2, b-1, c-3

  3. C

    a-1, b-2, c-3

  4. D

    a-1, b-3, c-2

Show answer

Correct answer

  • B

    a-2, b-1, c-3

Question 7

+3 marksOne correct option

In the code snippet given below, what should come in place of code 1 and code 2 such that one book can have multiple sections and the converse does not hold true?

python
from sqlalchemy import ForeignKey
from sqlalchemy import Integer, Column
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy.orm import relationship
class Base(DeclarativeBase):
Pass
class Section(Base):
__tablename__ = "section_table"
id = Column(Integer, primary_key=True)
# write your code 1 here
class Book(Base):
__tablename__ = "book_table"
id = Column(Integer, primary_key=True)
# write your code 2 here
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 8

+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", data=['Harry', 'Karl', 'John',
'Jason', 'Ros'])
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 %}
{% if item|length >= 5 %}
<li>{{item}}</li>
{% endif %}
{% endfor %}
</ul>
{% endmacro %}
{{ unordered_list(data) }}
</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

  • C

Question 9

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

Correct answer

  • C

Question 10

+3 marksOne correct option

Consider the following flask application.

python
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/')
def square():
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 = (int(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 URL http://localhost:5000/?num=4 ?

  1. A

    4

  2. B

    44

  3. C

    ValueError

  4. D

    4444

Show answer

Correct answer

  • D

    4444

Question 11

+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 -12 ?

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

Correct answer

  • D

Question 12

+3 marksOne correct option

The lens of an HDD can read data on the rotating disk with the speed of 42,000 bits per second. The disk is designed such that 600 bits pass under the lens for every revolution of the disk, what should be the maximum speed of disk in RPM so that the lens does not miss any data?

  1. A

    70 RPM

  2. B

    100 RPM

  3. C

    4200 RPM

  4. D

    6000 RPM

Show answer

Correct answer

  • C

    4200 RPM

Question 13

+3 marksOne correct option

Consider the following python code snippet.

python
from string import Template
statement = "The $animal jumped over the $obstacle."
temp = Template(statement)
print(=== OUTPUT ===)

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

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

Correct answer

  • A

Question 14

+3 marksOne correct option
  1. A

    The special series is: 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4

  2. B

    The special series is: 1 2 0 1 2 0 1 2 0 1 2 0 1 2

  3. C

    The special series is: 0 0 1 1 1 2 2 2 3 3 3 4 4 4

  4. D

    The special series is: 0.33 0.67 1.0 1.33 1.67 2.0 2.33 2.67 3.0 3.33 3.67 4.0 4.33 4.67

Show answer

Correct answer

  • C

    The special series is: 0 0 1 1 1 2 2 2 3 3 3 4 4 4

Question 15

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

Correct answer

  • D

Question 16

+3 marksOne correct option

In an OpenAPI documentation, which field contains all the endpoints (routes) of the API?

  1. A

    paths

  2. B

    schema

  3. C

    info

  4. D

    responses

Show answer

Correct answer

  • A

    paths

Question 17

+3 marksOne correct option

Consider the below two data models Author and Book using SQLite database.

python
class Author(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String)
dob = db.Column(db.String)
class Book(db.Model):
id = db.Column(db.Integer(), primary_key=True)
title = db.Column(db.String())
publisher = db.Column(db.String())
written_by = db.Column(db.Integer(), db.foreign_key("author.id"),unique=True)

What kind of relationship exists between Author and Book classes?

  1. A

    One Book to one Author relationship

  2. B

    One Author to many Books relationship

  3. C

    Many Authors to one Book relationship

  4. D

    Many Books to many Author relationship

Show answer

Correct answer

  • A

    One Book to one Author relationship

Question 18

+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**2+y**2
return out
class Test_class0():
def test_case1(self):
assert func(1,2) == 5
def case_test2(self):
assert func(2,3) == 13
def case_test3(self):
assert func(6,2) == 38
class Test_class1():
def test_case1(self):
assert func(5,2) == 29
def case_test2(self):
assert func(1,1) == 2

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

pytest test_file.py -k Test_class

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

Correct answer

  • C

Question 19

+4.5 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 %}
<p>MAD I</p>
<span>MAD II</span>
<p>DBMS</p>
{% endblock %}

base.html

html
<!DOCTYPE html>
<html lang="en">
<head>
<title>IITM</title>
</head>
<body>
<h2 style="color: violet;"> Diploma Courses </h2>
{% 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 20

+4.5 marksOne correct option

Consider the below Flask Restful API code snippet:

app.py

python
from flask import Flask, request
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
data_info = [
{"name": "IITM", "mail": "abc@study.iitm.ac.in"}
]
class Data(Resource):
def get(self):
return data_info
def post(self):
name = request.json["name"]
mail = request.json["mail"]
data = {}
data["name"] = name
data["mail"] = mail
data_info.append(data)
return "Saved data", 200
api.add_resource(Data, "/")
if __name__ == "__main__":
app.run()

Assume that above app.py is running on http://127.0.0.1:5000/ . What will be the outputs of the below sequence of CURL commands:

i)

bash
curl -X POST -H "Content-Type: application/json" -H "Accept-Type:
application/json" -d "{\"name\":\"Javed\",\"mail\":\"javed@study.iitm.ac.in\"}"
"http://127.0.0.1:5000/"

ii)

bash
curl -X GET "http://127.0.0.1:5000"
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 21

+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. What is the total data consumed in GigaBytes by all the users in 24 hrs?

  1. A

    633.6 GB

  2. B

    54 GB

  3. C

    120 GB

  4. D

    432GB

Show answer

Correct answer

  • B

    54 GB

Question 22

+4.5 marksOne correct option

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

CSS Code:

css
#one{color: blue;}
.two{color: red !important;}
#two{color: green}
#three{color: green;}

HTML Code:

html
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
<link href="style.css" rel="stylesheet">
<style>
body{font-weight: bold;}
p{color: violet !important ;}
</style>
</head>
<body>
<span id="one">Content 1</span>
<p class="two" id="two" >Content 2</p>
<span id="three">Content 3</span>
</body>
</html>
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 23

+4.5 marksOne correct option

Consider the below two python files code snippets app.py and test_app_route.py.

app.py

python
from flask import Flask
app = Flask(__name__)
@app.route("/greet/<string:name>")
def home(name):
return "Hello, " + name
if __name__ == "__main__":
app.run()

test_app_route.py:

python
import pytest, requests
@pytest.fixture
def get_response():
resp = requests.get("http://127.0.0.1:5000/greet/IITM")
return resp
def test_response(get_response):
assert get_response.text == "Hello, IITM"

Assume that app.py and test_app_route.py are running on two different terminals. And also all required modules are installed. Which of the below statement(s) are True?

i) Executing the command pytest test_app_route.py on the terminal returns
=========== 1 passed =============

ii) Executing the command pytest test_app_route.py on the terminal returns
============ 1 failed ==============

iii) Executing the command pytest test_app_route.py on the terminal returns
============ 1 selected, 1 passed ==============

iv) Executing the command pytest test_app_route.py on the terminal returns
============ 1 deselected ==============

  1. A

    Only statement i is correct

  2. B

    Only statement ii is correct

  3. C

    Statements i and iii are correct

  4. D

    Statements ii and iv are correct

Show answer

Correct answer

  • A

    Only statement i is correct

Question 24

+2 marksOne or more correct options

Which of the following is true about the term “stateful” in the client-server model?

Select all that apply.

  1. A

    The server responds to the client based on the previous state.

  2. B

    The server uses FTP protocol to respond to the client's request.

  3. C

    Network performance may reduce because of the large amount of data sent out repetitively.

  4. D

    Server is not required to maintain any state of client or session during transactions between client and server.

Show answer

Correct answers

  • A

    The server responds to the client based on the previous state.

  • B

    The server uses FTP protocol to respond to the client's request.

Question 25

+2 marksOne or more correct options

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

  • C

    An employee needs to have at least one salary slip

  • D

    A salary slip must belong to one and only one employee

Question 26

+2 marksOne or more correct options

What is the name of the branch that we start with when we create a new git repository?

Select all that apply.

  1. A

    main

  2. B

    master

  3. C

    develop

  4. D

    feature

Show answer

Correct answers

  • A

    main

  • B

    master

Question 27

+3 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 28

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

  • A

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

  • D

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

Question 29

+4.5 marksOne or more correct options

Consider the following flask app. Given that test_request_context() allows text to be printed on the terminal, which of the following statements is/are correct?

python
from flask import Flask, url_for
app = Flask(__name__)
@app.route('/library')
def home():
return 'Select your course!'
@app.route('/student/<username>/<roll>')
def dashboard(username):
return f'{username}\'s dashboard'
with app.test_request_context():
#== print statement ==#

Select all that apply.

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

Correct answers

  • B
  • D

Question 30

+4.5 marksOne or more correct options

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(10) == 100
@pytest.mark.marker2
def testcase_2():
assert square(4) == 4
@pytest.mark.marker3
def testcase_3():
assert square(5) == 25
@pytest.mark.marker4
def testcase_4():
assert square(6) == 6

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

text
========= 1 passed, 3 deselected, 4 warnings in 0.04s =========

What command will result into the outcome given above?

Select all that apply.

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

Correct answers

  • A
  • C

Question 31

+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: "App Dev III",
4: "DevOps"
}
if courses[int(sys.argv[2])] in "App Dev III":
i = 1
while i <= int(sys.argv[2]):
print("course found",courses[i])
i+=1
else:
print("No course found!")

Based on the above data, answer the given subquestions.

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

Correct answer

  • C

Question 32

+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: "App Dev III",
4: "DevOps"
}
if courses[int(sys.argv[2])] in "App Dev III":
i = 1
while i <= int(sys.argv[2]):
print("course found",courses[i])
i+=1
else:
print("No course found!")

Based on the above data, answer the given subquestions.

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

Correct answer

  • B