Quiz Space

September 2023 term · Modern Application Development I · BSCS2003

MAD 1 End Term: 24 December 2023, Set FDD1 (September 2023 term)

The IIT Madras BS Modern Application Development I (MAD 1) End Term paper sat on 24 Dec 2023, in the September 2023 term, set FDD1: 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
27
MSQ
5

Updated

Official paper: IIT M DIPLOMA FN EXAM FDD1 24 Dec 2023 · 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

Read the statements given below carefully and select the correct option.
Statement 1: If an element is styled externally using two different classes and an ID, then for the same attribute, it will always acquire styling from the latest style in order.
Statement 2: If an element is styled internally using ID and class selector as well as using inline styling for the same style attribute, then it will acquire styling from the ID selector.

  1. A

    Both statements 1 and 2 are correct

  2. B

    Both statements 1 and 2 are incorrect

  3. C

    Statement 1 is correct but statement 2 is incorrect

  4. D

    Statement 2 is correct but statement 1 is incorrect

Show answer

Correct answer

  • B

    Both statements 1 and 2 are incorrect

Question 3

+2 marksOne correct option

Consider two python files, one.py and two.py with following code snippets.

File1: one.py

python
import sys
import two
print(f'{sys.argv[0]} {sys.argv[1]}')

File2: two.py

python
import sys
print(f'{sys.argv[3]} {sys.argv[2]}')

What is the output of the following command “python one.py two.py one.py two.py ”?

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

Correct answer

  • B

Question 4

+2 marksOne correct option

What is the primary purpose of curl?

  1. A

    Web server configuration

  2. B

    Making requests to the web server

  3. C

    Database management

  4. D

    HTML parsing

Show answer

Correct answer

  • B

    Making requests to the web server

Question 5

+2 marksOne correct option

What is template inheritance in Jinja2 used for?

  1. A

    To establish a database connection

  2. B

    To create a new database table

  3. C

    To define a base template with a common structure and placeholders that can be extended by child templates

  4. D

    To insert CSS styles

Show answer

Correct answer

  • C

    To define a base template with a common structure and placeholders that can be extended by child templates

Question 6

+2 marksOne correct option

Which of the following is a common method to achieve data persistence in web applications?

  1. A

    Storing data in volatile cache

  2. B

    Saving data to temporary files

  3. C

    Writing data to a database

  4. D

    Using data stored in RAM

Show answer

Correct answer

  • C

    Writing data to a database

Question 7

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

+3 marksOne correct option

How will the browser render the following HTML document?

html
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
<style>
div{
border: 1px solid black;
color:pink;
display: inline-block;
}
span{
border: 1px solid pink;
}
</style>
</head>
<body>
<div>Div 1</div>
<div>Div 2</div>
<span>Span 1</span>
<span>Span 2</span>
</body>
</html>
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 9

+3 marksOne correct option

Consider the below flask application.

python
from flask_sqlalchemy import SQLAlchemy
from flask import Flask
app = Flask (__name__)
app.config ['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///testdb.sqlite3'
db = SQLAlchemy(app)
app.app_context().push()
class Material(db.Model):
m_id = db.Column('m_id', db.Integer, primary_key = True)
name = db.Column('name', db.String(100), unique = True)
db.create_all()
material1 = Material(name = 'Steel')
db.session.add(material1)
material2 = Material(name = 'Iron')
material3 = Material(name = 'Aluminium')
db.session.add(material2)
db.session.commit()
db.session.add(material3)
all_material = Material.query.all()
print([(x.m_id, x.name) for x in all_material])

If you run the flask application using a terminal. What will be the output in the terminal?

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

Correct answer

  • C

Question 10

+3 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) == 10
def test_case3(self):
assert func(4,2) == 21
class Test_class1():
def test_case1(self):
assert func(5,2) == 27
def case_test2(self):
assert func(4,3) == 25

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

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

Correct answer

  • D

Question 11

+3 marksOne correct option

Consider the statements given below and choose the correct option.
Statement 1: 100% condition coverage automatically implies 100% branch coverage. Statement 2: 100% branch coverage automatically implies 100% condition coverage.

  1. A

    Both statement 1 and 2 are correct.

  2. B

    Both statement 1 and 2 are incorrect.

  3. C

    Statement 1 is correct but, statement 2 is incorrect.

  4. D

    Statement 2 is correct but, statement 1 is incorrect.

Show answer

Correct answer

  • B

    Both statement 1 and 2 are incorrect.

Question 12

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

Correct answer

  • B

Question 13

