MAD Study Hub

Home / Past papers / MAD1 Quiz 1 / this paper

IIT M IMPROVEMENT AN EXAM QIM2 26 Oct - 26 Oct 2025

MAD1 Quiz 116 questions50 marks12 MCQ · 4 MSQImprovement / afternoon / QIM2
Elapsed 00:00
Q1MCQ2 marks
Which of the following is the correct syntax to display the total number of courses in a Jinja2 template?
  1. question figure
    text
    ```
    {{ courses | len }}
    ```
  2. question figure
    text
    ```jinja
    {{ courses | length }}
    ```
  3. question figure
    text
    ```html
    {{ len(courses) }}
    ```
  4. question figure
    text
    None of these
Q2MCQ2 marks
question figure
Text of the picture (copyable)
Consider the following code:
app.py

```python
from flask import Flask
app = 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?
  1. question figure
    text
    http://127.0.0.1:5000/
  2. question figure
    text
    http://localhost:0000/
  3. question figure
    text
    http://0.0.0.0:5000/
  4. question figure
    text
    http://localhost:5008/
Q3MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following statements and select the correct option.

Statement 1: The `<span>` elements will start on new lines, while the `<div>` elements will appear inline with surrounding content.

Statement 2: The `<p>` and `<div>` elements will each start on new lines and take up the full width of their container, while `<span>`, `<strong>`, and `<em>` will flow inline with surrounding content.
  1. Statement 1 is correct, but statement 2 is incorrect.
  2. Statement 2 is correct, but statement 1 is incorrect.
  3. Both statements 1 and 2 are correct
  4. Both statements 1 and 2 are incorrect
Q4MCQ3 marks
question figure
Text of the picture (copyable)
Which of the following Flask view functions will return a 404 error for the URL:
```
http://127.0.0.1:5000/profile/user123/active/2024?
```
  1. question figure
    text
    ```python
    @app.route('/profile/<username>/<status>/<int:year>')
    def profile(username, status, year):
        info = {'username': username, 'status': status, 'year': year}
        return info
    ```
  2. question figure
    text
    ```python
    @app.route('/profile/<string:username>/<string:status>/<string:year>')
    def profile(username, status, year):
        info = {'username': username, 'status': status, 'year': year}
        return info
    ```
  3. question figure
    text
    ```python
    @app.route('/profile/<username>/<status>/<year>')
    def profile(username, status, year):
        info = {'username': username, 'status': status, 'year': year}
        return info
    ```
  4. question figure
    text
    ```python
    @app.route('/profile/user/<username>/<status>/<year>')
    def profile(username, status, year):
        info = {'username': username, 'status': status, 'year': year}
        return info
    ```
Q5MCQ3 marks
question figure
Text of the picture (copyable)
Consider two Python files, main.py and utils.py with the following code snippets.

File1: main.py
```python
import sys
import utils
print('Processing: ' + sys.argv[2])
```

File2: utils.py
```python
import sys
print('Module: ' + sys.argv[0])
```

What is the output of the following command "python main.py data.txt output.txt" when run on terminal?
  1. question figure
    text
    ```
    Module: utils.py
    Processing: data.txt
    ```
  2. question figure
    text
    ```
    Processing: data.txt
    Module: utils.py
    ```
  3. question figure
    text
    ```
    Module: main.py
    Processing: output.txt
    ```
  4. question figure
    text
    ```
    Processing: output.txt
    Module: main.py
    ```
Q6MCQ3 marks
question figure
Text of the picture (copyable)
Match the following web development concepts with their correct descriptions:

| Column A | Column B |
|---|---|
| 1. PyHTML | A. Lightweight engine in Python for embedding variables inside strings using `$variable` style |
| 2. Jinja2 | B. A Python library to build HTML structures programmatically using Python functions |
| 3. Template Rendering | C. The process of generating dynamic HTML by combining templates with data |
| 4. String Template Rendering | D. Templating engine used by Flask that supports control structures, filters, and inheritance |
  1. 1 → B, 2 → C, 3 → D, 4 → A
  2. 1 → A, 2 → B, 3 → C, 4 → D
  3. 1 → B, 2 → D, 3 → C, 4 → A
  4. 1 → C, 2 → D, 3 → A, 4 → B
Q7MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following Python code snippet.

```python
from jinja2 import Template as JTemplate
from 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 statement
```

If the above Python code runs on the terminal, which of the following statements is/are correct?
  1. question figure
    text
    The first print statement will output: "name1 is age1 years old and works as a job1."
  2. question figure
    text
    The second print statement will output: "Alice is 25 years old and works as a Engineer."
  3. question figure
    text
    Jinja2 templates use double curly braces {{}} for variable substitution
  4. question figure
    text
    String templates use dollar signs $ for variable substitution in the substitute() method
  5. question figure
    text
    The code will raise a KeyError exception during execution
Q8MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
Which of the following Flask view functions will NOT throw any error for the URL:
`http://127.0.0.1:5000/user?username=mad1&role=admin?`
  1. question figure
    text
    ```python
    @app.route('/user')
    def profile():
        creds = request.args
        info = {'username': creds["username"], 'role': creds["role"]}
        return info
    ```
  2. question figure
    text
    ```python
    @app.route('/user/<username>/<role>')
    def profile(username, role):
        info = {'username': username, 'role': role}
        return info
    ```
  3. question figure
    text
    ```python
    @app.route('/user')
    def profile():
        return {'message': 'data retrieved successfully'}
    ```
  4. question figure
    text
    All of these
