Quiz Space

May 2022 term · Modern Application Development I · BSCS2003

Modern Application Development I Quiz 2: 10 July 2022 (May 2022 term)

The IIT Madras BS Modern Application Development I (MAD 1) Quiz 2 paper sat on 10 Jul 2022, in the May 2022 term: 16 questions for 50 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
16
Marks
50
Duration
120 min
MSQ
1
MCQ
15

Updated

Official paper: IIT M DIPLOMA QUIZ2 EXAM QPE1 10 July 2022 · No negative marking.

Question 1

+3 marksOne or more correct options

Consider the Python file and a template given below.
Python file: app.py

python
from flask import Flask, url_for, redirect, render_template
app = Flask(__name__)
@app.route("/<name>/")
def index1(name):
return "Hi" + " " + name + "!" + " " + "This is your home page."
@app.route("/first_index/<string:name>")
def index2(name):
if name == "XYZ":
return redirect(url_for("index1", name = "XYZ"))
else:
return redirect( url_for("index3"))
@app.route("/second_index")
def index3():
return render_template("index.html")
if __name__ == "__main__":
app.run(debug=True)

Template file: index.html

html
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Document</title>
</head>
<body>
<h2> You are on the incorrect page.</h2>
<a href="{{ url_for("index1", name="ABC") }}">Go back</a>
</body>
</html>

If the above flask application is running locally on the URL ‘http://127.0.0.1:5000’, which of the following statements is/are true about the above code snippet?

Select all that apply.

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

Correct answers

  • B
  • C

Question 2

+3 marksOne correct option

A flask application is given below.

python
from flask import Flask, jsonify
app = Flask(__name__)
Gadgets = [
{"tech":"Smartwatch, Digital camera"},
{"mobile":"Headphones, Speakers"},
{"Laptop":"Keyboard, Mouse"}
]
@app.route("/home", methods=["GET"])
def func1():
return jsonify({"The list of gadgets": Gadgets})
@app.route("//")
def rest_lists():
return {
"Restaurant 1" : "Hotel Alpine",
"Restaurant 2" : "Maurya Vihar",
"Restaurant 3" : "Royal Garden"
}
if __name__ == "__main__":
app.run(debug=True)

If the above flask application is running locally on the URL ‘http://127.0.0.1:5000’, which of the following statement is true about the above flask application?

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

Correct answer

  • A

Question 3

+3 marksOne correct option

Consider the table “production” in SQLite database given below:

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

Correct answer

  • B

Question 4

+3 marksOne correct option

Consider the table “employee” given below. The model class “Employee” corresponds to table “employee” in the database.

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

Correct answer

  • D

Question 5

+3 marksOne correct option

Which of the following is the correct Python object representation of the given SQL query with declarative_base() class.

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

Correct answer

  • B

Question 6

+3 marksOne correct option

If the below flask application is running locally on the URL: ‘http://127.0.0.1:5000’, what will be rendered by the browser?
Python file: main.py

python
from flask import Flask, render_template
app=Flask(__name__)
@app.route('/')
def home():
my_course = ['App1', 'App2', 'python', 'Data science',
'Database', 'machine learning']
return render_template('index.html', list=my_course)
if __name__=='__main__':
app.run(debug=True)

Template: index.html

html
<html>
<head>
<title>template file</title>
</head>
<body>
{% macro display(list) %}
{% for course in list %}
<p>{{ course }}</p>
{% endfor %}
{% endmacro %}
{{ display(list) }}
</body>
</html>
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 7

+3 marksOne correct option

Consider the following table “table_A” in SQLite database.

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

Correct answer

  • D

Question 8

+3 marksOne correct option

Consider the following HTML file with embedded JavaScript.
Filename: index.html

html
<!DOCTYPE html>
<html>
<body>
<h2>Creating a Json Object </h2>
<p id="jsonobj"></p>
<script>
const txt = '{"name":"icecream","type":"cup",
"flavor":"vanilla"}'
const obj = JSON.parse(txt);
document.getElementById("jsonobj").innerHTML = obj.name + ", "
+ obj.flavor + ", " + obj.type;
</script>
</body>
</html>

How will the browser render the above HTML file?

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

Correct answer

  • D

Question 9

+2 marksOne correct option