+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(12) == 144
@pytest.mark.marker2
def testcase_2():
assert square(9) == 9
@pytest.mark.marker3
def testcase_3():
assert square(3) == 27

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

text
============ 1 passed, 2 deselected, 3 warnings in 0.02s ============

What command will result into the outcome given above?

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

Correct answer

  • C

Question 14

+3 marksOne correct option
  1. A

    AC0A FE01

  2. B

    CA10 EF0A

  3. C

    AC01 0AEF

  4. D

    AC10 FE0A

Show answer

Correct answer

  • D

    AC10 FE0A

Question 15

+3 marksOne correct option

Consider the following models Creator and Song corresponding to tables creator and song in SQLite database.

python
class Creator(db.Model):
id = db.Column(db.Integer(), primary_key = True)
c_name = db.Column(db.String(), unique = True)
class Song(db.Model):
id = db.Column(db.Integer(), primary_key = True)
s_title = db.Column(db.String(), unique = True)
singer = db.Column(db.Integer(), db.ForeignKey("singer.id"))

Based on the model schemas, what relationship do the table creator and song 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 16

+3 marksOne correct option

What is the git command to change the registered e-mail of a user using CLI?

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

Correct answer

  • D

Question 17

+3 marksOne correct option
  1. A

    application

  2. B

    __application__

  3. C

    main

  4. D

    __main__

Show answer

Correct answer

  • D

    __main__

Question 18

+3 marksOne correct option

A flask application shown below is running locally on http://127.0.0.1:5000.

python
from flask import Flask, request, session, abort
app = Flask(__name__)
app.config['SECRET_KEY'] = "yekterces"
@app.route('/login')
def log_in():
user = request.args['user']
role = request.args['role'] if 'role' in request.args else
'general'
session['user'], session['role'] = user, role
return "Logged in successfully!"
@app.route('/home')
def land():
if 'user' in session:
if session['role'] == 'admin':
return f"Welcome {session['user']}"
return abort(401)
return abort(404)
@app.route('/logout')
def log_out():
session.pop('user', None)
session.pop('role', None)
return "Logged out sucessfully!"
app.run(debug=True)

If the application is running locally on http://127.0.0.1:5000, What will be the correct sequence of response status codes if the client visits the URLs one by one in the sequence given below?

  1. http://127.0.0.1:5000/home
  2. http://127.0.0.1:5000/login/admin
  3. http://127.0.0.1:5000/login?user=admin
  4. http://127.0.0.1:5000/home
  5. http://127.0.0.1:5000/logout
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 19

+4.5 marksOne correct option
  1. A

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

  2. B

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

  3. C

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

  4. D

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

Show answer

Correct answer

  • B

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

Question 20

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

Correct answer

  • C

Question 21

+4.5 marksOne correct option

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

test_file.py

python
powers = []
for i in range(1,5):
def powers_of_x(x):
return x**i
powers.append(powers_of_x)
powers_of_4 = [x(4) for x in powers]
def testcase_1():
assert 12 in powers_of_4
def testcase_2():
assert 64 in powers_of_4
def testcase_3():
assert 256 in powers_of_4

For the command pytest test_file.py, what will be the output on the terminal?

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

Correct answer

  • D

Question 22

+4.5 marksOne correct option

Consider the following HTML document rendered using a browser.

html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<style>
input:valid {
background: green;
}
input:invalid {
background: red;
}
</style>
</head>
<body>
<form>
<label for="uname">Enter a valid e-mail:</label>
<input type="text" name="uname" minlength="5"
maxlength="8" value="a">
</form>
</body>
</html>

If a user starts typing "madcourse" letter by letter, how will the background colour of the <input> tag change?

  1. A

    Red for first five letters, turns green till 8th letter and turns red back again after next letter.

  2. B

    Green for first five letters, turns red till 8th letter and turns green back again after next letter.

  3. C

    Red for first five letters, and remain green after that.

  4. D

    Green for first five letters, and remain red after that.

Show answer

Correct answer

  • C

    Red for first five letters, and remain green after that.

Question 23

+4.5 marksOne or more correct options

Select all that apply.

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

Correct answers

  • B
  • D

Question 24

+4.5 marksOne or more correct options

Consider the following flask application.

app.py

python
from flask import Flask
app = Flask(__name__)
@app.route('/home/<path:url_path>')
def course(url_path):
return 'The path is: ' + url_path
@app.route('/home/details/<student_id>/<course_id>')
def home(student_id, course_id):
return f'The student-id and course-id are {student_id} and {course_id} respectively.'
@app.route('/home/student/<student_id>/<course_id>')
def details(student_id, course_id):
details = {'course_id': course_id,'student_id': student_id}
return details
app.run(debug=True)

