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.
- 32
- 100
- 180 min
- 24
- 8
Show answer
Correct answer
Question 2
How will the browser render the following HTML document?
<!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>Show answer
Correct answer
Question 3
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.
Both statement 1 and 2 are correct.
Both statement 1 and 2 are incorrect.
Statement 1 is correct but, statement 2 is incorrect.
Statement 2 is correct but, statement 1 is incorrect.
Show answer
Correct answer
Both statement 1 and 2 are incorrect.
Question 4
Consider a simple web server using command prompt.
Filename - Hello.sh
#!/bin/bashwhile true; doecho -e "Current date and time is \n\t $(date)"| nc -l localhost 4100;doneIf this program creates a server in a terminal, the correct way to make a request to this server is _______.
Show answer
Correct answer
Question 5
Consider the following flask application.
Python file: app.py
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
<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 ?
Show answer
Correct answer
Question 6
Consider the following function to be tested and test functions given in the Python code snippet below.
test_file.py
import pytest
def square(x): sum = 0 for counter in range(x): sum += x return sum
@pytest.mark.marker1def testcase_1(): assert square(13) == 144
@pytest.mark.marker2def testcase_2(): assert square(6) == 6
@pytest.mark.marker3def testcase_3(): assert square(3) == 9On running this file on the terminal using pytest, the summary of the output is;
============ 1 passed, 2 deselected, 3 warnings in 0.02s ============What command will result into the outcome given above?
Show answer
Correct answer
Question 7
ABD8 6415
D8AB 6415
ABD8 1564
D8AB 1564
Show answer
Correct answer
ABD8 1564
Question 8
Consider the following models Creator and Song corresponding to tables creator and song in SQLite database.
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?
Many-to-Many
One-to-Many
One-to-One
The tables are not at all related
Show answer
Correct answer
One-to-Many
Question 9
Which curl option is used to set the request method in an HTTP request?
-H
-X
-d
-r
Show answer
Correct answer
-X
Question 10
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.
Both statements 1 and 2 are correct
Both statements 1 and 2 are incorrect
Statement 1 is correct but statement 2 is incorrect
Statement 2 is correct but statement 1 is incorrect
Show answer
Correct answer
Both statements 1 and 2 are correct
Question 11
Consider two python files, one.py and two.py with following code snippets.
File1: one.py
import sysimport twoprint(f'{sys.argv[1]} {sys.argv[3]}')File2: two.py
import sysprint(f'{sys.argv[2]} {sys.argv[0]}')What is the output of the following command “python one.py two.py two.py one.py ”?
Show answer
Correct answer
Question 12
Which of the following is not a web component?
Custom Elements
Shadow DOM
HTML Templates
Web Assembly
Show answer
Correct answer
Web Assembly
Question 13
Statement 1 is correct, but statement 2 is incorrect.
Statement 1 is incorrect, but statement 2 is correct.
Both statements 1 and 2 are correct.
Both statements 1 and 2 are incorrect.
Show answer
Correct answer
Statement 1 is incorrect, but statement 2 is correct.
Question 14
What is Emscripten in the context of WebAssembly?
A WebAssembly specification
A JavaScript framework
A toolchain for compiling C/C++ code to WebAssembly
An HTML and CSS editor
Show answer
Correct answer
A toolchain for compiling C/C++ code to WebAssembly
Question 15
The ORM(Object-Relational Mapping) sqlalchemy is used for?
Running SQL queries directly on the database
Defining the structure of HTML templates
Mapping Python objects to database tables and records
Creating Web Routes in a Flask app
Show answer
Correct answer
Mapping Python objects to database tables and records
Question 16
Consider the following Python code snippet.
a - 3, b - 2, c - 1, d - 4
a - 2, b - 1, c - 4, d - 3
a - 3, b - 1, c - 2, d - 4
a - 2, b - 3, c - 4, d - 1
Show answer
Correct answer
a - 2, b - 3, c - 4, d - 1
Question 17
Given a Python code snippet, code.py is run on the terminal with an appropriate temp.html document.
Show answer
Correct answer
Question 18
Consider the following function to be tested and test functions given in the Python code snippet below.
test_file.py
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_3For the command pytest test_file.py, what will be the output on the terminal?
Show answer
Correct answer
Question 19
Consider the following HTML document rendered using a browser.
<!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?
Red for first five letters, turns green till 8th letter and turns red back again after next letter.
Red for first five letters, and remain green after that.
Green for first five letters, turns red till 8th letter and turns green back again after next letter.
Green for first five letters, and remain red after that.
Show answer
Correct answer
Red for first five letters, and remain green after that.
Question 20
A flask application shown below is running locally on http://127.0.0.1:5000
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?
http://127.0.0.1:5000/homehttp://127.0.0.1:5000/login/adminhttp://127.0.0.1:5000/login?user=adminhttp://127.0.0.1:5000/homehttp://127.0.0.1:5000/logout
Show answer
Correct answer
Question 21
Consider the following two code snippets.
Snippet 1
@app.route("/base")@app.route("/home")def homepage(): return "Welcome to MAD I!"Snippet 2
@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 ?
Snippet 1 is valid, but Snippet 2 is invalid.
Snippet 2 is valid, but Snippet 1 is invalid.
Snippet 1 will run successfully, while Snippet 2 will raise an AssertionError.
Snippet 2 will run successfully, while Snippet 1 will raise an AssertionError.
Show answer
Correct answers
Snippet 1 is valid, but Snippet 2 is invalid.
Snippet 1 will run successfully, while Snippet 2 will raise an AssertionError.
Question 22
Consider the following flask application.
app.py
from flask import Flask, render_template, url_for, request, redirectapp = 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 ?
Show answer
Correct answers
Question 23
One order must have exactly one customer associated with it.
One customer must have many orders associated with it.
One customer may have zero or many orders associated with it.
It's not mandatory for a customer to have an order.
Show answer
Correct answers
One order must have exactly one customer associated with it.
One customer may have zero or many orders associated with it.
It's not mandatory for a customer to have an order.
Question 24
Show answer
Correct answers
Question 25
Consider the following Python code snippet.
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?
Show answer
Correct answers
Question 26
An HTML code is given below then which of the following CSS code will render the output as shown below.
Show answer
Correct answers
Question 27
Consider the following python code snippet and choose the correct option.
def modify(func): def wrapper(x): list = func(x, []) return list return wrapper
@modifydef expandList(x, list = []): list.append(x) return list
print(expandList(5))print(expandList(6))Show answer
Correct answers
Question 28
Consider the following flask application.
from flask import Flask, abortapp = 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).
Show answer
Correct answers
Question 29
Given below is a part of the HTTP response upon running the command:
curl --head https://www.httpbin.org/HTTP response
HTTP/2 200date: Fri, 02 Dec 2022 16:38:16 GMTcontent-type: text/html; charset=utf-8content-length: 9593server: gunicorn/19.9.0access-control-allow-origin: *access-control-allow-credentials: trueBased on the above data, answer the given subquestions.
Which part of the response indicates the MIME type of the response body?
charset=utf-8
server: gunicorn/19.9.0
content-type: text/html;
None of these
Show answer
Correct answer
content-type: text/html;
Question 30
Given below is a part of the HTTP response upon running the command:
curl --head https://www.httpbin.org/HTTP response
HTTP/2 200date: Fri, 02 Dec 2022 16:38:16 GMTcontent-type: text/html; charset=utf-8content-length: 9593server: gunicorn/19.9.0access-control-allow-origin: *access-control-allow-credentials: trueBased on the above data, answer the given subquestions.
Which part of the response indicates that the request created a successful response?
server: gunicorn/19.9.0
content-type: text/html;
HTTP/2 200
None of these
Show answer
Correct answer
HTTP/2 200
Question 31
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?
166
42
56
111
Show answer
Correct answer
42
Question 32
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?
24
12
10
5
Show answer
Correct answer
10
