MAD Study Hub

Home / Past papers / MAD1 Quiz 1 / this paper

2024 July07: IIT M AN EXAM QIM4 - 07 Jul 2024

MAD1 Quiz 115 questions45.5 marks13 MCQ · 2 MSQafternoon / QIM4
Elapsed 00:00
Q1MCQ2 marks
Which of the following is not a correct perceivable accessibility principle?
  1. Provide text alternatives for non-text content.
  2. Provide captions and other alternatives for multimedia.
  3. Make it easier for users to see and hear content.
  4. Give users enough time to read and use content.
Q2MCQ2 marks
Which of the below HTTP status codes represents the client error?
  1. 500-599
  2. 400-499
  3. 300-399
  4. 200-299
  5. 100-199
Q3MCQ2 marks
What will be the output of the following Python code? question figure What will be the output of the following Python code?
Text of the picture (copyable)
```python
from jinja2 import Template
data = {"id": 101, "prod_name": "Groceries", "sales_amt": 5600,
"sales_bonus": 5}

def foo(amount, p):
    return amount * p / 100

a = foo(data["sales_amt"], data["sales_bonus"])
t = Template(
"Congratulations, you got bonus {{ bonus }} by selling product
{{data['prod_name']}}"
)
output = t.render(data=data, bonus=a)
print(output)
```
  1. question figure
    text
    Congratulations, you got bonus 70.0 by selling product Groceries
  2. question figure
    text
    Congratulations, you got bonus 140.0 by selling product Groceries
  3. question figure
    text
    ```
    Congratulations, you got bonus 280.0 by selling product Groceries
    ```
  4. question figure
    text
    Congratulations, you got bonus 560.0 by selling product Groceries
Q4MCQ2 marks
Consider the below table. question figure Consider the below table. Use the above table. Which of the below match is correct?
Text of the picture (copyable)
| Column 1 | Column 2 |
|---|---|
| i) Primary Key | a) Method of the request |
| ii) Foreign key | b) Provides additional functionality at top of original function |
| iii) Nullable | c) Refers to another parent table column |
| iv) POST | d) Unique identification of row |
| v) @<decorator> | e) Undefined value |
  1. i - d, ii - b, iii - a, iv - e, v - c
  2. i - d, ii - c, iii - e, iv - a, v - b
  3. i - c, ii - d, iv - e, iii - a, v - b
  4. i - c, ii - d, iv - e, iii - b, v - a
Q5MCQ3 marks
A certain movie with advertisements is being streamed by the client on the internet with a bandwidth of 5 Mbps. If the total data consumed only in the advertisements is 340 MB and the advertisements comprises 17% of the total duration of the streamed movie, what can be the size of the entire movie (in Megabytes) including the advertisements?
  1. 20
  2. 640
  3. 2000
  4. 1660
Q6MCQ3 marks
question figure
Text of the picture (copyable)
Consider a document of 1000 characters written using only the characters of the character set L1 = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'}. If the character set L1 is to be upgraded by adding all the characters of character set L2 = {'0', '1', '2', '3', '4', '5', '6'} in it, By how many bits will the size of the original document increase?
  1. 0 bits
  2. 1000 bits
  3. 4000 bits
  4. 5000 bits
Q7MCQ3 marks
The following Python code snippet generates the output on the terminal. question figure The following Python code snippet generates the output on the terminal. Which of the following is the correct output?
Text of the picture (copyable)
```python
from string import Template

s = Template('$name studies at $university')
b = {'name': 'Bob'}

out1 = Template('$name studies $subject').safe_substitute(b)
print(out1)

out2 = s.substitute(name='Alice', university='Oxford')
print(out2)

out3 = Template('$name studies $subject').substitute(b)
print(out3)
```
  1. question figure
    text
    ```
    Bob studies at $subject
    Alice studies at Oxford
    KeyError: 'subject'
    ```
  2. question figure
    text
    ```
    Bob studies $subject
    Alice studies at Oxford
    KeyError: 'subject'
    ```
  3. question figure
    text
    ```
    Bob studies $subject
    Alice studies at Oxford
    Bob studies $subject
    ```
  4. question figure
    text
    ```
    Bob studies
    Alice studies at Oxford
    KeyError: 'subject'
    ```
Q8MCQ3 marks
Consider the following HTML document. question figure Consider the following HTML document.
Text of the picture (copyable)
```html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Span</title>
    <style>
        span{
            color: blue;
            Background-color: lime;
        }
    </style>
</head>
<body>
    <span id="my_span">MAD-I is a Diploma level course.</span>
    <span>SE is a Degree level course.</span>
</body>
</html>
```
What will be the rendered output if an additional style is added via the ID selector given below?

```css
#my_span{
    width: 1200px;
    Background-color: lightpink;
}
```
  1. question figure
    text
    MAD-I is a Diploma level course. SE is a Degree level course.
  2. question figure
    text
    MAD-I is a Diploma level course. SE is a Degree level course.
  3. question figure
    text
    MAD-I is a Diploma level course. SE is a Degree level course.
  4. question figure
    text
    MAD-I is a Diploma level course.
    SE is a Degree level course
