Question 1
Which of the following is the correct syntax to display the total number of courses in a Jinja2 template?

The IIT Madras BS Modern Application Development I (MAD 1) Quiz 1 paper sat on 26 Oct 2025, in the September 2025 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.
Which of the following is the correct syntax to display the total number of courses in a Jinja2 template?
Correct answer
Consider the following code:
app.py
from flask import Flaskapp = Flask(__name__)
@app.route("/")def port(): return "This is the port question."
if __name__ == "__main__": app.run(port=5008)You are running a Flask web application locally using the command: python app.py. On which URL will the application be accessible on the browser?
Correct answer
Statement 1 is correct, but statement 2 is incorrect.
Statement 2 is correct, but statement 1 is incorrect.
Both statements 1 and 2 are correct
Both statements 1 and 2 are incorrect
Correct answer
Statement 2 is correct, but statement 1 is incorrect.
Correct answer
Consider two Python files, main.py and utils.py with the following code snippets.
File1: main.py
import sysimport utilsprint('Processing: ' + sys.argv[2])File2: utils.py
import sysprint('Module: ' + sys.argv[0])What is the output of the following command "python main.py data.txt output.txt" when run on terminal?
Correct answer
1 → B, 2 → C, 3 → D, 4 → A
1 → A, 2 → B, 3 → C, 4 → D
1 → B, 2 → D, 3 → C, 4 → A
1 → C, 2 → D, 3 → A, 4 → B
Correct answer
1 → B, 2 → D, 3 → C, 4 → A
Consider the following Python code snippet.
from jinja2 import Template as JTemplatefrom string import Template as STemplate
data = {'name1': 'Alice', 'name2': 'name1', 'age1': '25', 'age2': 'age1', 'job1': 'Engineer', 'job2': 'job1'}
jt = JTemplate("{{name2}} is {{age2}} years old and works as a {{job2}}.")result1 = jt.render(data)print(result1) #first print statement
st = STemplate(result1)result2 = st.substitute(data)print(result2) #second print statementIf the above Python code runs on the terminal, which of the following statements is/are correct?
Correct answers
Correct answers
Consider the following HTML and CSS code:
<html> <head> <style> div { width: 0px; margin: 0px; } .container { width: 200px; padding: 15px; border: 5px solid black; } #box { margin: 10px; } </style> </head> <body> <div class="container" id="box">Hello World</div> </body></html>What is the total width (approximately ) of the div with class="container" and id="box", including content, padding, and border but excluding margin?
200 px
230 px
240 px
250 px
Correct answer
240 px
Consider the following code:
from flask import Flask, request, render_template_string
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])def home(): if request.method == 'POST': name = request.form['name'] template = "Hello, {{ name }}!" return render_template_string(template, name=name) return ''' <form method="POST"> Enter Your Name: <input type="text" name="name"> <button>Submit</button> </form> '''
if __name__ == '__main__': app.run(debug=True)You are building a Flask web application that takes user input from an HTML form and displays it using Jinja2 templates. Suppose the user runs this app locally and submits the name Alice in the form.
Which of the following represents the correct sequence of concepts that occur when the user submits the form with the name Alice ?
Correct answer
Correct answers
Correct answers
Consider the following Python code snippet.
Filename: server.py
from flask import Flask, requestimport sys
app = Flask(__name__)
@app.route('/api/data', methods=sys.argv[1:])def handle_data(): if request.method == 'GET': return "<h1>Data retrieved successfully</h1>" elif request.method == 'PUT': return "<h1>Data updated successfully</h1>" elif request.method == 'DELETE': return "<h1>Data deleted successfully</h1>" else: return "<h1>Unsupported operation</h1>"
app.run(debug=True)Based on the above data, answer the given subquestions.
Correct answer
Consider the following Python code snippet.
Filename: server.py
from flask import Flask, requestimport sys
app = Flask(__name__)
@app.route('/api/data', methods=sys.argv[1:])def handle_data(): if request.method == 'GET': return "<h1>Data retrieved successfully</h1>" elif request.method == 'PUT': return "<h1>Data updated successfully</h1>" elif request.method == 'DELETE': return "<h1>Data deleted successfully</h1>" else: return "<h1>Unsupported operation</h1>"
app.run(debug=True)Based on the above data, answer the given subquestions.
Correct answer
Consider the following Flask code:
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/login', method="GET")def login(id): name = request.form.get('name', 'Guest') return render_template("login.html", name=name)
if __name__ == '__main__': app.run(debug=True)login.html
<body> {{ name }} <form action="/login" method="POST"> <input type="text" name="name" placeholder="Enter your name"> <button type="submit">Submit</button> </form></body>Based on the above data, answer the given subquestions.
From the given options, select which part of the code (if any) will throw an error first in the terminal and prevent the Flask application from running successfully ?
Correct answer
Consider the following Flask code:
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/login', method="GET")def login(id): name = request.form.get('name', 'Guest') return render_template("login.html", name=name)
if __name__ == '__main__': app.run(debug=True)login.html
<body> {{ name }} <form action="/login" method="POST"> <input type="text" name="name" placeholder="Enter your name"> <button type="submit">Submit</button> </form></body>Based on the above data, answer the given subquestions.
Correct answer