Home / Past papers / MAD1 Quiz 1 / this paper

What will be the output of the following HTML code?
```html
<!DOCTYPE html>
<html>
<head>
<title>Test List</title>
</head>
<body>
<dl>
<dt>Flask</dt>
<dd>A Python web framework.</dd>
<dt>SQLAlchemy</dt>
<dd>A database toolkit for Python.</dd>
</dl>
</body>
</html>
```
Flask
A Python web framework.
SQLAlchemy
A database toolkit for Python.
Flask A Python web framework. SQLAlchemy A database toolkit for Python.

Flask - A Python web framework. SQLAlchemy - A database toolkit for Python.

Flask A Python web framework. SQLAlchemy A database toolkit for Python.

Mayur and Manoj are playing a friendly cricket match. You are building a Flask web application to display their scores. Which of the following Flask route functions will correctly display the score when the user visits http://127.0.0.1/score ?(Assume that the score.html exists)

```python
@app.route('/score')
def score():
return render('score.html', mayur=50, manoj=45)
```
```python
@app.route('/score')
def score():
return render_template('score.html', mayur=50, manoj=45)
```
```python
def score():
return render_template('score.html', mayur=50, manoj=45)
@app.route('/score')
```
```python
@app.route('/score')
def score():
return 'score.html', mayur=50, manoj=45
```
Consider the following HTML code snippet.
filename: index.html
```html
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Document</title>
<style>
.container p.highlight { background-color: red; }
.content .special { background-color: blue; }
span.highlight { background-color: green; }
</style>
</head>
<body>
<div class="container">
<p class="highlight">Welcome to our site</p>
<div class="content">
<p>This is regular content</p>
<p class="highlight special">Important information</p>
<span class="highlight">Notice</span>
</div>
<p class="highlight">Footer text</p>
</div>
<p class="highlight">Welcome to our site</p>
</body>
</html>
```
Which elements from the above document will have a red background color?
All elements with the class "highlight".

Only the `<p>` elements that are direct children of `.container` and have the class "highlight"

All `<p>` elements with the class "highlight" that are descendants of `.container`

Only the first `<p>` element with class "highlight"

Consider the following Python code snippet.
Filename: code.py
```python
from string import Template as string_template
from jinja2 import Template as jinja_template
template1 = string_template('Hello $name, welcome to $city!')
template2 = jinja_template('{{product}} costs {{price}}')
result1 = template1.substitute(name='Alice')
result2 = template1.substitute(name='Alice', city='Boston',
state='Massachusetts')
result3 = template2.render({"product": "laptop"})
result4 = template2.render({"product": "laptop", "price": "45000",
"currency": "rupees"})
print(result1)
print(result2)
print(result3)
print(result4)
```
Which of the following statements will throw a key error?
```python template1.substitute(name='Alice') ```

```python template1.substitute(name='Alice', city='Boston', state='Massachusetts') ```

```
template2.render({"product": "laptop"})
```
```
template2.render({"product": "laptop", "price": "45000", "currency": "rupees"})
```
What will be the output of the following Jinja2 template when rendered in Flask?
```html
{% macro greet(name) %}
Hello, {{ name }}!
{% endmacro %}
<!DOCTYPE html>
<html>
<head>
<title>Jinja2 Macro Test</title>
</head>
<body>
{{ greet("Alice") }}
{{ greet("Bob") }}
</body>
</html>
```
Hello, Alice! Hello, Bob!

``` jinja2.exceptions.UndefinedError: 'greet' is undefined ```

Hello, Alice! Hello, Bob!

```
{{ greet("Alice") }}
{{ greet("Bob") }}
```
Consider the following Flask code snippet:
```python
from flask import Flask, url_for, request, redirect
app = Flask(__name__)
@app.route("/signin/user")
def login():
return url_for("login")
@app.route("/")
def home():
return redirect(url_for("login"))
app.run(debug=True)
```
Assume the above code is running on server http://127.0.0.1:5000/ . What will be the output on a web browser for the URL: http://127.0.0.1:5000/ ?
http://127.0.0.1:5000/signin/user

/signin/user

http://127.0.0.1:5000

Not Found

