Quiz Space

September 2022 term · Modern Application Development I · BSCS2003

MAD 1 End Term: 11 December 2022, Set ETD1 (September 2022 term)

The IIT Madras BS Modern Application Development I (MAD 1) End Term paper sat on 11 Dec 2022, in the September 2022 term, set ETD1: 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
23
Numerical
1
MSQ
8

Updated

Official paper: IIT M DIPLOMA FN1 EXAM ETD1 11 Dec 2022 · No negative marking.

Question 1

+2 marksOne correct option

Consider the following HTML document with script which is running at the URL
http://127.0.0.1:8000, then choose the correct output of the JSON object.

html
<!DOCTYPE html>
<html>
<body>
<h2>Creating a JSON String</h2>
<p id="demo"></p>
<script>
const txt = '{"name":"Balu", "age":30, "city":"New Delhi"}'
const obj = JSON.parse(txt);
document.getElementById("demo").innerHTML = "Hi\n" + obj.name +
",\t" + obj.city + "," + obj.age*2;
</script>
</body>
</html>
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 2

+2 marksOne correct option

If the given python program is executed using pytest, then identify the status of the test code.

File name: test1.py

python
def dec(x):
return x-1
def test_answer():
assert dec(3) == 2
  1. A

    passed test1.py test_answer - assert 2 == 3

  2. B

    2 Failed

  3. C

    1 passed

  4. D

    Failed test1.py test_answer - assert 2 == 3

Show answer

Correct answer

  • C

    1 passed

Question 3

+2 marksOne correct option

Which of the following lines can be used in a template to inherit another base.html template that provides a basic, uniform layout?

  1. A

    {% expand 'base.html'%}

  2. B

    {% include 'base.html'%}

  3. C

    {% extends 'base.html'%}

  4. D

    {% inherits 'base.html' %}

Show answer

Correct answer

  • C

    {% extends 'base.html'%}

Question 4

+2 marksOne correct option

Which of the following routes binds the index() function to the application's root URL and renders the index.html template?

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

Correct answer

  • B

Question 5

+2 marksOne correct option

In which of the following options, url_for() function calls will produce URL
http://localhost:5000/home?

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

Correct answer

  • B

Question 6

+2 marksOne correct option

Read the following statements carefully and mark the correct answer:
Statement 1: Continuous integration is the practice of automating the integration of code changes from multiple contributors into a single software project
Statement 2: Continuous Delivery refers to automated delivery of “release package” on each successful test

  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 7

+2 marksNumerical answer

Compute the octal representation of the binary number (01000101)2.
Note: The answer must be an integer. For ex: If the octal representation is (39)8, then you must write 39 only

Show answer

Correct answer: 105

Question 8

+3 marksOne correct option

Consider the URL given below.
https://onlinedegree.com/academics?course=appdev1\#week2
Which of the following options correctly describes each component of the URL given above?

  1. A

    1-C, 2-A, 3-D, 4-B, 5-E

  2. B

    1-C, 2-A, 3-E, 4-B, 5-D

  3. C

    1-A, 2-C, 3-D, 4-B, 5-E

  4. D

    1-C, 2-A, 3-B, 4-E, 5-D

Show answer

Correct answer

  • B

    1-C, 2-A, 3-E, 4-B, 5-D

Question 9

+3 marksOne correct option

Consider the following flask python snippet with all preliminary conditions.

python
class User(UserMixin, db.Model):
id = db.Column(db.Integer, primary_key = True)
name = db.Column(db.String(30))
def __init__(self, id, name):
self.id = id
self.name = name
@login_manager.user_loader
def firstuser(id):
return User.query.get(int(id))
@app.route('/')
def index():
u1 = User.query.filter_by(id = 112).first()
login_user(u1)
return current_user.name + 'logged in'
@app.route('/logout')
@login_required
def logout():
logout_user()
return 'logged out'
@app.route('/home')
@login_required
def home():
return "current user is " + current_user.name
python
def init_db():
db.create_all()
new_user = User(112,'Rose')
new_user2 = User(113,'lily')
db.session.add(new_user)
db.session.add(new_user2)
db.session.commit()
if __name__ == '__main__':
init_db()
app.run(debug = True)