Q9MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following HTML and CSS code:

```html
<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?
  1. 200 px
  2. 230 px
  3. 240 px
  4. 250 px
Q10MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following code:

```python
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** ?
  1. question figure
    text
    HTML Form Rendering → HTTP 404 Not Found Error → User Submits Form → Flask Routing → Template Rendering
  2. question figure
    text
    User Submits Form (HTTP POST) → Check URL Structure → Network Transfer (Bandwidth & Latency) → Flask Routing
  3. question figure
    text
    User Accesses URL (Form at "/") → User Submits Form (HTTP POST) → Flask Request
    Handling (request.form) → Jinja2 Template Rendering
  4. question figure
    text
    Flask Request Handling → Network Round Trip (RTT) → HTML Table Rendering → Jinja2 Template Rendering
Q11MSQ2 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the web URL.
http://localhost:5000/

Which of the following is/are **True**?
  1. question figure
    text
    http is the protocol.
  2. question figure
    text
    5000 is the port number.
  3. question figure
    text
    The trailing / represents the base URL.
  4. question figure
    text
    5000 is the status code.
Q12MSQ2 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following HTML snippet:

```html
<img src="logo.png" alt="Company Logo" />
```

Which of the following is true?
  1. question figure
    text
    If logo.png fails to load, the text "Company Logo" will be shown.
  2. question figure
    text
    If the image file is missing, browsers display it as a broken image.
  3. question figure
    text
    The alt attribute is mandatory in HTML5.
  4. question figure
    text
    Logo.png fails to load because the `<img>` tag only allows "jpeg/jpg" files.
Comprehension passage - the questions below it refer to this
Based on the above data, answer the given subquestions. question figure
Q13MCQ4.5 marks
question figure
Text of the picture (copyable)
If the given Flask app is run using the command
```
python server.py GET PUT POST
```
in one terminal, what will be the output on another terminal for the command
```
curl -X POST http://127.0.0.1:5000/api/data?
```
  1. question figure
    text
    ```html
    <h1>Data added successfully</h1>
    ```
  2. question figure
    text
    ```html
    <h1>Unsupported operation</h1>
    ```
  3. question figure
    text
    ```html
    <h1>Method not Allowed</h1>
    ```
  4. question figure
    text
    ```html
    <h1>404 Not Found</h1>
    ```
