uiz Space

May 2024 term · Modern Application Development I · BSCS2003

Modern Application Development I Quiz 2: 4 August 2024 (May 2024 term)

The IIT Madras BS Modern Application Development I (MAD 1) Quiz 2 paper sat on 4 Aug 2024, in the May 2024 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
MCQ
10
MSQ
6

Updated

Official paper: IIT M DIPLOMA AN EXAM QDD2 4 Aug 2024 · No negative marking.

Question 1

+2 marksOne correct option

Read the statements given below carefully and select the correct option.
Statement 1: The GET method is the same as the HEAD method. It is used to transfer the header section only.
Statement 2: The GET method retrieves information from the given server using a given URI.GET request can retrieve the data.

  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 1 is incorrect but statement 2 is correct

Show answer

Correct answer

  • D

    Statement 1 is incorrect but statement 2 is correct

Question 2

+2 marksOne correct option

Consider the below flask_sqlalchemy data models “Product”, “Supplier” and “Supply” given in the code below.

python
class Product(db.Model):
__tablename__ = "product"
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String, nullable=False)
class Supplier(db.Model):
__tablename__ = "supplier"
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String, nullable=False)
address = db.Column(db.String, nullable=True)
class Supply(db.Model):
__tablename__ = "supply"
id = db.Column(db.Integer, primary_key=True)
product_id = db.Column(db.Integer, db.ForeignKey("product.id"))
supplier_id = db.Column(db.Integer, db.ForeignKey("supplier.id"))

What will be the cardinality of the “Product” and “Supplier” relationship?

  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 3

+3 marksOne correct option

A certain video on the web occupies 3 gigabytes of memory of the server. If the number of viewers of the video over time is given by the curve shown below and assuming that each viewer requires an individual connection to the server to view the video, what should be the minimum RAM requirement of the server that can process requests from all the viewers simultaneously at any point of time?

  1. A

    1.9 GB

  2. B

    5.7 GB

  3. C

    1.9 TB

  4. D

    5.7 TB

Show answer

Correct answer

  • D

    5.7 TB

Question 4

+3 marksOne correct option

Consider the following Python code.

app.py

python
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import os
app_dir = os.path.dirname(os.path.abspath(__file__))
db_file = "sqlite:///course_database.sqlite3"
app = Flask(__name__)
app.app_context().push()
app.config["SQLALCHEMY_DATABASE_URI"] = db_file
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
db = SQLAlchemy(app)
class MaxScores(db.Model):
__tablename__ = "max_scores"
course_id = db.Column(db.String(10), nullable=False, primary_key=True)
high_score = db.Column(db.Integer)
term_year = db.Column(db.String(10))

Using MaxScores data model in the above “app.py”. What is the correct sequence of python commands to insert MaxScores record?

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

Correct answer

  • A

Question 5

+3 marksOne correct option

Consider the following Python code snippet, and select the correct output list if the code is run on the terminal.

python
def modify(func):
def wrapper(l):
res = func(l)
return res[::-1]
return wrapper
def update(func):
def wrapper(l):
res = func(l)
return list(map(lambda x: x/2,res))
return wrapper
@modify
@update
def mylist(l):
out_list = []
for i in l:
out_list.append(i**2)
return out_list
print(mylist([2,4,1,7,5,9]))
  1. A

    [0.25, 1, 4, 6.26, 12.25, 20.25]

  2. B

    [1, 4, 0.25, 12.25, 6.25, 20.25]

  3. C

    [40.5, 12.5, 24.5, 0.5, 8.0, 2.0]

  4. D

    [0.5, 2.0, 8.0, 12.5, 24.5, 40.5]

Show answer

Correct answer

  • C

    [40.5, 12.5, 24.5, 0.5, 8.0, 2.0]

Question 6

+3 marksOne or more correct options

Consider the following flask application.

python
from flask import Flask, request
app = Flask(__name__)
@app.route('/home')
def home():
var_a = request.args.get('method')
if var_a == "GET":
return """
<body style="background-color: lightgray; color:
purple;text-align: center;font-weight: bold;">
<p>IIT</p>
<p>MADRAS</p>
</body>
"""
elif var_a == "POST":
return """
<body style="background-color: lightgray; color:
purple;text-align: center;font-weight: bold;">
<p>IIT</p>
<span>MADRAS</span>
</body>
"""
else:
return "Invalid Method"
app.run(debug=True)

If the application is running locally on http://127.0.0.1:5000 then which of the following statements are correct?

Select all that apply.

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

Correct answers

  • A
  • D

Question 7

+3 marksOne or more correct options

Consider the following code.

python
from flask import Flask
from flask_restful import Resource, Api
trains_list = [
{"train_no": 12842, "source": "Madras", "destination": "Howrah"},
{"train_no": 12727, "source": "VSKP", "destination": "HYD"},
{"train_no": 12434, "source": "Delhi", "destination": "Madras"},
]
app = Flask(__name__)
api = Api(app)
class TrainsApi1(Resource):
def get(self, tno):
for train in trains_list:
if train["train_no"] == tno:
return train
return None
class TrainsApi2(Resource):
def get(self):
return trains_list
api.add_resource(TrainsApi1, "/api/ver1/<int:tno>")
api.add_resource(TrainsApi2, "/api/ver2/")
if __name__ == "__main__":
app.run(debug=True)

Assume that the above flask code is running locally on http://127.0.0.1:5000/ . Which of the below URL(s) requests renders train data without errors?