If the above program is running in the URL “http://127.0.0.1:8000” then what will be the output for the given URLs in sequence
● http://127.0.0.1:8000
● http://127.0.0.1:8000/logout
● http://127.0.0.1:8000/home

  1. A

    current user is lily
    logged out
    Unauthorized user

  2. B

    Rose logged in
    logged out
    Unauthorized user

  3. C

    Rose logged in
    current user is Rose
    logged out

  4. D

    lily logged in
    current user is lily
    logged out

Show answer

Correct answer

  • B

    Rose logged in
    logged out
    Unauthorized user

Question 10

+3 marksOne correct option

Which of the following is the correct order of precedence to reflect the effect of style in HTML documents?

  1. A

    internal > inline > external

  2. B

    inline > internal > external

  3. C

    inline > external > internal

  4. D

    external > internal > inline

Show answer

Correct answer

  • B

    inline > internal > external

Question 11

+3 marksOne correct option

Which of the following Jinja templates correctly implements a simple if-else statement?

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

Correct answer

  • C

Question 12

+3 marksOne correct option

A template named userinfo.html contains the following line inside the body tag:

Which of the following code snippets will utilize the template to display Hello Ram when http://localhost:5000/user/Ram is visited on the browser?

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

Correct answer

  • B

Question 13

+3 marksOne correct option

Which line of code correctly adds the below Hello class as a resource to a Flask application to get data using “http://localhost:5000/hello" URL?

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

Correct answer

  • A

Question 14

+3 marksOne correct option

A server using the inbuilt http module of Python, is running for a directory My_app whose file structure and content of each file is given below.

Folder: My_app

text
My_app
|_ home.html
|_ first.html
|_ main.html

File: home.html

html
<h1>Hello from Home!</h1>

File: first.html

html
<h1>Hello from First!</h1>

File: main.html

html
<h1>Hello from Main!</h1>

What will be rendered by the browser for the URL: http://localhost:8000/first.html assuming that 8000 is the port of connection?

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

Correct answer

  • B

Question 15

+3 marksOne correct option

Match the following:

Which of the following is the correct?

  1. A

    A-1, B-2, C-3, D-4

  2. B

    A-2, B-4, C-1, D-3

  3. C

    A-3, B-4, C-2, D-1

  4. D

    A-4, B-3, C-1, D-2

Show answer

Correct answer

  • C

    A-3, B-4, C-2, D-1

Question 16

+3 marksOne or more correct options

Which of the following statement(s) is/are false regarding Git?

Select all that apply.

  1. A

    Git is an example of a centralized version control system.

  2. B

    A file can stay in both working directory and staging area at a given time, while working with Git.

  3. C

    Git and GitLab/GitHub are essentially the same.

  4. D

    The command “git checkout -b <branch_name> ” will create the new branch and switches to the new branch created.

Show answer

Correct answers

  • A

    Git is an example of a centralized version control system.

  • C

    Git and GitLab/GitHub are essentially the same.

Question 17

+3 marksOne or more correct options

Which of the following statement(s) is/are true regarding database migrations?

Select all that apply.

  1. A

    Flask does not provide support for migrations, as of December 2022.

  2. B

    The database migration allows a developer to make schema changes without losing the data

  3. C

    One of the disadvantages of migration is that a developer can only upgrade the database, and it does not allow rollbacks.

  4. D

    The migration is useful when a business wants to move from an on-premise database to a cloud based database.

Show answer

Correct answers

  • B

    The database migration allows a developer to make schema changes without losing the data

  • D

    The migration is useful when a business wants to move from an on-premise database to a cloud based database.

Question 18

+3 marksOne or more correct options

Consider the following Model for User.

python
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(100),unique=True,index=True)
name = db.Column(db.String(100))
password = db.Column(db.String(100))

Which of the following methods from the Flask-sqlalchemy package will behave the same as SQL query select * from User where name='Ram'?