Q14MCQ3 marks
question figure
Text of the picture (copyable)
If the given Flask app is run using the command
```
python server.py GET PUT POST
```
in one terminal, what will be the output on
another terminal for the command
```
curl -X DELETE http://127.0.0.1:5000/api/data?
```
  1. question figure
    text
    ```html
    <h1>Data deleted successfully</h1>
    ```
  2. question figure
    text
    ```html
    <h1>Unsupported operation</h1>
    ```
  3. question figure
    text
    ```html
    <h1>Method not Allowed</h1>
    ```
  4. question figure
    text
    ```html
    <h1>404 Not Found</h1>
    ```
Comprehension passage - the questions below it refer to this
Based on the above data, answer the given subquestions. question figure
Q15MCQ4.5 marks
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 ?
  1. question figure
    text
    method="GET" is not correct, it should be methods=["GET"]
  2. question figure
    text
    ```python
    def login(id)
    ```
    can throw error because no id is passed in, /login url
  3. question figure
    text
    name will throw error because no name will be written in the starting of app
  4. question figure
    text
    There is no error, Flask application will run correctly.
Q16MCQ3 marks
question figure
Text of the picture (copyable)
Assume the **terminal error** (so the Flask server
starts) has already been **fixed**. Now, if you hit
the `/login` URL in the browser, which of the
following is the correct option in this case?
  1. question figure
    text
    method="GET" is not correct, it should be methods=["GET"]
  2. question figure
    text
    ```python
    def login(id) can throw error because no id is passed in /login url
    ```
  3. question figure
    text
    name will throw error because no name will be written in the starting of app
  4. question figure
    text
    There is no error, Flask application will run correctly.

Answer key

  1. Q1 (MCQ, 2 marks): B
  2. Q2 (MCQ, 2 marks): D
  3. Q3 (MCQ, 3 marks): B
  4. Q4 (MCQ, 3 marks): D
  5. Q5 (MCQ, 3 marks): C
  6. Q6 (MCQ, 3 marks): C
  7. Q7 (MSQ, 3 marks): A, C, D
  8. Q8 (MSQ, 3 marks): A, C
  9. Q9 (MCQ, 4.5 marks): C
  10. Q10 (MCQ, 4.5 marks): C
  11. Q11 (MSQ, 2 marks): A, B, C
  12. Q12 (MSQ, 2 marks): A, B
  13. Q13 (MCQ, 4.5 marks): B
  14. Q14 (MCQ, 3 marks): C
  15. Q15 (MCQ, 4.5 marks): A
  16. Q16 (MCQ, 3 marks): B

Concepts this paper tests

Auto-generated summary from the source site. Handy as a checklist; the lessons above explain each idea from scratch.

Here’s a structured summary of the core topics, concepts, principles, and key takeaways from the exam questions, followed by Mermaid knowledge graphs to visualize relationships.


Core Topics & Concepts

1. Web Development Fundamentals

Key Concepts:

Equations/Code Snippets:


2. Flask Framework

Key Concepts:

Equations/Code Snippets:


3. Jinja2 Templating

Key Concepts:

Equations/Code Snippets:


4. HTML/CSS Basics

Key Concepts:

Equations/Code Snippets:


5. Python & Command-Line Arguments

Key Concepts:

Equations/Code Snippets:


6. Debugging & Common Errors

Key Concepts:

Equations/Code Snippets:


Graph 2: Flask Request Flow

Graph 3: Jinja2 vs String Templates

Graph 4: HTML Box Model

Graph 5: Flask Error Handling


Exam Preparation Checklist

  1. Flask:

    • Route syntax (@app.route, dynamic routes).
    • request object (args, form, method).
    • Template rendering (render_template, render_template_string).
    • Common errors (404, 405, methods= vs method=).
  1. Jinja2:

    • Syntax ({{ }}, {% %}, filters like |length).
    • Comparison with string.Template.
  1. HTML/CSS:

    • Block vs inline elements.
    • Box model calculations.
  1. Python:

    • sys.argv for command-line args.
    • Module imports and execution order.
  1. HTTP:

    • URL structure (protocol, host, port, path, query).
    • HTTP methods (GET, POST, etc.).