Home / Past papers / MAD1 End Term / this paper

Which of the following statements is correct for the "alt" attribute of an `<img>` tag in HTML?

The "alt" attribute stores the address of an alternative image which gets loaded if the image URL specified in "src" attribute fails to load.

The "alt" attribute stores an alternative text which gets displayed if the image URL specified in "src" attribute fails to load.

It is mandatory to specify the value of "alt" attribute while using an `<img>` tag.

All of these.

Which of the following would change the default templates folder to "views" in a Flask app?

```python app = Flask(__name__, template="views") ```

```python app = Flask(__name__, templates="views") ```

```python app = Flask(__name__, template_folder="views") ```

```python app = Flask(__name__, templates_folder="views") ```

Match the first column with the second. | 1 | HTTPS | A | must be sent with each request | |---|---|---|---| | 2 | Cookies | B | base64 encoding | | 3 | Digest Authentication | C | encrypted channel | | 4 | HTTP Basic Authentication | D | hash function |

What can be inferred from the ERD below? The diagram shows two tables, "Customers" and "Orders", connected by a relationship line. **Customers Table:** | Column | Attribute | |---|---| | PK | customer_id int NOT NULL | | | customer_name char(50) NOT NULL | **Orders Table:** | Column | Attribute | |---|---| | PK | order_id int NOT NULL | | FK1 | customer_id int NOT NULL | | | order_date date NOT NULL | **Relationship:** A curved line connects the "Customers" table to the "Orders" table. - On the "Customers" side, the line ends with a "one-to-many" symbol (two vertical lines and a crow's foot). - On the "Orders" side, the line ends with a "zero or one" symbol (a circle and a vertical line). The line also has "FK1" labeled near the "Orders" table, indicating `customer_id` in "Orders" is a foreign key.

Consider the following code snippet.
```python
@app.route('/user/<username>')
def profile(username):
# CODE BLOCK HERE
```
Assume the database has a "User" table which has a TEXT column "username". If we want the server to return a 404 status code when a user goes to the route '/user/<username>' with a username that does not exist in the database, which of the following lines would give us the desired output?
```python
user = User.query.filter_by(username=username).first()
if user is None:
abort(404)
return render_template('profile.html', user=user)
```
```python
user = User.query.filter_by(username=username).first()
if user is None:
return render_template("404.html")
return render_template('profile.html', user=user)
```
```python
user = User.query.filter_by(username=username).first_or_404()
return render_template('profile.html', user=user)
```
```python
user = User.query.filter_by(username=username).first()
if user is None:
return render_template("404.html"), 404
return render_template('profile.html', user=user)
```
Consider the following flask application running on the base URL and is accessed through a browser. Select the correct option(s). ```python
from flask import Flask, abort, request
app = Flask(__name__)
users = {
1 : {"Name": "Ritu", "role": "Admin", "access": True},
2 : {"Name": "Ramesh", "role": "User", "access": True},
3 : {"Name": "Tejas", "role": "Admin", "access": True},
4 : {"Name": "Manisha", "role": "User", "access": False}
}
@app.route('/login')
def auth():
cred = request.args
if users[int(cred["id"])].get("access"):
id = int(cred["id"])
user = users[id]
return "Welcome, " + user.get("Name") + ", you have " \
+user.get("role")+" access"
else:
abort(403)
@app.errorhandler(403)
def no_access(error):
return "Looks like you are not an authorized user!"
app.run(debug = True)
```
For the URL: http://127.0.0.1:5000/?id=2, The browser will render; Welcome, Ramesh, you have User access.

For the URL: http://127.0.0.1:5000/login?id=1, The browser will render, Welcome, Ritu, you have Admin access.

For the URL: http://127.0.0.1:5000/login?id=4, The browser will render, Welcome, Manisha, you have User access.

For the URL: http://127.0.0.1:5000/login?id=4, The browser will render; Looks like you are not an authorized user!

Consider the following users list.
```
users = [ {"id":1, "name": "user_1", "role": "manager"},
{"id":2, "name": "user_2", "role": "manager"},
{"id":3, "name": "user_3", "role": "manager"}]
```
An ordered HTML list is to be created for users where every list item should have a clickable "name" attribute redirecting to the endpoint "/show_users/<id>" where "id" is the "id" attribute of the same user dictionary. The correct way of doing it with jinja and HTML is _________.
```html
<ol>
{% for user in users %}
<li><a href="/show_users/{{user.id}}">{{user.name}}</a></li>
{% endfor %}
</ol>
```
```html
<ol>
{% for user in users %}
<li><a href="/show_users/{{user['id']}}">{{user['name']}}</a></li>
{% endfor %}
</ol>
```
```html
<ol>
<li><a href="/show_users/{{users[0].id}}">{{users[0].name}}</a></li>
<li><a href="/show_users/{{users[1].id}}">{{users[1].name}}</a></li>
<li><a href="/show_users/{{users[2].id}}">{{users[2].name}}</a></li>
</ol>
```
```html
<ol>
{% for user in users %}
<li><a href="/show_users/{{user.name[-1]}}">{{user.name}}</a></li>
{% endfor %}
</ol>
```
Consider the following code snippet. Which of the following is correct regarding the coverage of the test?```python
def foo(x,y):
if x < 0:
y += 1
if y > 0:
x -= 1
return x + y
```
Test:
```
foo(-1, 1)
foo(1, -1)
```
If $N_x$ is a number N represented in the base 'x' and the equation. $400_a = 100_b = 256_c$ Holds for a specific set of a, b and c. The correct values of a, b and c that satisfy the above equation are:
Consider the following HTML file and select the correct option. ```html
<!DOCTYPE html>
<html lang="en">
<body>
<table id="rows">
<tr>
<th>Name</th>
<th>City</th>
</tr>
</table>
<button onclick="perform()">action</button>
<script>
function perform(){
let row = document.createElement("tr")
let td1 = document.createElement("td")
td1.innerText = "name_1"
let td2 = document.createElement("td")
td2.innerText = "city_1"
row.appendChild(td1)
row.appendChild(td2)
let rows = document.getElementById("rows")
rows.appendChild(row)
}
</script>
</body>
</html>
```
Consider the following Table products in SQLite database created using model class Product and the python file main.py given below.
**products:**
| id | pro_name | section |
|---|---|---|
| 1 | Pencil | stationary |
| 2 | Butter | food |
| 3 | Pencil | art |
| 4 | Face wash | cosmetics |
| 5 | Olive | vegetables |
**main.py**
```python
from jinja2 import Template
templates = """
{% if result %}
<ol>
{% for product in products %}
<li>{{product.pro_name}}</li>
<li>{{product.section}}</li>
{% endfor %}
</ol>
{% endif %}
"""
products = Product.query.filter_by(pro_name = 'Pencil').all()
Templates = Template(templates)
result = Templates.render(products = products)
print(result)
```
What will be the output on the terminal?
Pencil stationary Pencil art

```html
<ol>
<li>Pencil stationary</li>
<li>Pencil art</li>
</ol>
```
Pencil stationary Pencil art

```html
<ol>
<li>Pencil</li>
<li>stationary</li>
<li>Pencil</li>
<li>art</li>
</ol>
```
Match the following types of testing with their functionality. | | | |---|---| | A. Black box testing | 1. Focuses primarily on input and output of the software application. | | B. Unit testing | 2. Tests individual pieces of source code. | | C. Grey box testing | 3. Analyzes the internal structures, the data structures, internal design, code structure, and the working of the software. | | D. White box testing | 4. Testing the functionality of the software. In the event of errors, they can access the software code. | Which of the following is correct matching?

What is the following HTML code is correctly represented by the DOM structure below?
Diagram: DOM structure
- "document" node.
- "document" node connects to "root element <html>" node.
- "root element <html>" node connects to "element <head>" node.
- "element <head>" node connects to "element <title>" node.
- "root element <html>" node connects to "element <body>" node.
- "element <body>" node connects to "element <div>" node.
- "element <div>" node connects to "element <h1>" node.
- "element <h1>" node connects to "Text "Click Here"" node.
- "element <body>" node connects to "element <div>" node.
- "element <div>" node connects to "element <p>" node.
- "element <p>" node connects to "Text "paragraph"" node.
- "element <div>" node connects to "element <a>" node.
- "element <a>" node connects to "attribute href="#" " node.
- "element <a>" node connects to "Text "Click Here"" node.
```html
<html>
<head>
<title>My website</title>
</head>
<body>
<div>
<h1> Header </h1>
<p><a href="#"> Click Here </a></p>
</div>
</body>
</html>
```
```html
<html>
<head>
<title>My website</title>
</head>
<body>
<div>
<h1> Header </h1>
</div>
<div>
<p> <a href="#"> Click Here </a> </p>
</div>
</body>
</html>
```
```html
<html>
<head>
<title>My website</title>
</head>
<body>
<div>
<h1> Header </h1>
</div>
<div>
<p>Paragraph</p>
<a href="#"> Click Here </a>
</div>
</body>
</html>
```
```html
<html>
<head>
<title>My website</title>
</head>
<body>
<h1> Header </h1>
<p><a href="#"> Click Here </a></p>
</body>
</html>
```
Consider the following table "emp" created in SQLite database corresponding to model class "Employee" using flask_sqlalchemy. | Id | Name | Designation | Gender | Salary | |---|---|---|---|---| | 1 | Raji | Headmaster | Female | 4500 | | 2 | Ram | Teacher | Male | 5000 | | 3 | Raveena | Teacher | Female | 3000 | | 4 | Reshma | Technical staff | Female | 2000 | | 5 | Ravi | Teacher | Male | 1000 | Which of the following code snippets correctly increases the salary of all the teachers by 1000 Rupees when typed in the Python console?

```python >>> emp = Employee.query.filter_by(Designation = 'Teacher').all() >>> for staff in emp: ... staff.Salary += 1000 ... >>> db.session.commit() ```

```python >>> emp = Employee.query.filter_by(Gender = 'Female').all() >>> staff.Salary += 1000 >>> db.session.commit() ```

```python >>> emp = Employee.query.filter_by(Gender = 'Female').all() >>> for staff in emp: ... staff.Salary += 1000 ... >>> db.session.commit() ```

```python
>>>emp = Employee.query.filter(Employee.Gender.like('T%')).all()
>>> for staff in emp:
... staff.Salary += 1000
...
>>> db.session.commit()
```
Consider the following Python code snippet.
```python
from math import factorial
def prettify(func):
def wrapper(num):
try:
return func(num)
except:
return "Please check your number!"
return wrapper
@prettify
def fact(num):
return factorial(num)
out = fact(-4)
print(out)
```
What will the output if the above Python code is run on the terminal?
-24

24

Please check your number!

None

Read the following statements regarding web accessibility principles and choose the correct option. **Statement 1:** The command `git merge <branch_name>` merges all the change done to currently active branch. **Statement 2:** The command `git merge <branch_name>` merges all the change done to master branch.

Consider a function remainder, and a set of test cases given below.
Filename: test_file.py
```python
def remainder(numerator, denominator):
rem = numerator % denominator
return rem
def test_func0():
assert remainder(5,7) == 5
def test_function1():
assert remainder(20,4) == 3
def test_func2():
assert remainder(31,8) == 6
def test_function3():
assert remainder(2,3) == 2
```
What will be the output on the terminal for the command `pytest test_file.py -k func`?
``` ======== 1 failed, 1 passed, 2 deselected in 0.41s ======== ```

```text ============================= 2 passed, 2 deselected in 0.41s ============================= ```

```text ============================= 2 failed, 2 passed in 0.41s ============================= ```

``` ========== 2 failed, 2 deselected in 0.41s ========== ```

Consider the following models Library and Book corresponding to tables library and book in SQLite database.
```python
class Library(db.Model):
id = db.Column(db.Integer(), primary_key = True)
name = db.Column(db.String(), unique = True)
class Book(db.Model):
id = db.Column(db.Integer(), primary_key = True)
name = db.Column(db.String(), unique = True)
library = db.Column(db.Integer(), unique = True, db.ForeignKey("library.id"))
```
Based on the model schemas, what relationship do the classes Library and Book share?
Consider the `<span>` element and the styling given to it in `<style>` tag using element selector in the HTML file below.
```html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Span</title>
<style>
span{
color: red;
border:1px solid blue;
}
</style>
</head>
<body>
<span id="this_span">Hello Students! MAD-I welcomes you!</span>
</body>
</html>
```
What will be the final style applied to `<span>` tag if an additional style is added via the ID selector given below?
```css
#this_span{
width: 1200px;
border: 2px solid pink;
}
```
```css color: red; width: 1200px; border: 2px solid pink; ```

```css color: red; width: 1200px; border: 1px solid blue; ```

```css color: red; border: 2px solid pink; ```

```css width: 1200px; border: 2px solid pink; ```

Software packages A and B of complexity O(n²logn) and O(n³), respectively, spend exactly T_A(n) = C_A n²log₁₀(n) and T_B(n) = C_B n³ milliseconds to process n data items. During a test, the average time of processing n = 10⁵ data items with the package A and B is 600 milliseconds and 300 milliseconds, respectively. Which of two software packages defined above will work better to process 10⁶ data items?
Consider the following Python code snippet. How will the browser render the output of the above given Python code?```python
from jinja2 import Template
data = [
{"vehicle_id":"ev101", "vehicle_name":"electroN", "fuel_type":"electric"},
{"vehicle_id":"pt201", "vehicle_name":"discover", "fuel_type":"petrol"},
{"vehicle_id":"dz301", "vehicle_name":"apex", "fuel_type":"diesel"},
]
this_text = """
<h1> Ordered Vehicles </h1>
{% set keys = data[0].keys() %}
{% set keys = keys|list %}
{% for i in range(data|length) %}
{{keys[i]}} : {{data[i][keys[i]]}}
{% endfor %}
<h3> Total: {{ data|length }} </h3>
"""
this_temp = Template(this_text)
rendered = this_temp.render(data = data[::-1])
print(rendered)
```
Ordered Vehicles vehicle_id : pt201 vehicle_name : discover fuel_type : petrol Total: 3

Ordered Vehicles vehicle_id : ev101 vehicle_name : electroN fuel_type : electric Total: 3

Ordered Vehicles vehicle_id : ev101 vehicle_name : discover fuel_type : diesel Total: 3

Ordered Vehicles vehicle_id : dz301 vehicle_name : discover fuel_type : electric Total: 3



Which of the following URL will return a 200 OK for GET HTTP method?

``` http://127.0.0.1:5000/maharastra/mumbai ```

``` http://127.0.0.1:5000/india?state=tamilnadu&capital=chennai ```

``` http://127.0.0.1:5000/india/madhyapradesh/bhopal ```

``` http://127.0.0.1:5000?state=rajasthan&capital=jaipur ```

Which of the following URL will return a 200 OK for POST HTTP method?

``` http://127.0.0.1:5000/india?state=odisha&capital=bhubaneshwar ```

``` http://127.0.0.1:5000?state=telangana&capital=hyderabad ```

``` http://127.0.0.1:5000/karnataka/bangalore ```

``` http://127.0.0.1:5000/india/westbengal/kolkata ```
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 core topics, concepts, principles, and equations for the "Diploma Level: Modern Application Development 1" exam, along with Mermaid knowledge graphs to visualize relationships.
HTML Attributes & Accessibility
alt attribute in <img>: Provides alternative text for accessibility (e.g., screen readers) or when the image fails to load.<video>, <audio>, <canvas>), parsing rules, and separation from SGML (unlike HTML4).Flask Framework
Template Folder Customization:
app = Flask(__name__, template_folder="views") # Changes default templates folder to "views"Routing & Error Handling:
@app.route('/user/<username>')
def profile(username):
user = User.query.filter_by(username=username).first_or_404() # Returns 404 if user not found
return render_template('profile.html', user=user)HTTP Methods:
GET: Retrieve data (e.g., query parameters via request.args).POST: Submit data (e.g., form data via request.form).Jinja2 Templating:
Loop through lists:
<ol>
{% for user in users %}
<li><a href="/show_users/{{ user.id }}">{{ user.name }}</a></li>
{% endfor %}
</ol>Conditional rendering:
{% if user.access %}
<p>Welcome, {{ user.name }}!</p>
{% else %}
<p>Access denied.</p>
{% endif %}Database Integration (SQLAlchemy)
Relationships:
Book.library_id references Library.id).unique=True in the foreign key column.Querying:
teachers = Employee.query.filter_by(Designation='Teacher').all()
for teacher in teachers:
teacher.Salary += 1000
db.session.commit()RESTful APIs (Flask-RESTful)
Define resources with HTTP methods:
class TestApi(Resource):
def get(self):
return {"data": request.args} # Handles GET requests
def post(self, state, city):
return {"state": state, "capital": city} # Handles POST requests
api.add_resource(TestApi, '/india', '/india/<state>/<city>')Logging & DDoS Protection
Server logs can detect:
Access Control Models
Web Accessibility (WCAG Principles)
Testing
Coverage Metrics:
if/else) executed.Example:
def foo(x, y):
if x < 0: y += 1 # Branch 1
if y > 0: x -= 1 # Branch 2
return x + y
Tests foo(-1, 1) and foo(1, -1) achieve 100% branch coverage.
Version Control (Git)
git merge <branch>: Merges changes into the currently active branch (not necessarily master).CI/CD (Continuous Integration/Deployment)
Entity-Relationship Diagrams (ERD)
Example:
Customers (PK: customer_id) → Orders (FK: customer_id)
Inferences:
Time Complexity
Example:
Latency Calculation
Round-trip time (RTT) depends on:
Speed of light in medium (\(v\)):
Example: Client-server distance = 12,000 km, router at midpoint.
Base Conversion
| Topic | Equation |
|---|---|
| Time Complexity | \(T_A(n) = c_A n^2 \log n\), \(T_B(n) = c_B n^3\) |
| Latency | \(\text{RTT} = 2 \times \left( \frac{d_1}{v_1} + \frac{d_2}{v_2} \right)\) |
| Base Conversion | \(400_a = 4a^2 = 100_b = b^2 = 256_c = 2c^2 + 5c + 6\) |
alt, semantic tags, and DOM structure.git merge affects the current branch, not always master.