Quiz Space

September 2023 term · Modern Application Development I · BSCS2003

MAD 1 End Term: 24 December 2023, Set ADD3 (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 ADD3: 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
8

Updated

Official paper: IIT M DIPLOMA FN EXAM FDD1 24 Dec 2023 · No negative marking.

Question 1

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

Correct answer

  • D

Question 2

+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;
}
span{
border: 1px solid pink;
display: block;
}
div,span{
width:8%;
margin: 2px;
}
</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

  • A

Question 3

+3 marksOne correct option

Consider the statements given below and choose the correct option.
Statement 1: 100% statement coverage automatically implies 100% branch coverage. Statement 2: 100% statement 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 4

+3 marksOne correct option

Consider a simple web server using command prompt.

Filename - Hello.sh

bash
#!/bin/bash
while true; do
echo -e "Current date and time is \n\t $(date)"
| nc -l localhost 4100;
done

If this program creates a server in a terminal, the correct way to make a request to this server is _______.

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

Correct answer

  • D

Question 5

+3 marksOne correct option

Consider the following flask application.

Python file: app.py

python
from flask import Flask, render_template, request
app = Flask(__name__)
emp = {'admin':'manoj', 'user':'sumit'}
@app.route('/profile/<user>')
def profile(user):
access = request.args.get('access')
if emp[access] != user:
return render_template("profile.html", user = user,
access = access, error = True)
return render_template("profile.html", user = user,
access = access, error = False)
app.run()

Template file: profile.html

html
<body>
<div>
{% if error %}
<h3>Hi {{user}}, {{access}} access denied</h3>
{% else %}
<h3>Hi {{user}}, you are logged in as {{access}}.</h3>
{% endif %}
</div>
</body>

If the application is running locally on http://127.0.0.1:5000, then what will be rendered by the browser for URL, http://127.0.0.1:5000/profile/sumit?access=admin ?

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

Correct answer

  • C

Question 6

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

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

  • D

Question 7

+3 marksOne correct option
  1. A

    ABD8 6415

  2. B

    D8AB 6415

  3. C

    ABD8 1564

  4. D

    D8AB 1564

Show answer

Correct answer

  • C

    ABD8 1564

Question 8

+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("creator.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

  • B

    One-to-Many

Question 9

+3 marksOne correct option

Which curl option is used to set the request method in an HTTP request?

  1. A

    -H

  2. B

    -X

  3. C

    -d

  4. D

    -r

Show answer

Correct answer

  • B

    -X

Question 10

+2 marksOne correct option

Read the statements given below carefully and select the correct option.
Statement 1: If an element is styled externally using both the class and the ID, then for the same attribute, it will acquire styling from the ID.
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 always acquire inline styling.

  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

  • A

    Both statements 1 and 2 are correct

Question 11

+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[1]} {sys.argv[3]}')

File2: two.py

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

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

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

Correct answer

  • C

Question 12

+2 marksOne correct option

Which of the following is not a web component?

  1. A

    Custom Elements

  2. B

    Shadow DOM

  3. C

    HTML Templates

  4. D

    Web Assembly

Show answer

Correct answer

  • D

    Web Assembly

Question 13

+2 marksOne correct option
  1. A

    Statement 1 is correct, but statement 2 is incorrect.

  2. B

    Statement 1 is incorrect, but statement 2 is correct.

  3. C

    Both statements 1 and 2 are correct.

  4. D

    Both statements 1 and 2 are incorrect.

Show answer

Correct answer

  • B

    Statement 1 is incorrect, but statement 2 is correct.

Question 14

+2 marksOne correct option

What is Emscripten in the context of WebAssembly?

  1. A

    A WebAssembly specification

  2. B

    A JavaScript framework

  3. C

    A toolchain for compiling C/C++ code to WebAssembly

  4. D

    An HTML and CSS editor

Show answer

Correct answer

  • C

    A toolchain for compiling C/C++ code to WebAssembly

Question 15

+2 marksOne correct option

The ORM(Object-Relational Mapping) sqlalchemy is used for?

  1. A

    Running SQL queries directly on the database

  2. B

    Defining the structure of HTML templates

  3. C

    Mapping Python objects to database tables and records

  4. D

    Creating Web Routes in a Flask app

Show answer

Correct answer

  • C

    Mapping Python objects to database tables and records

Question 16

+4.5 marksOne correct option

Consider the following Python code snippet.

  1. A

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

  2. B

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

  3. C

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

  4. D

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

Show answer

Correct answer

  • D

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

Question 17

+4.5 marksOne correct option

Given a Python code snippet, code.py is run on the terminal with an appropriate temp.html document.

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

Correct answer

  • B

Question 18

+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_3 = [x(3) for x in powers]
def testcase_1():
assert 9 in powers_of_3
def testcase_2():
assert 27 in powers_of_3
def testcase_3():
assert 64 in powers_of_3

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

  • C

Question 19

+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

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

  3. C

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

  4. D

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

Show answer

Correct answer

  • B

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

Question 20

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

  • B

Question 21

+3 marksOne or more correct options

Consider the following two code snippets.

Snippet 1