Q9MCQ3 marks
Consider the following Python code snippet. question figure Consider the following Python code snippet.
Text of the picture (copyable)
Filename: app.py
```python
from flask import Flask, request
import sys
app = Flask(__name__)

@app.route('/home', methods = sys.argv)
def my_func():
    if request.method == 'GET':
        return f"Hello from {sys.argv[1]} method"

    elif request.method == 'POST':
        return f"Hello from {sys.argv[2]} method"

    else:
        return "Please enter a valid HTTP method"

app.run(debug = True)
```

If the above flask app is run using the command `python app.py POST GET` in one terminal, what will be the output on another terminal for command;
`curl -X POST http://127.0.0.1:5000/home ?`
  1. question figure
    text
    Hello from POST method
  2. question figure
    text
    Hello from GET method
  3. question figure
    text
    Please enter a valid HTTP method
  4. question figure
    text
    Method not Allowed
Q10MCQ3 marks
Consider the following Python code snippet. question figure Consider the following Python code snippet.
Text of the picture (copyable)
Filename: module.py

```python
from pyhtml import *
import sys
var = sys.argv[1:]

def list_func(stack):
    for tech in stack:
        yield span(tech)

doc = html(
    head(title('My Document')),
    body(
        h3('Frontend technologies'),
        list_func(var[::-1])
    )
)

print(doc.render())
```

How will the browser render the output of the above code if it is run on the terminal using the command `python module.py HTML CSS JS VUE`?
  1. question figure
    text
    Frontend Technologies
    HTML CSS JS VUE
  2. question figure
    text
    Frontend Technologies
    VUE JS CSS HTML
  3. question figure
    text
    Frontend Technologies
    HTML
    CSS
    JS
    VUE
  4. question figure
    text
    Frontend Technologies
    VUE
    JS
    CSS
    HTML
Q11MCQ4.5 marks
Consider the following HTML document. question figure Consider the following HTML document. How will the browser render above HTML file?
Text of the picture (copyable)
```html
<!DOCTYPE html>
<html>
<head>
    <style>
        span {
            background-color: lightgray;
            color: red;
            font-weight: bold;
        }
        div {
            border: 3px solid purple;
            text-align: center;
            width:20%;
        }
        #id1 {
            color:blue ;
        }
        #id2 {
            display: block;
        }
        .class1 {
            background-color: lightgreen;
            color: blue;
            display: inline-block;
        }
        .class2 {
            background-color: skyblue;
            color: red;
        }
    </style>
</head>
<body>
    <div>
        <span class="class1" id="id1">Content 1</span>
        <span class="class2 class1" >Content 2</span>
        <span id="id2">Content 3</span>
    </div>
</body>
</html>
```
  1. question figure
    text
    A horizontal rectangular box with a purple border. Inside, from left to right, there are three colored sections:
    1. A green section with the text "Content 1" in blue.
    2. A light blue section with the text "Content 2" in red.
    3. A light gray section with the text "Content 3" in red.
  2. question figure
    text
    The image displays a rectangular area with a purple border. Inside, the top half is white, and the bottom half is light gray.
    
    Within the white top half, there are two colored rectangular blocks:
    - A green block on the left, containing the text "Content 1" in blue.
    - A light blue block on the right, containing the text "Content 2" in blue.
    
    Within the light gray bottom half, there is the text "Content 3" in red, centered horizontally.
  3. question figure
    text
    The image displays a rectangular box with a purple border. Inside, the top section is white, and the bottom section is light gray.
    
    Within the white top section, there are two smaller rectangular boxes:
    - The left box is light green and contains the text "Content 1" in blue.
    - The right box is light blue and contains the text "Content 2" in red.
    
    Within the light gray bottom section, there is the text "Content 3" in red, centered horizontally.
  4. question figure
    text
    This is a diagram of a rectangular box divided horizontally into three sections.
    The top section is light green and contains the text "Content 1" in blue.
    The middle section is light blue and contains the text "Content 2" in red.
    The bottom section is light gray and contains the text "Content 3" in red.
    The entire box has a purple border.
Q12MCQ4.5 marks
Consider a client A that makes a request to server B that fetches the information from Datacenter C which in turn fetches other required information from the Datacenter D. The distance between the client A, server B and datacenters C and D within the network and the speed of information in the medium connecting these nodes is mentioned in the table below. question figure Consider a client A that makes a request to server B that fetches the information from Datacenter C which in turn fetches other required information from the Datacenter D. The distance between the client A, server B and datacenters C and D within the network and the speed of information in the medium connecting these nodes is mentioned in the table below. Calculate the round trip latency (in milliseconds) of the network?
Text of the picture (copyable)
| Nodes | A to B | B to C | C to D |
|---|---|---|---|
| Distance (km) | 12000 | 8500 | 7500 |
| Speed of Information(m/s) | 3 x 10⁸ | 2 x 10⁸ | 1.5 x 10⁸ |
  1. 187
  2. 132.5
  3. 265
  4. 150
