Home / Past papers / MAD1 Quiz 1 / this paper

Create a simple HTML document with the following requirements: 1. Include a heading with the text "My Web Page" using an `<h1>` tag. 2. Add a paragraph with the text "Welcome to the world of HTML!" using a `<p>` tag. 3. Create an unordered list with three list items. The list items should contain the text "Item 1", "Item 2" and "Item 3" respectively, using `<li>` tags. 4. Include a link to "https://www.example.com" with the anchor text "Visit Example.com" using an `<a>` tag. Which of the following HTML code is correct to fulfill these requirements?

```html
<body>
<h1>My Web Page</h1>
<p>Welcome to the world of HTML!</p>
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
<a href="https://www.example.com">Visit Example.com</a>
</body>
```
```html
<body>
<h1>My Web Page</h1>
<p>Welcome to the world of HTML!</p>
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
<a href="Visit Example.com">https://www.example.com</a>
</body>
```
```html
<body>
<h1>My Web Page</h1>
<p>Welcome to the world of HTML!</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<a href="Visit Example.com">https://www.example.com</a>
</body>
```
```html
<body>
<h1>My Web Page</h1>
<p>Welcome to the world of HTML!</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<a href="https://www.example.com">Visit Example.com</a>
</body>
```
Consider the following example. ```html <img src="example.jpg" alt="Gajendra Circle, IITM Campus"> ``` Which of the following accessibility principle is followed in this example?

The directory listing of a folder and the content of each of its files are given below.
**Directory Listing:**
```
my_dir-|
|-- base.html
|-- home.html
|-- index.html
```
**Filename: base.html**
```html
<body>
<h1>Hello from Base</h1>
</body>
```
**Filename: home.html**
```html
<body>
<h1>Hello from Home</h1>
</body>
```
**Filename: index.html**
```html
<body>
<h1>Hello from Index</h1>
</body>
```
If a simple Python HTTP server is created for this directory, what will be rendered on the browser for base URL?
Hello from Base

Hello from Home

Hello from Index

Directory listing for /

An HTML code and CSS code is given below. Which of the following correctly represents its rendered output?
CSS Code:
```css
.one{color: brown;}
.two{color: yellow !important;}
```
HTML Code:
```html
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
<link href="style.css" rel="stylesheet">
<style>
h4{color: blue !important ;width: 90px;}
p,span{font-weight: bold;}
</style>
</head>
<body style="background-color:lightgray;">
<h4 style="color: yellow;"> Statement 1 </h4>
<p class="one"> Statement 2 </p>
<span class="two" style="color: blue;"> Statement 3 </span>
<span> Statement 4 </span>
</body>
</html>
```
Statement 1 Statement 2 Statement 3 Statement 4

Statement 1 Statement 2 Statement 3 Statement 4

Statement 1 Statement 2 Statement 3 Statement 4

Statement 1 Statement 2 Statement 3 Statement 4

The following Python code snippet generates the output on the terminal.
```python
from string import Template
s = Template('$who lives in $where')
out1 = s.substitute(who='Karl', where='Chennai')
print(out1)
b = dict(who='Tim')
out2 = Template('$who likes $what').safe_substitute(b)
print(out2)
out3 = Template('$who likes $what').substitute(b)
print(out3)
```
Which of the following is the correct output?
``` Karl lives in Chennai Tim likes $what Tim likes $what ```

``` Karl lives in Chennai Tim likes Tim likes $what ```

```text Karl lives in Chennai KeyError: 'what' Tim likes $what ```

``` Karl lives in Chennai Tim likes $what KeyError: 'what' ```

Consider the following python code snippet. What will be the rendered output?
```python
from jinja2 import Template
data=[
{"Course":"MAD-I", "ID":101, "Name":"John"},
{"Course":"MAD-II", "ID":161, "Name":"Karl"},
{"Course":"MAD-I", "ID":120, "Name":"Kim"}
]
t="""
<ul>
{% for group in data|groupby('Course') %}
<li>
{{ group.grouper }}
<ul>
{% for person in group.list %}
{% if person.Name|length == 4 %}
<li> {{ person.Name }} has ID {{ person.ID }} </li>
{% endif %}
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
"""
temp=Template(t)
print(temp.render(data = data))
```
- MAD-I - John has ID 101 - Kim has ID 120 - MAD-II - Karl has ID 161

- MAD-I - John has ID 101 - Karl has ID 161 - MAD-II - Kim has ID 120

* MAD-I
* John has ID 101
* MAD-II
* Karl has ID 161
- MAD-I - Karl has ID 101 - MAD-II - John has ID 161

Consider the following HTML document.
```html
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
<style>
h2{
background-color: lightgray;
color: red;
width:25%;
text-align: center;
/* ===code1=== */
}
#id {
background-color: skyblue;
border: 3px solid purple;
color: red;
}
.class {
color:blue ;
}
</style>
</head>
<body>
<h2 class="class" id="id">Statement 1</h2>
<h2 class="class">Statement 2</h2>
</body>
</html>
```
Which of the following is/are correct rendered output for given ===code1===?
If ===code1=== is replaced by: ```css display:inline-block; border: 2px solid purple; ``` Output: A diagram showing two rectangular boxes side-by-side. The first box is light blue with a purple border and contains the text "Statement 1" in red. The second box is light gray with a purple border and contains the text "Statement 2" in blue.