Select all that apply.

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

Question 8

+3 marksOne or more correct options

Consider the following flask application running locally on http://127.0.0.1:5000

app.py

python
from flask import Flask, request
import sys
app = Flask(__name__)
data = ["Java", "Application Development","DBMS"]
@app.route('/course')
def home():
course = request.args.get('course')
if course in sys.argv:
if sys.argv[1] in data:
return f"Welcome to {sys.argv[1]}!"
return f"Welcome to {course}!"
else:
return "Invalid Data"
app.run(debug=True)

Based on the above data, answer the given subquestions.

Select all that apply.

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

Correct answers

  • C
  • D

Question 9

+2 marksOne correct option

Consider the following flask application running locally on http://127.0.0.1:5000

app.py

python
from flask import Flask, request
import sys
app = Flask(__name__)
data = ["Java", "Application Development","DBMS"]
@app.route('/course')
def home():
course = request.args.get('course')
if course in sys.argv:
if sys.argv[1] in data:
return f"Welcome to {sys.argv[1]}!"
return f"Welcome to {course}!"
else:
return "Invalid Data"
app.run(debug=True)

Based on the above data, answer the given subquestions.

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

Correct answer

  • D

Question 10

+3 marksOne or more correct options

If the flask application is running locally on URL http://127.0.0.1:5000. Select the appropriate options for the given subquestions.

python
from flask import Flask, request
app = Flask(__name__)
users = [
{"id": "101", "name": "Ravi", "city": "Chennai"},
{"id": "102", "name": "Ram", "city": "Mumbai"},
{"id": "103", "name": "Rahim", "city": "Bhopal"},
{"id": "104", "name": "Robert", "city": "Delhi"},
]
def search_user(id):
for user in users:
if id == user.get("id"):
return user
return None
@app.route("/user/<string:id>")
def user(id):
this_user = search_user(id)
return this_user
@app.route("/user")
def get_user():
this_user = search_user(request.args.get('id'))
return this_user
app.run(debug=True)

Select all that apply.

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

Question 11

+3 marksOne correct option

If the flask application is running locally on URL http://127.0.0.1:5000. Select the appropriate options for the given subquestions.

python
from flask import Flask, request
app = Flask(__name__)
users = [
{"id": "101", "name": "Ravi", "city": "Chennai"},
{"id": "102", "name": "Ram", "city": "Mumbai"},
{"id": "103", "name": "Rahim", "city": "Bhopal"},
{"id": "104", "name": "Robert", "city": "Delhi"},
]
def search_user(id):
for user in users:
if id == user.get("id"):
return user
return None
@app.route("/user/<string:id>")
def user(id):
this_user = search_user(id)
return this_user
@app.route("/user")
def get_user():
this_user = search_user(request.args.get('id'))
return this_user
app.run(debug=True)
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 12

+4.5 marksOne correct option

You have a DRAM module with bus width of 64 bits, clock speed of 400 MHz, and operating in DDR (double-data-rate or two values per clock cycle) mode. What is the maximum memory bandwidth in Gigabytes per second achievable with this module if it is working in dual channel mode (two memory interfaces are used)?

  1. A

    51.2

  2. B

    102.4

  3. C

    25.6

  4. D

    12.8

Show answer

Correct answer

  • D

    12.8

Question 13

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

Correct answer

  • D

Question 14

+4.5 marksOne correct option

Consider the following Python code snippet.

Filename: code.py

python
import logging
import sys
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)
logging.warning('This is only for testing.')
if sys.argv[1] == 'info':
logging.info('This code is working as expected.')
if sys.argv[1] == 'debug':
logging.debug('This code may have issues, debugging...')
logging.warning('code execution complete!')

What will be output on the terminal is the above code snippet is run on the terminal using command: python code.py debug

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

Correct answer

  • C

Question 15

+2 marksOne or more correct options

Consider the following flask application.

app.py

python
from flask import Flask, abort, request
app = Flask(__name__)
@app.route('/login/<id>')
def login(id):
if id:
if id.isalpha():
abort(400, "Bad Request: Invalid ID")
return f'<h1>Your ID is: {id}</h1>'
return f'<h1>Invalid ID</h1>'
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 16

+4.5 marksOne or more correct options

Consider the following HTML Document and select the correct statement(s) from the following if a user types the password “mad1password” in the password field letter by letter.

html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Login Form</title>
<style>
input[type="password"]:valid{
background-color: green;
}
input[type="password"]:invalid{
background-color: red;
}
</style>
</head>
<body>
<div class="login-form">
<h2>Login</h2>
<form>
E-mail: <input type="email" id="email" name="email" required>
Password: <input type="password" id="password" name="password"
required minlength="5" maxlength="8">
<input type="submit" value="Login">
</form>
</div>
</body>
</html>

Select all that apply.

  1. A

    The HTML form is integrated with backend validation.

  2. B

    The HTML form is integrated with Frontend HTML5 validation.

  3. C

    The background colour of the password field remains red for the first 4 letters, then turns green for the next 4 letters, and then again turns red for the remaining letters.

  4. D

    The background colour of the password field remains red for the first 4 letters, then turns green for the next 4 letters, and then remains green for the remaining allowable letters.

Show answer

Correct answers

  • B

    The HTML form is integrated with Frontend HTML5 validation.

  • D

    The background colour of the password field remains red for the first 4 letters, then turns green for the next 4 letters, and then remains green for the remaining allowable letters.