Home / Past papers / MAD1 End Term / this paper

Consider the given URL below. ``` https://seek.onlinedegree.iitm.ac.in/courses/ns_23t3_cs2003?type=lesson&tab =courses ``` Select the appropriate option that correctly identifies different components of a given URL.

``` Protocol: https Domain: seek Sub-Domain: onlinedegree.iitm.ac.in Path: /courses Parameters: ns_23t3_cs2003?type=lesson&tab=courses ```

``` Protocol: https Domain: seek Sub-Domain: onlinedegree.iitm.ac.in/courses Path: /ns_23t3_cs2003 Parameters: ?type=lesson&tab=courses ```

``` Protocol: https Domain: onlinedegree.iitm.ac.in Sub-Domain: seek Path: /courses/ns_23t3_cs2003 Parameters: ?type=lesson&tab=courses ```

``` Protocol: https Domain: onlinedegree.iitm.ac.in/courses Sub-Domain: seek Path: /ns_23t3_cs2003 Parameters: ?type=lesson&tab=courses ```

Consider two python files, one.py and two.py with following code snippets.
File1: one.py
```python
import sys
import two
print(f'{sys.argv[0]} {sys.argv[1]}')
```
File2: two.py
```python
import sys
print(f'{sys.argv[3]} {sys.argv[2]}')
```
What is the output of the following command "python one.py two.py one.py two.py "?
one.py two.py one.py two.py

two.py one.py one.py two.py

two.py one.py two.py one.py

one.py two.py two.py one.py
How will the browser render the following HTML document? ```html
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
<style>
div{
border: 1px solid black;
color:pink;
display: inline-block;
}
span{
border: 1px solid pink;
}
</style>
</head>
<body>
<div>Div 1</div>
<div>Div 2</div>
<span>Span 1</span>
<span>Span 2</span>
</body>
</html>
```
The image displays four text elements, arranged horizontally. The first element is "Div 1 Div 2", enclosed in a black rectangular border. The text "Div 1" is in a light pink color, and "Div 2" is also in a light pink color. The second element is "Span 1", enclosed in a light pink rectangular border. The text "Span 1" is in black. The third element is "Span 2", enclosed in a light pink rectangular border. The text "Span 2" is in black.

The image displays four text elements, each enclosed in a rectangular border. From left to right: 1. "Div 1" with a black border and light pink text. 2. "Div 2" with a black border and light pink text. 3. "Span 1" with a light pink border and black text. 4. "Span 2" with a light pink border and black text.

The image displays two rectangular boxes side-by-side. The left box has a black border and contains the text "Div 1 Div 2" in a light pink color. The right box has a light pink border and contains the text "Span 1 Span 2" in a black color.

The image displays three rectangular boxes arranged horizontally. The first box, on the left, contains the text "Div 1" in light pink color with a black border. The second box, in the middle, contains the text "Div 2" also in light pink color with a black border. The third box, on the right, contains the text "Span 1 Span 2" in black color with a light pink border.

Consider the below flask application.
```python
from flask_sqlalchemy import SQLAlchemy
from flask import Flask
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///testdb.sqlite3'
db = SQLAlchemy(app)
app.app_context().push()
class Material(db.Model):
m_id = db.Column('m_id', db.Integer, primary_key = True)
name = db.Column('name', db.String(100), unique = True)
db.create_all()
material1 = Material(name = 'Steel')
db.session.add(material1)
material2 = Material(name = 'Iron')
material3 = Material(name = 'Aluminium')
db.session.add(material2)
db.session.commit()
db.session.add(material3)
all_material = Material.query.all()
print([(x.m_id, x.name) for x in all_material])
```
If you run the flask application using a terminal. What will be the output in the terminal?
``` [(1, 'Steel'), (2, 'Iron')] will be displayed in the terminal and two records will be added in the "testdb" database. ```

``` [(1, 'Steel'), (2, 'Iron'), (3, 'Aluminium')] will be displayed in the terminal and three records will be added in the "testdb" database. ```