Which of the following statements is/are true if the application is running locally on http://127.0.0.1:5000 ?

Select all that apply.

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

Correct answers

  • B
  • C
  • D

Question 25

+4.5 marksOne or more correct options

Consider the following python code snippet and choose the correct option.

python
def modify(func):
def wrapper(x):
list = func(x, [])
return list
return wrapper
@modify
def expandList(x, list = []):
list.append(x)
return list
print(expandList(5))
print(expandList(6))

Select all that apply.

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

Correct answers

  • A
  • D

Question 26

+4.5 marksOne or more correct options

Consider the following flask application.

python
from flask import Flask, abort
app = Flask(__name__)
modules = ['python', 'react', 'node']
@app.route('/home/modules/')
def all_modules():
return f"<h3>List of modules: {modules}</h3>"
@app.route('/get/<string:module_1>')
def get_module(module_1):
if module_1 in modules:
return f"<h3>One module found: {module_1}.</h3>"
else:
abort(400)
@app.errorhandler(400)
def module_error(error):
return "<h3>Cannot find module</h3>"
@app.errorhandler(404)
def module_error(error):
return "<h3>Incorrect Path</h3>"
app.run(debug=True)

If the application is running locally on http://127.0.0.1:5000, select the correct statement(s).

Select all that apply.

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

Correct answers

  • A
  • C

Question 27

+3 marksOne or more correct options

Consider the following flask view function definition given below.

python
@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'GET':
return render_template("login.html")
if request.method == 'POST':
#=== POST logic ===
return render_template("profile.html")

Which of the following view function definitions would work the same as that of one given above?

Select all that apply.

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

Correct answers

  • A
  • B

Question 28

+3 marksOne correct option

What is the maximum number of requests that can be made to B per second?

  1. A

    166

  2. B

    100

  3. C

    56

  4. D

    111

Show answer

Correct answer

  • C

    56

Question 29

+2 marksOne correct option

What is the round trip time (RTT) in milliseconds for server B?

  1. A

    10

  2. B

    6

  3. C

    18

  4. D

    5

Show answer

Correct answer

  • B

    6

Question 30

+3 marksOne correct option

Consider the following resource "TestAPI" created using flask-restful which is running locally on http://127.0.0.1:5000 and answer the given subquestions.

python
parser = reqparse.RequestParser()
parser.add_argument('movie')
parser.add_argument('genre')
r_fields = {"film":fields.String(attribute = 'movie')}
class TestAPI(Resource):
# =============================================
# GET-FUNCTION
# =============================================
# =============================================
# POST-FUNCTION
def post(self, genre):
return {'Genre': genre}
# =============================================
@marshal_with(r_fields)
def put(self):
this_film = parser.parse_args()
return this_film
api.add_resource(TestAPI, "/api/v1", "/api/v1/<genre>")

If the curl request shown below.

bash
curl http://127.0.0.1:5000/api/v1 -X GET -d "{\"movie\" : \"X-men\",
\"genre\": \"Action\"}" -H "Content-Type: application/json"

retrieves the movie only with status 200 OK, what will come in place of GET-FUNCTION in the code?

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

Correct answer

  • C

Question 31

+3 marksOne correct option

Consider the following resource "TestAPI" created using flask-restful which is running locally on http://127.0.0.1:5000 and answer the given subquestions.

python
parser = reqparse.RequestParser()
parser.add_argument('movie')
parser.add_argument('genre')
r_fields = {"film":fields.String(attribute = 'movie')}
class TestAPI(Resource):
# =============================================
# GET-FUNCTION
# =============================================
# =============================================
# POST-FUNCTION
def post(self, genre):
return {'Genre': genre}
# =============================================
@marshal_with(r_fields)
def put(self):
this_film = parser.parse_args()
return this_film
api.add_resource(TestAPI, "/api/v1", "/api/v1/<genre>")
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 32

+3 marksOne correct option

Consider the following resource "TestAPI" created using flask-restful which is running locally on http://127.0.0.1:5000 and answer the given subquestions.

python
parser = reqparse.RequestParser()
parser.add_argument('movie')
parser.add_argument('genre')
r_fields = {"film":fields.String(attribute = 'movie')}
class TestAPI(Resource):
# =============================================
# GET-FUNCTION
# =============================================
# =============================================
# POST-FUNCTION
def post(self, genre):
return {'Genre': genre}
# =============================================
@marshal_with(r_fields)
def put(self):
this_film = parser.parse_args()
return this_film
api.add_resource(TestAPI, "/api/v1", "/api/v1/<genre>")
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D