Select all that apply.

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

Correct answers

  • A
  • D

Question 19

+4.5 marksOne correct option

Consider the following constraints for the “student” table:

For the above student table, which of the following columns would be the most appropriate for the indexing?

  1. A

    RollNo

  2. B

    Name

  3. C

    Section

  4. D

    Department

Show answer

Correct answer

  • C

    Section

Question 20

+4.5 marksOne or more correct options

Consider the following Python code snippet:

Filename: module_0.py

python
import sys
arguments = sys.argv
courses = {'MAD 1': '1002', 'MAD-2': '2003', 'BDM': '205', 'SysCom': '304'}
def operate():
arg_1 = arguments[1]
arg_2 = courses[arg_1]
return f"The function output is: {len(arg_1 + arg_2)}"
print(operate())

The above file will yield the output as “The function output is: 9”, for which of the following command line inputs?

Select all that apply.

  1. A

    python module_0.py MAD 1

  2. B

    python module_0.py MAD-2

  3. C

    python module_0.py BDM

  4. D

    python module_0.py SysCom

Show answer

Correct answers

  • B

    python module_0.py MAD-2

  • D

    python module_0.py SysCom

Question 21

+4.5 marksOne or more correct options

Select all that apply.

  1. A

    Software package A is slower than Software package B for inputs in the range N ∈ [0,3]

  2. B

    Software package B is slower than Software package A for inputs in the range N ∈ [0,3]

  3. C

    Software package B is faster than Software package A for all N > 3.

  4. D

    Time taken by both the software packages A and B is the same when N = 3.

Show answer

Correct answers

  • A

    Software package A is slower than Software package B for inputs in the range N ∈ [0,3]

  • D

    Time taken by both the software packages A and B is the same when N = 3.

Question 22

+4.5 marksOne or more correct options

Consider the following Python code snippet.

python
from flask import Flask, abort, redirect, url_for, render_template
app = Flask(__name__)
data_science = ['ML-techniques','ML-foundations','PDSA']
programming = ['Java','MAD-I', 'System-Commands', 'ML-practices']
@app.route('/courses/<course>')
def find_course(course):
if course in data_science:
return f"<h2>Data Science course found, {course}!</h2>"
elif course in programming:
return f"<h2>Programming course found, {course}!</h2>"
else:
abort(401)
@app.errorhandler(401)
def page_not_found(error):
return "<h2>No course found!<!h2>"
app.run()

If the above application is running locally on URL: 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

  • C
  • D

Question 23

+4.5 marksOne or more correct options

Consider the following two tables, user1 and logstable:

Which of the following query/ queries will return the log ID and log name, which are created by user ‘Shaun’?

Select all that apply.

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

Correct answers

  • A
  • B

Question 24

+3 marksOne correct option

Consider the following jinja2 template, and answer the given subquestions.

python
from jinja2 import Template
temp = """
Data science combines {{a}} abilities and competence in
{{b}}, {{c}} to draw important insights from data.
"""
to_render = Template(temp)
out = to_render.render(data)
print(out)

What will be the output on the terminal for:

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

Correct answer

  • C

Question 25

+3 marksOne correct option

Consider the following jinja2 template, and answer the given subquestions.

python
from jinja2 import Template
temp = """
Data science combines {{a}} abilities and competence in
{{b}}, {{c}} to draw important insights from data.
"""
to_render = Template(temp)
out = to_render.render(data)
print(out)

What will be the output on the terminal for:

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

Correct answer

  • C

Question 26

+2 marksOne correct option

Consider the below graph, and answer the given subquestions.
The bandwidth vs. time graph for a period of one hour between 12 noon to 1 p.m in the afternoon is shown below. [Use relations: 1 Byte = 8 bits, 1 GB = 1000 MB and so on.]

What is the network bandwidth (in Mbps) of the network at exactly 12:30 pm?

  1. A

    5

  2. B

    6

  3. C

    7

  4. D

    8

Show answer

Correct answer

  • C

    7

Question 27

+4.5 marksOne correct option