``` [(1, 'Steel'), (2, 'Iron'), (3, 'Aluminium')] will be displayed in the terminal and two records will be added in the "testdb" database. ```

``` [(1, 'Steel', 2, 'Iron', 3, 'Aluminium')] will be displayed in the terminal and two records will be added in the "testdb" database. ```

Consider a function func, and a set of test cases given below.
Filename: test_file.py
```python
import pytest
def func(x,y):
out = x**2+y**2
return out
class Test_class0():
def test_case1(self):
assert func(1,2) == 5
def case_test2(self):
assert func(2,3) == 10
def test_case3(self):
assert func(4,2) == 21
class Test_class1():
def test_case1(self):
assert func(5,2) == 27
def case_test2(self):
assert func(4,3) == 25
```
What will be the output on the terminal for the command below?
pytest test_file.py -k Test_class
``` == 3 failed, 2 passed in 0.17s === ```

``` == 2 failed, 1 passed, 2 deselected in 0.04s === ```

``` === 1 failed, 1 passed, 1 deselected in 0.04s === ```

``` == 2 failed, 1 passed in 0.17s === ```

Consider the following box model of an element `<div>` with Id = "box". Diagram: Box Model - Outermost layer (light orange, dashed border): Margin. Values: Top 5, Right 10, Bottom 5, Left 10. - Second layer (yellow, solid border): Border. Values: Top 3, Right 3, Bottom 3, Left 3. - Third layer (green, dashed border): Padding. Values: Top 8, Right 4, Bottom 8, Left 4. - Innermost layer (blue, solid border): Content. Values: 200x20. Which of the following CSS styling would correctly create the box model of the element given above?

```css
#box {
width: 200px;
border: 3px solid red;
margin: 5px 10px;
padding: 8px 4px;
}
```
```css
#box {
width: 200px;
height: 20px;
border: 3px solid red;
margin: 5px 10px;
padding: 8px 4px;
}
```
```css
#box {
width: 200px;
height: 20px;
border: 3px solid red;
padding: 5px 10px;
margin: 8px 4px;
}
```
```css
#box {
width: 200px;
height: 20px;
border: 3px solid red;
margin: 10px 5px;
padding: 4px 8px;
}
```
Consider the following function to be tested and test functions given in the Python code snippet below.
test_file.py
```python
import pytest
def square(x):
sum = 0
for counter in range(x):
sum += x
return sum
@pytest.mark.marker1
def testcase_1():
assert square(12) == 144
@pytest.mark.marker2
def testcase_2():
assert square(9) == 9
@pytest.mark.marker3
def testcase_3():
assert square(3) == 27
```
On running this file on the terminal using pytest, the summary of the output is:
`========== 1 passed, 2 deselected, 3 warnings in 0.02s ==========`
What command will result into the outcome given above?
``` pytest test_file.py -k marker1 ```

``` pytest test_file.py -m marker3 ```

``` pytest test_file.py -m marker2 ```

``` pytest test_file.py -m marker1 ```

The hexadecimal equivalent of the IPv4 address 172.16.254.10 would be ___________

Consider the following models Creator and Song corresponding to tables
creator and song in SQLite database.
```python
class Creator(db.Model):
id = db.Column(db.Integer(), primary_key = True)
c_name = db.Column(db.String(), unique = True)
class Song(db.Model):
id = db.Column(db.Integer(), primary_key = True)
s_title = db.Column(db.String(), unique = True)
singer = db.Column(db.Integer(), db.ForeignKey("singer.id"))
```
Based on the model schemas, what relationship do the table creator and song
share?
``` git config email <new e-mail> ```

``` git config user.email <new e-mail> ```

``` git config --global email <new e-mail> ```

``` git config --global user.email <new e-mail> ```

Consider the following one-line python code snippet. Filename: application.py ```python print(__name__) ``` If we run the above file in a terminal using "python application.py", what will be the output?