Consider the following code:
```html
<!DOCTYPE html>
<html>
<head>
<style>
p {
color: blue;
}
#highlight {
color: green;
}
.important {
color: red;
}
</style>
</head>
<body>
<p class="important" id="highlight">This is a paragraph.</p>
</body>
</html>
```
What will be the color of the paragraph text when rendered in a browser?
Consider the following Python file "output.py"
File: "output.py"
```python
from jinja2 import Template
output = """<!DOCTYPE html>
<body>
<ul>
<!--Missing Jinja2 implementation-->
</ul>
</body>
</html>
"""
l = [5, 4, 3, 2, 1]
t = Template(output)
output = t.render(sl=l)
print(output)
```
Which of the following code snippet when placed at `<!--Missing Jinja2 implementation-->` will render the below unordered list as shown below?
* 1
* 2
* 3
* 4
* 5
```html
{%for item in sl|sort(reverse=True)%}
<li>{{item}}</li>
{%endfor%}
```
```
{%for item in sl%}
<li>{{item}}</li>
{%endfor%}
```
```html
{%for item in s1|sort%}
<li>{{item}}</li>
{%endfor%}
```
```jinja
{%for item in sl.sort()%}
<li>{{item}}</li>
{%endfor%}
```
Consider the following Python code snippet:
main.py
```python
import sys
def process(v):
# Missing code 1
v = sys.argv
# Missing code 2
print(output)
```
We are executing above main.py in command line with command `python main.py 1 2 3 4 5`.
Which of the following codes when replaced at #Missing code 1 and #Missing code 2 will render the output below:
**1,2,3,4,5**
```python #Missing code 1 st = ",".join(v) return st #Missing code 2 output = process(v) ```

```python #Missing code 1 st = str(join(v),",") return st #Missing code 2 output = process(v) ```

```python #Missing code 1 st = str(join(v),",") return st #Missing code 2 output = process(v[1:]) ```

```python #Missing code 1 st = ",".join(v) return st #Missing code 2 output = process(v[1:]) ```


Which command line input will produce the output: flask is a server-side python framework.?

``` python webapp.py flask python type ```

``` python webapp.py flask type server-side ```

``` python webapp.py flask type ```

``` python webapp.py type flask python ```

``` python webapp.py flask server-side ```

What will be the output for command line input, ``` python webapp.py react type ? ```

react is a client-side javascript framework

react is a server-side python framework

Invalid second argument or Language not found!

Invalid command

What will be the output for command line input, python webapp.py django python ?

django is a client-side javascript framework

django is a server-side python framework

Invalid second argument or language not found!

Invalid command


The Flask route and template given in the main data, what will be rendered in the browser when the user visits `/protein?gender=FeMaLe&weight=154lb`

Recommended Daily Protein Intake Gender: male Weight: 60kg Recommended Intake: **48 grams**

Recommended Daily Protein Intake Gender: FeMaLe Weight: 154lb Recommended Intake: **52 grams**

Recommended Daily Protein Intake Gender: FeMaLe Weight: 154lb Recommended Intake: **70 grams**

Recommended Daily Protein Intake Gender: female Weight: 154lb Recommended Intake: **70 grams**

The Flask route and template given in the main data, what will be rendered in the browser when the user visits `/protein?gender=FEMALE&weight=60`

Recommended Daily Protein Intake Gender: Weight: Recommended Intake: grams

Recommended Daily Protein Intake Gender: FEMALE Weight: 60 Recommended Intake: **45 grams**

Recommended Daily Protein Intake Gender: FEMALE Weight: 60kg Recommended Intake: **45 grams**

Recommended Daily Protein Intake Gender: male Weight: 60kg Recommended Intake: **48 grams**
Auto-generated summary from the source site. Handy as a checklist; the lessons above explain each idea from scratch.
<html>, <head>, <body>, <title>, and <p>.<dl>), and their respective tags (<dt>, <dd>)..class), ID selectors (#id), and descendant selectors.@app.route decorator.render_template and render_template_string.url_for and redirect.sys.argv.join, split, and formatting.The relationship between bandwidth, data size, and time is given by: \[ B = \frac{S}{T} \]
Given \( B = 2 \text{ Gbps} = 2 \times 10^9 \text{ bits per second} \) and \( T = 1 \text{ second} \), we can calculate the data size \( S \) in bits: \[ S = B \times T = 2 \times 10^9 \text{ bits} \]
To convert bits to megabytes (MB), we use the conversion factors: \[ 1 \text{ byte} = 8 \text{ bits} \] \[ 1 \text{ KB} = 1000 \text{ bytes} \] \[ 1 \text{ MB} = 1000 \text{ KB} \]
So, \[ S \text{ (in MB)} = \frac{2 \times 10^9 \text{ bits}}{8 \times 10^6 \text{ bits/MB}} = 250 \text{ MB} \]
The time taken for the signal to travel through the cable is: \[ T_c = \frac{D}{V_c} \]
The time taken for the signal to travel through the air is: \[ T_a = \frac{D}{V_a} \]
The total delay is the sum of the time taken to travel through the cable and the additional delay: \[ T_{total} = T_c + T_d \]
Substituting the values: \[ T_c = \frac{3000 \times 10^3 \text{ m}}{2 \times 10^8 \text{ m/s}} = 15 \text{ ms} \] \[ T_{total} = 15 \text{ ms} + 47 \text{ ms} = 62 \text{ ms} \]
However, the correct answer provided is 72 ms, which suggests there might be additional considerations or a different interpretation of the problem.