uiz Space

September 2024 term · Modern Application Development I · BSCS2003

Modern Application Development I Quiz 2: 1 December 2024 (September 2024 term)

The IIT Madras BS Modern Application Development I (MAD 1) Quiz 2 paper sat on 1 Dec 2024, in the September 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 01 Dec 2024 · No negative marking.

Question 1

+4.5 marksOne correct option

You have a DRAM module with bus width of 64 bits, clock speed of 800 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

  • C

    25.6

Question 2

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

Correct answer

  • B

Question 3

+4.5 marksOne correct option

Consider the following python code.

python
from flask import Flask
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
salaries = {
1: {"name": "Ravi", "basic": 14500},
2: {"name": "David", "basic": 9500},
3: {"name": "Tinu", "basic": 15009},
}
class Salaries(Resource):
def do_something(self):
global salaries
for s in salaries.keys():
salaries[s]["hra"] = salaries[s]["basic"] * 0.10
def get(self):
self.do_something()
return salaries
api.add_resource(Salaries, "/api/salaries")
app.run(debug=True)

Consider that the above code is running locally on “http://127.0.0.1:5000”. What will the output for the URL: “http://127.0.0.1:5000/api/salaries”?

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

Correct answer

  • B

Question 4

+3 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.isalnum():
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

  • A
  • C
  • D

Question 5

+3 marksOne or more correct options

Consider the following flask application.

app.py

python
from flask import Flask, abort, request
app = Flask(__name__)
data = {'PDSA':'CS2003', 'DBMS':'CS2004', 'Java':'CS2005'}
@app.route('/course/<course_name>')
def course(course_name):
course_id = request.args.get('id')
if course_name in data and course_id == data[course_name]:
return f'<h1>The Course ID for {course_name} is: {course_id}</h1>'
else:
abort(400, "Bad Request: Invalid data")
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

  • A
  • B
  • D

Question 6

+3 marksOne or more correct options

Consider the following HTML document “form.html” and the flask route given in “app.py”. Assume all the required methods are imported, Which of the following statements is/are correct.

Filename: form.html

html
<!DOCTYPE html>
<html>
<head>
<style>
input:valid {border: 2px solid red;}
</style>
</head>
<body>
<form action="/submit_form" method="post">
<label for="e-mail">Please enter your email address</label>
<input id="e-mail" name="e-mail" required/>
<button>Submit</button>
</form>
</body>
</html>

Filename: app.py

python
@app.route('/submit_form', methods = ['GET', 'POST'])
def form_on_submit():
if request.method == 'POST':
email = request.form.get('e-mail')
if "@" in email:
return "Form is validated"
return render_template('form.html')

Select all that apply.

  1. A

    The above HTML document has frontend validation incorporated, using HTML5 form validation.

  2. B

    The above HTML document has only backend validation incorporated.

  3. C

    The above HTML document has both frontend and backend validation incorporated.

  4. D

    If the e-mail input field is left blank, the border colour of the input field will be red.

Show answer

Correct answers

  • A

    The above HTML document has frontend validation incorporated, using HTML5 form validation.

  • C

    The above HTML document has both frontend and backend validation incorporated.

Question 7

+3 marksOne or more correct options

Consider the following flask code.

python
from flask import Flask
import json
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class Car:
def __init__(self, brand, model):
self.brand = brand
self.model = model
def __str__(self) -> str:
result = {
"brand": self.brand,
"model": self.model,
}
return str(result)
class MyApi(Resource):
def get(self, brand, model):
c = Car(brand, model)
return json.dumps(c, default=vars)
api.add_resource(MyApi, "/api/<string:brand>/<string:model>")
app.run(debug=True)

If the flask server is running locally on “http://127.0.0.1:5000/”. Which of the following URLs will result in a Not Found error?

Select all that apply.

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

Correct answers

  • C
  • D

Question 8

+3 marksOne or more correct options

Consider the flask code below.

python
from flask import Flask
app = Flask(__name__)
@app.route("/")
def get_home():
a = [i for i in range(11)]
t = ", ".join(map(str, a))
return t
@app.route("/numbers/<int:n>")
def get_numbers(n):
a = [i for i in range(n + 1)]
t = ", ".join(map(str, a))
return t
if __name__ == "__main__":
app.run(debug=True)

Assume that the above flask application is running on http://127.0.0.1:5000. Which of the following statements is/are True for the above code snippet?

Select all that apply.

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

Correct answers

  • A
  • B
  • D