A flask application shown below is running locally on http://127.0.0.1:5000.
```python
from flask import Flask, request, session, abort
app = Flask(__name__)
app.config['SECRET_KEY'] = "yekterces"
@app.route('/login')
def log_in():
user = request.args['user']
role = request.args['role'] if 'role' in request.args else \
'general'
session['user'], session['role'] = user, role
return "Logged in successfully!"
@app.route('/home')
def land():
if 'user' in session:
if session['role'] == 'admin':
return f"Welcome {session['user']}"
return abort(401)
return abort(404)
@app.route('/logout')
def log_out():
session.pop('user', None)
session.pop('role', None)
return "Logged out sucessfully!"
app.run(debug=True)
```
If the application is running locally on http://127.0.0.1:5000. What will be the correct sequence of response status codes if the client visits the URLs one by one in the sequence given below?
1. http://127.0.0.1:5000/home
2. http://127.0.0.1:5000/login/admin
3. http://127.0.0.1:5000/login?user=admin
4. http://127.0.0.1:5000/home
5. http://127.0.0.1:5000/logout
``` 401 401 200 404 200 ```

404 200 200 200 200

404 404 200 401 200

404 200 404 200 200

Consider the following Python code snippet.
Filename: arg.py
```python
from jinja2 import Template
import sys
input_list = sys.argv
num1, num2, input_list[3] = int(input_list[1]), int(input_list[2]), \
int(input_list[3])
if input_list[3]== 1:
num3= (num1*num2)
elif input_list[3]== 2:
num3= (num1+num2)
elif input_list[3]== 3:
num3= (num1-num2)
else:
num3= (num1%num2)
template = """
<!DOCTYPE html>
<html>
<div>
Number 1: {{num1}},
Number 2: {{num2}},
Output : {{num3}}
</div>
</html>
"""
t = Template(template)
print(t.render(num1=num1, num2=num2, num3=num3))
```
Map the commands in column A with the correct rendered output in the browser in column B.
| Column A | Column B |
|---|---|
| a) python arg.py 1 2 1 | 1) Number 1: 1, Number 2: 2, Output : 3 |
| b) python arg.py 1 2 2 | 2) Number 1: 3, Number 2: 2, Output : 1 |
| c) python arg.py 3 2 4 | 3) Number 1: 1, Number 2: 2, Output : 2 |
| d) python arg.py 3 2 3 | 4) Number 1: 3, Number 2: 2, Output : 1 |
Given a Python code snippet, code.py is run on the terminal with an appropriate temp.html document.
code.py
```python
from jinja2 import Template
Products = [
{'product_id':'101', 'prod_name':'Legion', 'producer':'Lenovo'},
{'product_id':'102', 'prod_name':'S21pro', 'producer':'Samsung'},
{'product_id':'103', 'prod_name':'TabA7', 'producer':'Samsung'},
{'product_id':'104', 'prod_name':'Ideapad', 'producer':'Lenovo'},
]
file = open ('temp.html','r')
temp = file.read()
file.close()
made_temp = Template(temp)
print(made_temp.render(Products=Products))
```
What should be the content of temp.html file if the browser renders the output of the above code, as shown below;
Lenovo
| Product ID | Name |
|:-----------|:--------|
| 101 | Legion |
| 104 | Ideapad |
Samsung
| Product ID | Name |
|:-----------|:-------|
| 102 | S21pro |
| 103 | TabA7 |
```html
{% for product in Products| groupby('producer') %}
<p> {{product.grouper}} </p>
<table border="1">
<tr>
<th>Product ID</th>
<th>Name</th>
</tr>
<tr>
<td>{{product.product_id}}</td>
<td>{{product.prod_name}}</td>
</tr>
</table>
{% endfor %}
```
```html
{% for product in Products| groupby('prod_name') %}
<p>{{product.grouper}} </p>
<table border="1">
<tr>
<th>Product ID</th>
<th>Name</th>
</tr>
{% for item in product.list %}
<tr>
<td>{{item.product_id}}</td>
<td>{{item.prod_name}}</td>
</tr>
{% endfor %}
</table>
{% endfor %}
```
```html
{% for product in Products| groupby('producer') %}
<p> {{product.grouper}} </p>
<table border="1">
<tr>
<th>Product ID</th>
<th>Name</th>
</tr>
{% for item in product.list %}
<tr>
<td>{{item.product_id}}</td>
<td>{{item.prod_name}}</td>
</tr>
{% endfor %}
</table>
{% endfor %}
```
```html
{% for product in Products| groupby('prod_name') %}
<p>{{product.grouper}}</p>
<table border="1">
<tr>
<th>Product ID</th>
<th>Name</th>
</tr>
<tr>
<td>{{item.product_id}}</td>
<td>{{item.prod_name}}</td>
</tr>
</table>
{% endfor %}
```
Consider the following function to be tested and test functions given in the Python code snippet below.
```python
# test_file.py
powers = []
for i in range(1,5):
def powers_of_x(x):
return x**i
powers.append(powers_of_x)
powers_of_4 = [x(4) for x in powers]
def testcase_1():
assert 12 in powers_of_4
def testcase_2():
assert 64 in powers_of_4
def testcase_3():
assert 256 in powers_of_4
```
For the command `pytest test_file.py`, what will be the output on the terminal?
``` ======== 1 failed, 2 passed in 0.02s ======== ```