If ===code1=== is replaced by: ``` display:block; color: purple; ``` Output: A light blue rectangle with a purple border contains the text "Statement 1" in red. Below it, a light gray rectangle contains the text "Statement 2" in purple.

If ===code1=== is replaced by: ``` color: blue; border: 2px solid purple; ``` Output: Statement 1 Statement 2

If ===code1=== is left blank: Output: Statement 1 Statement 2

Consider the following python code snippet.
```python
from jinja2 import Template as T1
from string import Template as T2
info = {'det1': 'Civil', 'Name': 'John', 'Civil': 'Mechanical', 'John': 'Sujoy'}
t1 = T1(" ${{Name}} and {{Name}} are {{det1}} and ${{det1}} engineer respectively.")
out1 = t1.render(info)
out2 = T2(out1)
print(out2.substitute(info))
```
What is the generated output on the python console?
$John and John are Civil and $Civil engineer respectively.

John and Sujoy are Civil and Mechanical engineer respectively.

John and `{{John}}` are Civil and `{{Civil}}` engineer respectively.
Sujoy and John are Civil and Mechanical engineer respectively.

Consider the following equation;
$1xy25_8 = 1ED5_{16} = x89y_{10}.$
Where x and y are unknowns. For what values of x and y does the above equation hold true?
Consider the following Python code snippet.
Filename: app.py
```python
from flask import Flask, request
import sys
app = Flask(__name__)
@app.route('/home', methods = sys.argv[1])
def my_func():
if request.method == 'GET':
return "<h1>Hello from App Development</h1>"
elif request.method == 'POST':
return "<h1>Hello from POST</h1>"
else:
return "<h1>Please enter a valid HTTP method</h1>"
app.run(debug = True)
```
If the above flask app is run using the command `python app.py POST` in one terminal,
what will be the output on another terminal for command;
`curl http://127.0.0.1:5000/home ?`
```html <h1>Hello from App Development</h1> ```

```html <h1>Hello from App POST</h1> ```

```html <h1>Please enter a valid HTTP method</h1> ```

```html <h1>Method not Allowed</h1> ```

Consider the following Python code snippet "code.py".
Filename: code.py
```python
import sys
from jinja2 import Template
vars = sys.argv
course_technologies = {'python': 'backend', 'javascript': 'frontend'}
template = Template("This course focuses on {{ technology }} development.")
if len(vars) > 2 and vars[2] in course_technologies:
course = vars[1]
technology = course_technologies[course]
print(template.render(technology=technology))
else:
print("Please specify a valid course name!")
```
Which of the following will be the correct command line input to the terminal to get the output: This course focuses on backend development. ?
``` python code.py course python ```

``` python code.py python javascript ```

``` python code.py python python ```

``` python code.py python backend ```

Consider the following flask application.
app.py
```python
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/greet')
def greet():
user_name = request.args.get('name', 'Guest')
greeting_message = f"Hello, {user_name}!"
============code here============
if __name__ == "__main__":
app.run(debug=True)
```
Which of the following should replace "code here" to construct the HTML response with the greeting_message correctly?
```
return "<h1>{{ greeting_message }}</h1>"
```
```
return f"<h1>{greeting_message}</h1>"
```
```
return "<h1>{greeting_message}</h1>"
```
```
return "Hello, {user_name}!"
```
Match the URLs in column A with their correct rendered output in Column B with the correct app.py code for the flask application given in the previous question. | Column A | Column B | | :------- | :------- | | 1. http://127.0.0.1:5000/greet?name=MADI&guest=MADII | a. Hello, Guest! | | 2. http://127.0.0.1:5000/greet?name=MADII&guest=MADI | b. Hello, MADII! | | 3. http://127.0.0.1:5000/greet? | c. Hello, Guest! | | 4. http://127.0.0.1:5000/greet?guest=MADI | d. Hello, MADI! |
Auto-generated summary from the source site. Handy as a checklist; the lessons above explain each idea from scratch.
HTML Structure and Tags:
<h1>, <p>, <ul>, <li>, <a>, <img>.src, alt, href, style, class, id.CSS Styling:
.class), ID (#id), element (h2).color, background-color, width, text-align, display, border.!important rule in CSS.Accessibility Principles:
alt attributes for images.Python Basics:
string.Template and jinja2.Template.sys.argv.Flask Framework:
request object to access query parameters.HTTP and Web Servers:
curl to make HTTP requests.Data Structures:
Algorithms:
Bandwidth Calculations:
Network Coverage:
Relationship Types:
Number Bases:
This summary and the knowledge graphs should help you focus on the essential topics and understand the relationships between different concepts for your exam.