python
@app.route("/base")
@app.route("/home")
def homepage():
return "Welcome to MAD I!"

Snippet 2

python
@app.route("/mad1")
def homepage():
return "Welcome to MAD I!"
@app.route("/mad2")
def homepage():
return "Welcome to MAD II!"

Which of the following is/are correct options if the above snippets are run as view functions of a flask application ?

Select all that apply.

  1. A

    Snippet 1 is valid, but Snippet 2 is invalid.

  2. B

    Snippet 2 is valid, but Snippet 1 is invalid.

  3. C

    Snippet 1 will run successfully, while Snippet 2 will raise an AssertionError.

  4. D

    Snippet 2 will run successfully, while Snippet 1 will raise an AssertionError.

Show answer

Correct answers

  • A

    Snippet 1 is valid, but Snippet 2 is invalid.

  • C

    Snippet 1 will run successfully, while Snippet 2 will raise an AssertionError.

Question 22

+3 marksOne or more correct options

Consider the following flask application.

app.py

python
from flask import Flask, render_template, url_for, request, redirect
app = Flask(__name__)
list_of_courses = ['Java', 'Python', 'DBMS', 'PDSA']
@app.route("/if")
def if_loop():
name = request.args.get("name")
if name == "MADI":
return redirect("/home")
elif name in list_of_courses:
return url_for("for_loop")
return "You are not authorized to view this page"
@app.route("/home")
def home_page():
return "Welcome to MADI!"
@app.route("/for")
def for_loop():
return render_template("for_course.html", courses=list_of_courses)
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

  • C
  • D

Question 23

+3 marksOne or more correct options

Select all that apply.

  1. A

    One order must have exactly one customer associated with it.

  2. B

    One customer must have many orders associated with it.

  3. C

    One customer may have zero or many orders associated with it.

  4. D

    It's not mandatory for a customer to have an order.

Show answer

Correct answers

  • A

    One order must have exactly one customer associated with it.

  • C

    One customer may have zero or many orders associated with it.

  • D

    It's not mandatory for a customer to have an order.

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

Question 25

+3 marksOne or more correct options

Consider the following Python code snippet.

python
from string import Template
statement = Template("the $var1 boxing $var2 jump $var3")
out = statement.substitute(var_dict)
print(out)

Which of the following options correctly represent(s) the dictionary var_dict, such that the code does not throw any error when run in the terminal?

Select all that apply.

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

Correct answers

  • B
  • C

Question 26

+4.5 marksOne or more correct options

An HTML code is given below then which of the following CSS code will render the output as shown below.

Select all that apply.

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

Correct answers

  • A
  • D

Question 27

+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

  • B
  • C

Question 28

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

Question 29

+2 marksOne correct option

Given below is a part of the HTTP response upon running the command:

bash
curl --head https://www.httpbin.org/

HTTP response

http
HTTP/2 200
date: Fri, 02 Dec 2022 16:38:16 GMT
content-type: text/html; charset=utf-8
content-length: 9593
server: gunicorn/19.9.0
access-control-allow-origin: *
access-control-allow-credentials: true

Based on the above data, answer the given subquestions.

Which part of the response indicates the MIME type of the response body?

  1. A

    charset=utf-8

  2. B

    server: gunicorn/19.9.0

  3. C

    content-type: text/html;

  4. D

    None of these

Show answer

Correct answer

  • C

    content-type: text/html;

Question 30

+2 marksOne correct option

Given below is a part of the HTTP response upon running the command:

bash
curl --head https://www.httpbin.org/

HTTP response

http
HTTP/2 200
date: Fri, 02 Dec 2022 16:38:16 GMT
content-type: text/html; charset=utf-8
content-length: 9593
server: gunicorn/19.9.0
access-control-allow-origin: *
access-control-allow-credentials: true

Based on the above data, answer the given subquestions.

Which part of the response indicates that the request created a successful response?

  1. A

    server: gunicorn/19.9.0

  2. B

    content-type: text/html;

  3. C

    HTTP/2 200

  4. D

    None of these

Show answer

Correct answer

  • C

    HTTP/2 200

Question 31

+3 marksOne correct option

A machine client M makes multiple requests to three different servers A, B and C in the order A then B followed by C. However, it can make a request to server B only after receiving the response from server A and same with server C i.e. the client can make a request to server C only after receiving response from server B. If the servers A, B and C are located at 900 kms, 1200 kms and 1500 kms respectively, answer the given subquestions.[Consider speed of light in air to be 3 x 10⁸ m/s]

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

  1. A

    166

  2. B

    42

  3. C

    56

  4. D

    111

Show answer

Correct answer

  • B

    42

Question 32

+3 marksOne correct option

A machine client M makes multiple requests to three different servers A, B and C in the order A then B followed by C. However, it can make a request to server B only after receiving the response from server A and same with server C i.e. the client can make a request to server C only after receiving response from server B. If the servers A, B and C are located at 900 kms, 1200 kms and 1500 kms respectively, answer the given subquestions.[Consider speed of light in air to be 3 x 10⁸ m/s]

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

  1. A

    24

  2. B

    12

  3. C

    10

  4. D

    5

Show answer

Correct answer

  • C

    10