======================================== 3 passed in 0.02s ========================================

========== 3 Failed in 0.02s ==========

``` ========================= 2 failed, 1 passed in 0.02s ========================= ```

Consider the following HTML document rendered using a browser.
```html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<style>
input:valid {
background: green;
}
input:invalid {
background: red;
}
</style>
</head>
<body>
<form>
<label for="uname">Enter a valid e-mail:</label>
<input type="text" name="uname" minlength="5"
maxlength="8" value="a">
</form>
</body>
</html>
```
If a user starts typing "madcourse" letter by letter, how will the background colour of the `<input>` tag change?
An HTML code is given below, which of the following CSS code will render the output as shown below.
HTML Code:
```html
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
<link href="style.css" rel="stylesheet">
<style>
body{background-color: gray; text-align: center;}
h2{color: purple !important ;}
</style>
</head>
<body style="background-color:lavender;" >
<h2 style="color: blue;">CSS Selectors</h2>
<p class="one">ID</p>
<p class="two">Class</p>
<p class="three" id="id">Element</p>
</body>
</html>
```
Rendered Output:
UI screenshot: A light blue rectangular box with rounded corners.
Inside the box, the text "CSS Selectors" is displayed in purple, centered.
Below it, the text "ID" is displayed in blue, centered.
Below it, the text "Class" is displayed in blue, centered.
Below it, the text "Element" is displayed in red, centered.
```css
body{background-color: skyblue !important;}
#id{color: green ;}
.one{color: yellow;}
.two{color: blue;}
.three{color: red;}
```
```css
body{background-color: skyblue !important;}
#id{color: red ;}
.one{color: yellow;}
.two{color: blue;}
.three{color: green;}
```
```css
body{background-color: skyblue !important;}
#id{color: red ;}
.one{color: blue;}
.two{color: yellow;}
.three{color: green;}
```
```css
body{background-color: skyblue !important;}
#id{color: red ;}
.one{color: yellow;}
.two{color: blue;}
```
Consider the following flask application.
app.py
```python
from flask import Flask
app = Flask(__name__)
@app.route('/home/<path:url_path>')
def course(url_path):
return 'The path is: ' + url_path
@app.route('/home/details/<student_id>/<course_id>')
def home(student_id, course_id):
return f'The student-id and course-id are {student_id} and {course_id} respectively.'
@app.route('/home/student/<student_id>/<course_id>')
def details(student_id, course_id):
details = {'course_id': course_id, 'student_id': student_id}
return details
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 ?
For URL, http://127.0.0.1:5000/home/M101/CS2003 browser will render; The student-id and course-id are M101 and CS2003 respectively.

For URL, http://127.0.0.1:5000/home/student/M101/CS2003 browser will render
```json
{
"course_id": "CS2003",
"student_id": "M101"
}
```
For URL http://127.0.0.1:5000/home/details/M101/CS2003 browser will render, The student-id and course-id are M101 and CS2003 respectively.

For URL, http://127.0.0.1:5000/home/M101/CS2003 browser will render; The path is: M101/CS2003

Consider the following python code snippet and choose the correct option.
```python
def modify(func):
def wrapper(x):
list = func(x, [])
return list
return wrapper
@modify
def expandList(x, list = []):
list.append(x)
return list
print(expandList(5))
print(expandList(6))
```
If the code is run on the terminal directly, the output on the terminal will be; ``` [5] [6] ```

If the code is run on the terminal directly, the output on the terminal will be; ``` [5] [5, 6] ```

If `@modify` is commented and the updated code is run on the terminal, the output will be; ``` [5] [6] ```

If `@modify` is commented and the updated code is run on the terminal, the output will be; ``` [5] [5, 6] ```

Consider the following flask application.
```python
from flask import Flask, abort
app = Flask(__name__)
modules = ['python', 'react', 'node']
@app.route('/home/modules/')
def all_modules():
return f"<h3>List of modules: {modules}</h3>"
@app.route('/get/<string:module_1>')
def get_module(module_1):
if module_1 in modules:
return f"<h3>One module found: {module_1}.</h3>"
else:
abort(400)
@app.errorhandler(400)
def module_error(error):
return "<h3>Cannot find module</h3>"
@app.errorhandler(404)
def module_error(error):
return "<h3>Incorrect Path</h3>"
app.run(debug=True)
```
If the application is running locally on http://127.0.0.1:5000, select the correct statement(s).
For the URL, http://127.0.0.1:5000/home/modules, the browser will render: List of modules: ['python', 'react', 'node']

For the URL, http://127.0.0.1:5000/home/modules, the browser will render: **Incorrect Path**

For the URL, http://127.0.0.1:5000/get/vuejs, the browser will render; **Cannot find module**

For the URL, http://127.0.0.1:5000/get/react/, the browser will render: **One module found: react.**

Consider the following flask view function definition given below.
```python
@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'GET':
return render_template("login.html")
if request.method == 'POST':
#=== POST Logic ===
return render_template("profile.html")
```
Which of the following view function definitions would work the same as that of one given above?
```python
@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'POST':
#=== POST logic ===
return render_template("profile.html")
return render_template("login.html")
```
```python
@app.get('/login')
def login_page():
return render_template("login.html")
@app.post('/login')
def login_verify():
#=== POST Logic ===
return render_template("profile.html")
```
```python
@app.route('/login', methods=['GET', 'POST'])
def login():
return render_template("login.html")
if request.method == 'POST':
#=== POST logic ===
return render_template("profile.html")
```
None of these



If the curl request shown below.
```
curl http://127.0.0.1:5000/api/v1 -X GET -d "{\"movie\": \"X-men\", \"genre\": \"Action\"}" -H "Content-Type: application/json"
```
retrieves the movie only with status 200 OK,
what will come in place of GET-FUNCTION
in the code?
```python
def get(self):
return {'Movie': movie}
```
```python
def get(self, movie):
return {'Movie': movie}
```
```python
def get(self):
args = parser.parse_args()
return {'Movie': args['movie']}
```
```python
def get(self):
args = parser.parse_args()
return args
```
If the curl request shown below ``` curl http://127.0.0.1:5000/api/v1/fiction -X POST ``` retrieves the genre only with status 200 OK, what will come in place of POST-FUNCTION in the code?