Consider the below graph, and answer the given subquestions.
The bandwidth vs. time graph for a period of one hour between 12 noon to 1 p.m in the afternoon is shown below. [Use relations: 1 Byte = 8 bits, 1 GB = 1000 MB and so on.]

What is the total amount of data (in GigaBytes) consumed by the only user connected to the network between 12:15 pm to 12:30 pm? [Assuming that the user is using the entire bandwidth from 12:15 p.m to 12:30 p.m]

  1. A

    81

  2. B

    8.1

  3. C

    1.0125

  4. D

    10.125

Show answer

Correct answer

  • C

    1.0125

Question 28

+3 marksOne correct option

Consider the below model definitions, and answer the given subquestions.
Consider the following model classes “Movies” and “Producers” corresponding to tables “movies” and “producers”, respectively, in the SQLite database.

python
class Movies(db.Model):
id = db.Column(db.Integer(), primary_key = True)
movie_name = db.Column(db.String(50), nullable = False, unique = True)
movie_year = db.Column(db.Integer, nullable = False)
producers = db.relationship('Producer', backref = 'movie', secondary = 'groups')
class Producer(db.Model):
id = db.Column(db.Integer(), primary_key = True)
producer_name = db.Column(db.String(50), nullable = False, unique = True)
productions = db.Column(db.Integer())
class Groups(db.Model):
movie_id = db.Column(db.Integer(),db.ForeignKey('movies.id'), primary_key = True)
prod_id = db.Column(db.Integer(),db.ForeignKey('producer.id'), primary_key = True)

The tables “movies” and “producers” are related to each other by which of the following relationships

  1. A

    One-to-one

  2. B

    One-to-many

  3. C

    Many-to-Many

  4. D

    Many-to-One

Show answer

Correct answer

  • C

    Many-to-Many

Question 29

+4.5 marksOne or more correct options

Consider the below model definitions, and answer the given subquestions.
Consider the following model classes “Movies” and “Producers” corresponding to tables “movies” and “producers”, respectively, in the SQLite database.

python
class Movies(db.Model):
id = db.Column(db.Integer(), primary_key = True)
movie_name = db.Column(db.String(50), nullable = False, unique = True)
movie_year = db.Column(db.Integer, nullable = False)
producers = db.relationship('Producer', backref = 'movie', secondary = 'groups')
class Producer(db.Model):
id = db.Column(db.Integer(), primary_key = True)
producer_name = db.Column(db.String(50), nullable = False, unique = True)
productions = db.Column(db.Integer())
class Groups(db.Model):
movie_id = db.Column(db.Integer(),db.ForeignKey('movies.id'), primary_key = True)
prod_id = db.Column(db.Integer(),db.ForeignKey('producer.id'), primary_key = True)

If an object “p1” that represents an existing record in the table “producer” is defined as p1 = Producer.query.get(2), The correct way to create a new record in the “movies” table that is produced by the producer represented by object ‘p1’ using terminal is.

Select all that apply.

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

Correct answers

  • A
  • B

Question 30

+3 marksOne correct option

Consider the below program, and answer the given subquestions, if the application is running locally on URL: http://127.0.0.1:5000.

Consider the following resource created with help of flask-restful.

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

If the curl request shown below.

bash
curl http://127.0.0.1:5000/api/v1/5001 -X GET

retrieves the employee_id 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

  • B

Question 31

+3 marksOne correct option

Consider the below program, and answer the given subquestions, if the application is running locally on URL: http://127.0.0.1:5000.

Consider the following resource created with help of flask-restful.

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

If the curl request shown below.

bash
curl http://127.0.0.1:5000/api/v1 -X POST -d "{\"employee_id\" : \"2003\",
\"employee_name\": \"Suresh\"}" -H "Content-Type: application/json"

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

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

Correct answer

  • C

Question 32

+4.5 marksOne correct option

Consider the below program, and answer the given subquestions, if the application is running locally on URL: http://127.0.0.1:5000.

Consider the following resource created with help of flask-restful.

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

Correct answer

  • D