Consider the statements given below.
Statement 1: APIs usually contain SDKs, but SDKs do not contain APIs.
Statement 2: The SDKs contains the group of tools that help developers to use a different product or services.
Which of the following is correct in the context of statements given above?

  1. A

    Both statement 1 and 2 are correct.

  2. B

    Statement 1 is correct, 2 is incorrect.

  3. C

    Both statement 1 and 2 are incorrect.

  4. D

    Statement 1 is incorrect, 2 is correct.

Show answer

Correct answer

  • D

    Statement 1 is incorrect, 2 is correct.

Question 10

+2 marksOne correct option

Consider a situation, where a developer wants to create his own customized application and wants to deploy it for the end users. For that, he wants a development environment that consists of some programming language execution environment, an operating system, a web server and a database, such that he can build, compile and run his programs without worrying about the servers, storage, and networking. Which of the following service models he would prefer in order to do so?

  1. A

    SaaS

  2. B

    PaaS

  3. C

    IaaS

  4. D

    None of these

Show answer

Correct answer

  • B

    PaaS

Question 11

+2 marksOne correct option

Consider the following table ‘flowers’ in SQLite database.

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

Correct answer

  • D

Question 12

+2 marksOne correct option

Match the following based on the memory hierarchy of computer.

  1. A

    1 - e, 2 - b, 3 - d

  2. B

    1 - a, 2 - b, 3 - c

  3. C

    1 - a, 2 - b, 3 - a

  4. D

    1 - b, 2 - c, 3 - d

Show answer

Correct answer

  • C

    1 - a, 2 - b, 3 - a

Question 13

+4.5 marksOne correct option

Consider the HTML document given below:

html
<!DOCTYPE html>
<html>
<head>
<style>
[id~=out] {
border: 10px solid red;
}
[class~=out]{
border: 5px solid yellow;
}
</style>
</head>
<body>
<h2>Hello World!</h2>
<h1 id="out">Hey!</h1>
<p id="out-text">My name is Fred.</p>
<p class="outcontent">I am learning to develop
applications.</p>
<p id ="out"> Are you also willing to learn?</p>
<p class="out">Welcome to the world of Application
development!</p>
<h3>Have a nice day!!</h3>
</body>
</html>

Which of the following statements is true for the above HTML document when rendered by the browser?

  1. A

    The headings, i.e., ‘Hello World!’ and ‘Hey!’, both will have red border color.

  2. B

    The paragraph with class=‘out’, will get a yellow color border.

  3. C

    The paragraph with id=‘out’ will get a yellow color border.

  4. D

    The two paragraphs with contents, ‘My name is Fred.’ and ‘I am learning to develop applications.’, will both get a red color border and yellow color border.

Show answer

Correct answer

  • B

    The paragraph with class=‘out’, will get a yellow color border.

Question 14

+4.5 marksOne correct option

Consider the following PyHTML program. Identify the corresponding HTML file which will be generated on running the PyHTML code.

python
from pyhtml import *
my_html = html(head(title("Quiz 2")),
body(h2("Second level heading"),
div("This is my first div"),
p("Paragraph1"),
p("Paragraph2")
)
)
output = my_html.render()
print(output)
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 15

+4.5 marksOne correct option
  1. A

    Package A

  2. B

    Package B

  3. C

    Both A and B will take same time

  4. D

    Both A and B will infinite time to process records

Show answer

Correct answer

  • A

    Package A

Question 16

+4.5 marksOne correct option

Consider the following Python code snippet:

python
from flask import Flask
from flask_restful import Resource, Api, reqparse, fields,
marshal_with
app = Flask('__main__')
api = Api(app)
parser = reqparse.RequestParser()
parser.add_argument("Id")
parser.add_argument("name")
parser.add_argument("email")
out_fields = {
"Id": fields.Integer,
"name": fields.String
}
class MyApi(Resource):
def get(self):
info = parser.parse_args()
return {"Identity": info['Id'] , "Name": info['name'],
"E-mail": info['email']}
@marshal_with(out_fields)
def post(self):
info = parser.parse_args()
return info
api.add_resource(MyApi, '/myinfo')
app.run(debug = True)

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

bash
curl -X POST -H "Content-Type: application/json"
-d "{\"Id\":3, \"name\":\"user_1\", \"email\":
\"user_1@gmail.com\"}" http://127.0.0.1:5000/myinfo
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B