Question 9

+3 marksOne correct option

Consider a character set Q, which consists of only those characters used in the sentence, "the five boxing wizards jump quickly" If this sentence is to be saved in a document with minimum encoding, what will be the size of the document given that no other information or context is to be saved?

  1. A

    175 bits

  2. B

    180 bits

  3. C

    252 bits

  4. D

    256 bits

Show answer

Correct answer

  • B

    180 bits

Question 10

+3 marksOne correct option

We are trying to create two models ‘Student’ and ‘Assignment’ and they are related by one-to- many relationship(i.e., one student will attempt multiple assignments). Assuming that flask_sqlalchemy is to be used to create data models, which of the following will correctly achieve the requirements?

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

Correct answer

  • C

Question 11

+4.5 marksOne correct option

Consider the following resource created using Flask, assume that the application is running on a terminal 1 and being accessed using CURL on terminal 2. Answer the given subquestions.

python
from flask_restful import Api, Resource
from flask import Flask
app = Flask(__name__)
api = Api(app)
class TestApi(Resource):
def get(self):
# logic to retrieve data from backend
return {
"val1": "value1",
"val2": "value2",
"val3": "value3"
}
def delete(self, val):
# logic to delete the value from data w.r.t "val" argument provided
return {
"message": "Value deleted successfully",
"value": val
}, 200
def put(self, val):
# logic to update the value from data w.r.t "val" argument provided
return {
"message": "Value updated successfully",
"value": val
}, 200
api.add_resource(TestApi, '/get_values', '/delete/<val>', '/update/<val>')
app.run()

What will be returned on the terminal 2 for the command:

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

Correct answer

  • D

Question 12

+3 marksOne correct option

Consider the following resource created using Flask, assume that the application is running on a terminal 1 and being accessed using CURL on terminal 2. Answer the given subquestions.

python
from flask_restful import Api, Resource
from flask import Flask
app = Flask(__name__)
api = Api(app)
class TestApi(Resource):
def get(self):
# logic to retrieve data from backend
return {
"val1": "value1",
"val2": "value2",
"val3": "value3"
}
def delete(self, val):
# logic to delete the value from data w.r.t "val" argument provided
return {
"message": "Value deleted successfully",
"value": val
}, 200
def put(self, val):
# logic to update the value from data w.r.t "val" argument provided
return {
"message": "Value updated successfully",
"value": val
}, 200
api.add_resource(TestApi, '/get_values', '/delete/<val>', '/update/<val>')
app.run()

What will be returned on the terminal 2 for the command:

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

Correct answer

  • B

Question 13

+2 marksOne or more correct options

Which of the following statements are correct?

Select all that apply.

  1. A

    HTML defines the styling, while CSS defines the content

  2. B

    HTML defines the content, while CSS defines the styling

  3. C

    JavaScript is always the core part of an application’s frontend

  4. D

    JavaScript provides additional functionality at the frontend

Show answer

Correct answers

  • B

    HTML defines the content, while CSS defines the styling

  • D

    JavaScript provides additional functionality at the frontend

Question 14

+2 marksOne correct option

Identify the correct order of tasks that take place when a client makes a request on the URL: https://example.com/home.html.

  1. The web browser sends an HTTPS request to the server, requesting a copy of home.html.
  2. The web browser assembles the response and displays it.
  3. The server responds either with the requested resource or an error code.
  4. The web browser connects to the DNS server to get the server IP address, for example.com.
  1. A

    1-4-3-2

  2. B

    4-1-3-2

  3. C

    1-3-4-2

  4. D

    4-3-1-2

Show answer

Correct answer

  • B

    4-1-3-2

Question 15

+2 marksOne correct option

Consider the following statements and select the correct option.
Statement 1: Redundancy is used to improve performance and decrease server load. Statement 2: Replication ensures data is not lost if a copy gets destroyed.

  1. A

    Statement 1 is true & statement 2 is false

  2. B

    Statement 2 is true & statement 1 is false

  3. C

    Both statements 1 and 2 are true

  4. D

    Both statements 1 and 2 are false

Show answer

Correct answer

  • D

    Both statements 1 and 2 are false

Question 16

+2 marksOne correct option

The term “stateless” in the context of a server means that _________

  1. A

    it is not physically located on any particular machine

  2. B

    it does not have any information about the state of the client

  3. C

    it is ephemeral

  4. D

    All of these

Show answer

Correct answer

  • B

    it does not have any information about the state of the client