Q13MCQ4.5 marks
Consider the following flask app and the bodies of two index.html files shown in the figure below. question figure Consider the following flask app and the bodies of two index.html files shown in the figure below.
Text of the picture (copyable)
app.py

```python
from flask import Flask, render_template
import sys

app = ========== app object initialization here ==========

@app.route('/home')
def home():
    return render_template('index.html')

app.run()
```

app_templates/index.html

```html
<h3>Home page</h3>
<p>MAD I focuses on backend development</p>
<h5>IITM ONLINE DEGREE</h5>
```

root_templates/index.html

```html
<h3>Home page</h3>
<p>Vue JS is a frontend technology</p>
<h5>IITM BS DEGREE</h5>
```

If the app is run locally using the command
`python app.py root_templates app_templates`
and the output on browser for URL `http://127.0.0.1/home` is:

Home page

Vue JS is a frontend technology

IITM BS DEGREE

How should the app be initialized to get the desired output on the browser?
  1. question figure
    text
    ```python
    app = Flask(__name__)
    ```
  2. question figure
    text
    ```python
    app = Flask(__name__, templates = sys.argv[1])
    ```
  3. question figure
    text
    ```python
    app = Flask(__name__, templates = sys.argv[2])
    ```
  4. question figure
    text
    ```python
    app = Flask(__name__, template_folder = sys.argv[1])
    ```
  5. question figure
    text
    ```python
    app = Flask(__name__, template_folder = sys.argv[2])
    ```
Q14MSQ3 marksselect all that apply
What can be inferred from the Entity-Relationship Diagram below: question figure What can be inferred from the Entity-Relationship Diagram below:
Text of the picture (copyable)
This is an Entity-Relationship (ER) diagram showing two entities and a linking table.

Entity 1: STUDENT
| Type   | Field      |
| :----- | :--------- |
| int    | ID         |
| string | FirstName  |
| string | LastName   |
| string | Department |

Linking Table: COURSE_STUDENT
| Type | Field     |
| :--- | :-------- |
| int  | CourseID  |
| int  | StudentID |

There is a relationship line connecting STUDENT to COURSE_STUDENT.
The relationship from STUDENT to COURSE_STUDENT has a "one-to-many" cardinality, indicated by a vertical line and a circle on the STUDENT side, and a crow's foot and a circle on the COURSE_STUDENT side.
  1. A student can exist without enrolling to any course
  2. A student can have more than one courses
  3. A student needs to have at least one course
  4. A course must belong to one and only one student
Q15MSQ3 marksselect all that apply
Consider the following Flask code. question figure Consider the following Flask code. Select the command(s) to execute the above code without any error.
Text of the picture (copyable)
File name: sum_args.py

```python
import sys
from flask import Flask
app = Flask(__name__)

def do_something():
    if len(sys.argv) >= 2:
        l = []
        for i in range(1, len(sys.argv)):
            l.append(int(sys.argv[i]))
        return l
    else:
        return None

@app.route("/")
def do_sum():
    result = do_something()
    if result:
        s = 0
        for e in result:
            s += int(e)
        return f"<h2>Sum is : {s}</h2>"
    else:
        return f"<h2>Sum is : {result}</h2>"

app.run(debug=True)
```
  1. question figure
    text
    ```
    python sum_args.py 2 8 9
    ```
  2. question figure
    text
    ```
    python sum_args.py 2
    ```
  3. question figure
    text
    ```
    python sum_args.py
    ```
  4. question figure
    text
    ```
    python sum_args.py IITM
    ```

Answer key

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

Concepts this paper tests

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

Summary of Core Topics, Concepts, Principles, and Equations

1. Web Accessibility Principles

2. HTTP Status Codes

3. Python and Jinja2 Templating

4. Database Concepts

5. Networking and Bandwidth

6. Character Encoding and Data Size

7. Flask and Web Development

8. HTML and CSS

9. Entity-Relationship Diagrams (ERD)

Equations

Bandwidth and Data Consumption

\[ \text{Total Data} = \text{Bandwidth} \times \text{Time} \] \[ \text{Data Consumption} = \text{Percentage of Duration} \times \text{Total Data} \]

Round Trip Latency

\[ \text{Latency} = \frac{\text{Distance}}{\text{Speed of Information}} \] \[ \text{Round Trip Latency} = 2 \times \text{Latency} \]

Character Encoding

\[ \text{Bits per Character} = \log_2(\text{Number of Characters}) \] \[ \text{Total Bits} = \text{Number of Characters} \times \text{Bits per Character} \]

Core Topics and Relationships

Detailed Relationships

This summary and knowledge graph should help you understand the core topics and their relationships, making it easier to prepare for the exam.