```python
def get(self):
return {'Genre': genre}
```
```python
def get(self, movie):
return {'Genre': genre}
```
```python
def get(self):
args = parser.parse_args()
return {'Genre': args['genre']}
```
```python
def get(self):
args = parser.parse_args()
return args
```
What will be the response from the server for the request:
```
curl http://127.0.0.1:5000/api/v1 -X PUT -d "{\"movie\" : \"X-men\", \"genre\": \"Action\"}" -H "Content-Type: application/json"
```
```json
{
"Movie": "X-men",
"Genre": "Action"
}
```
```json
{
"Movie": "X-men"
}
```
```json
{
"Genre": "Action"
}
```
None of these
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 equations essential for the "Modern Application Development I" exam, along with a Mermaid knowledge graph to visualize relationships.
Components:
https, http, ftponlinedegree.iitm.ac.inseek.onlinedegree.iitm.ac.in (if applicable)/courses/ns_23t3_cs2003?type=lesson&tab=coursesKey Takeaway:
seek is not a subdomain in the given example; onlinedegree.iitm.ac.in is the domain).curlcurl: Command-line tool for making HTTP requests (GET, POST, PUT, DELETE).Example:
curl http://127.0.0.1:5000/api/v1 -X GET -d '{"movie": "X-men"}' -H "Content-Type: application/json"Box Model:
CSS Syntax:
#box {
width: 200px;
height: 20px;
padding: 8px 4px;
border: 3px solid;
margin: 5px 10px;
}Form Validation:
:valid/invalid pseudo-classes for input fields.Example:
<input type="text" minlength="5" maxlength="8">Specificity Hierarchy (Highest to Lowest):
!importantstyle="...")#id).class), Attributes ([type="text"]), Pseudo-classes (:hover)div, p), Pseudo-elements (::before)Key Takeaway:
Flask Routes:
@app.route('/home/<path:url_path>')
def course(url_path):
return f'The path is: {url_path}'Jinja2 Templating:
base.html) extended by child templates.Example:
<!-- base.html -->
<html>
<head>
{% block head %}{% endblock %}
</head>
<body>
{% block content %}{% endblock %}
</body>
</html><!-- child.html --> {% extends "base.html" %} {% block content %} <h1>Hello, World!</h1> {% endblock %} ```
Database Integration (SQLAlchemy):
Model Definition:
class Material(db.Model):
m_id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(100), unique=True)CRUD Operations:
material = Material(name="Steel")
db.session.add(material)
db.session.commit()Custom HTML Elements:
class extending HTMLElement.Example:
class MyElement extends HTMLElement {
connectedCallback() {
this.innerHTML = `<p>Hello, World!</p>`;
}
}
customElements.define('my-element', MyElement);Methods:
Basic Syntax:
def test_addition():
assert 1 + 1 == 2Markers & Selection:
Run specific tests:
pytest -m "marker1" # Runs tests with @pytest.mark.marker1
pytest -k "TestClass" # Runs tests with "TestClass" in nameFixtures:
@pytest.fixture
def sample_data():
return [1, 2, 3]Branch vs. Condition Coverage:
x > 0 && y < 10) are tested.Key Takeaway:
Configuration:
git config --global user.email "new-email@example.com"Basic Commands:
git add .
git commit -m "Message"
git push origin mainConversion:
172.16.254.10 → AC.10.FE.0ABreak each octet into hex:
172 → AC16 → 10254 → FE10 → 0AMaximum Requests to Server B:
1000 / 6 ≈ 166 (but constrained by dependencies).Resource Definition:
class TestAPI(Resource):
def get(self):
args = parser.parse_args()
return {"movie": args["movie"]}api.add_resource(TestAPI, "/api/v1") ```
Request Parsing:
parser = reqparse.RequestParser()
parser.add_argument("movie")
parser.add_argument("genre")Marshalling (Response Formatting):
r_fields = {"film": fields.String(attribute="movie")}
@marshal_with(r_fields)
def put(self):
return parser.parse_args()Custom Elements:
class MyComponent extends HTMLElement {
connectedCallback() {
this.innerHTML = `<p>Custom Element</p>`;
}
}
customElements.define("my-component", MyComponent);Shadow DOM:
Round-Trip Time (RTT): \[ RTT = \frac{2 \times \text{Distance (m)} \times 1000}{3 \times 10^8 \text{ m/s}} \times 1000 \text{ (ms)} \]
Maximum Requests per Second: \[ \text{Max Requests} = \frac{1000 \text{ ms}}{RTT \text{ (ms)}} \]