Home / MAD1 / Week 11 / Real questions
42 questions pulled from past papers whose wording matches this week's topics, newest first, duplicates removed. Pick your answers, then press Check answers. Figures and answer keys are the originals.

``` curl -X PUT -d "status=active&role=admin" https://api/users/update ```
You are running a Flask web application locally using the command: python app.py. On which URL will the application be accessible in the browser?```python
from flask import Flask
app = Flask(__name__)
@app.route("/")
def port():
return "This is the same port question. Yet again, for a reason."
if __name__ == "__main__":
app.run(port=0007)
```
Consider the following HTML5 form:
```html
<form method="POST" action="/submit">
<input type="email" name="email" required>
<input type="password" name="password" required minlength="8">
<input type="number" name="age" min="18" max="65" required>
<button type="submit">Submit</button>
</form>
```
Which of the following attributes are HTML5 native validation features that work without JavaScript?
Consider the following code:
app.py
```python
from flask import Flask
app = Flask(__name__)
@app.route("/")
def port():
return "This is the port question."
if __name__ == "__main__":
app.run(port=5008)
```
You are running a Flask web application locally using the command: python app.py. On which URL will the application be accessible on the browser?
http://127.0.0.1:5000/

http://localhost:0000/

http://0.0.0.0:5000/

http://localhost:5008/

Consider the following HTML snippet: ```html <img src="logo.png" alt="Company Logo" /> ``` Which of the following is true?

If logo.png fails to load, the text "Company Logo" will be shown.

If the image file is missing, browsers display it as a broken image.

The alt attribute is mandatory in HTML5.

Logo.png fails to load because the `<img>` tag only allows "jpeg/jpg" files.

Consider a document of 2000 characters written using only the characters from the character set L1 = {'x', 'y', 'z', 'w', 'v', 'u', 't', 's'}. If the character set L1 is to be upgraded by adding all the characters from the set L2 = {'1', '2', '3', '4', '5'}, by how many bits will the size of the original document increase?(assume an optimal number of bits are used for representing each character).
Consider the following example:
```html
<form>
<label for="search-input">Search for a word:</label>
<input
type="text"
id="search-input"
placeholder="Type a word to search"
aria-describedby="search-help"
required
/>
<small id="search-help">Enter a word to find relevant results.</small>
<button type="submit">Start Search</button>
</form>
```
Which of the following accessibility principles is followed in this example?
Consider the following HTML code below.
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
body{text-align: center;}
p{font-size: 30px;color: black;}
.blue{color: red;}
.red{color: green !important;}
.green{color: blue;}
#myId{color: grey;}
</style>
</head>
<body>
<div>
<p class="blue">Text1</p>
<p class="red" id="myId">Text2</p>
<p class="green" id="myId">Text3</p>
<p class="green">Text4</p>
</div>
</body>
</html>
```
How will the browser render the above HTML file?
Match the rendered color for the text.
| 1. Text1 | a. green |
|---|---|
| 2. Text2 | b. blue |
| 3. Text3 | c. red |
| 4. Text4 | d. grey |
Let L = { 'a', 'b', 'c', 'd', 'A', 'B', 'C', 'D', '^', '*', '#', '!', '$' } be a complete character set (i.e., only these characters can be used to represent text in the document). If a document that uses fixed encoding with optimal number of bits for all characters is created using the character set L and has a disk size of 3 Kilobytes, the number of characters in the documents would be _____. [Take 1 Byte = 8 bits, 1 KB = 1000 Bytes, 1 MB = 1000 Kilobytes and so on.]
Consider a flask app "app.py" and a template file "doc.html" given below:
Python file: app.py
```python
from flask import Flask, render_template
app = Flask(__name__)
itemlist = [
{'value': '0', 'content': 'zero'},
{'value': '1', 'content': 'one'},
{'value': '2', 'content': 'two'},
{'value': '3', 'content': 'three'},
]
@app.route('/')
def func():
return render_template('doc.html', itemlist = itemlist)
app.run()
```
Template file: doc.html
```html
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"></head>
<body>
{% macro render_field(value='field value', content='content value') %}
<option value="{{value}}">{{content}}</option>
{% endmacro %}
{% for item in itemlist %}
{{ render_field(item.content) }}
{% endfor %}
</body>
</html>
```
If the application is running locally on http://127.0.0.1:5000. What will be the raw HTML body of the file rendered by the flask app for base url?
```html
<body>
<option value="field value">zero</option>
<option value="field value">one</option>
<option value="field value">two</option>
<option value="field value">three</option>
</body>
```
```html
<body>
<option value="zero">content value</option>
<option value="one">content value</option>
<option value="two">content value</option>
<option value="three">content value</option>
</body>
```
```html
<body>
<option value="0">zero</option>
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</body>
```
```html
<body>
<option value="zero">0</option>
<option value="one">1</option>
<option value="two">2</option>
<option value="three">3</option>
</body>
```
Consider the following example:
```html
<form>
<label for="search-input">Search for a word:</label>
<input
type="text"
id="search-input"
placeholder="Type a word to search"
aria-describedby="search-help"
required
/>
<small id="search-help">Enter a word to find relevant results.</small>
<button type="submit">Start Search</button>
</form>
```
Which of the following accessibility principles is followed in this example?
Consider the following HTML document. ```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
function makeBold(){
//MISSING JS CODE
}
</script>
</head>
<body>
Enter your name : <input type="text" id="txt1" name="txt1">
<br>
<input type="button" onclick="makeBold();" value="Click Me">
</body>
</html>
```
Replace the **MISSING JS CODE** part with the correct JS code that will change the text box content to bold?
```javascript
t=document.getElementsByName("txt1").value;
t.style.fontWeight="bold";
```
```javascript
t=document.getElementById("txt1").value;
t.style.fontWeight="bold";
```
```javascript
t=document.getElementById("txt1");
t.style.fontWeight="bold";
```
```javascript
t=document.getElementById("txt1");
t.style.fontWeight="bold";
```
Consider the following HTML document.
Which of the following statements is/are correct about the above code snippet?```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IITM</title>
</head>
<body>
<h2>Welcome to IITM </h2>
<h3>Online Degree</h3>
Courses offered
<ol>
<li>Foundation</li>
<ul>
<li>CT</li>
<li>Python</li>
<li>Maths-I</li>
</ul>
<li>Diploma</li>
<ul>
<li>PDSA</li>
<li>MAD-I</li>
<li>MAD-II</li>
</ul>
</ol>
</body>
</html>
```
Consider the following HTML document “form.html” and the flask route given in “app.py”. Assume all the required methods are imported, Which of the following statements is/are correct.
Filename: form.html
```html
<!DOCTYPE html>
<html>
<head>
<style>
input:valid {border: 2px solid red;}
</style>
</head>
<body>
<form action="/submit_form" method="post">
<label for="e-mail">Please enter your email address</label>
<input id="e-mail" name="e-mail" required/>
<button>Submit</button>
</form>
</body>
</html>
```
Filename: app.py
```python
@app.route('/submit_form', methods = ['GET', 'POST'])
def form_on_submit():
if request.method == 'POST':
email = request.form.get('e-mail')
if "@" in email:
return "Form is validated"
return render_template('form.html')
```
Consider the following HTML Document and select the correct statement(s) from the following if a user types the password “mad1password” in the password field letter by letter. ```html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Login Form</title>
<style>
input[type="password"]:valid{
background-color: green;
}
input[type="password"]:invalid{
background-color: red;
}
</style>
</head>
<body>
<div class="login-form">
<h2>Login</h2>
<form>
E-mail: <input type="email" id="email" name="email" required>
Password: <input type="password" id="password" name="password"
required minlength="5" maxlength="8">
<input type="submit" value="Login">
</form>
</div>
</body>
</html>
```
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?
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?


Let L = { 'a', 'b', 'c', 'd', 'A', 'B', 'C', 'D', '0', '1', ' ', ' '} be a complete character set (i.e., only these characters can be used to represent text in the document). If a document that uses fixed encoding for all characters is created using the character set L and has a disk size of 2 Kilobytes, the number of characters in the documents would be ______. [Take 1 Byte = 8 bits, 1 KB = 1000 Bytes, 1 MB = 1000 Kilobytes and so on.]
Consider the following HTML document. ```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
p {
background-color: yellow;
color: red;
display: inline-block;
}
#id {
border: 2px solid purple;
color:blue ;
}
.class {
background-color: aqua;
color: red;
}
</style>
</head>
<body>
<p class="class" id="id">HTML</p>
<p class="class" >HTML</p>
<p>HTML</p>
</body>
</html>
```
How will the browser render above HTML file?
The image displays three rectangular boxes stacked vertically, each containing the text "HTML". 1. **Top box:** Cyan background, blue text, purple border. 2. **Middle box:** Cyan background, red text, no visible border. 3. **Bottom box:** Yellow background, red text, no visible border.

The image displays three rectangular boxes, each containing the text "HTML". 1. **Left Box:** A light blue rectangle with the text "HTML" in red. The text appears slightly blurred. 2. **Middle Box:** A light blue rectangle with a purple border. The text "HTML" is in blue. 3. **Right Box:** A yellow rectangle with the text "HTML" in red, with a gradient effect making it appear orange/yellow in some parts. The text also appears slightly blurred.

The image displays three rectangular blocks, each containing the text "HTML". 1. **Left Block:** A cyan rectangle with a purple border. The text "HTML" is in blue. 2. **Middle Block:** A cyan rectangle with no border. The text "HTML" is in red. 3. **Right Block:** A yellow rectangle with no border. The text "HTML" is in red.

The image displays three rectangular blocks, each containing the text "HTML". 1. **Left block:** A cyan-colored rectangle with the text "HTML" in red. The text has a slight shadow effect. 2. **Middle block:** A yellow-colored rectangle with the text "HTML" in red. The text also has a slight shadow effect. 3. **Right block:** A cyan-colored rectangle with a purple border. The text "HTML" is in blue and has a slight shadow effect.

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 |

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.

A certain text document consisting of only alphanumeric characters (including spaces) takes 1,36,000 bits, when encoded with UCS-4 (32 bit) encoding. How many bits will the same document take if encoded with ASCII 7 bit encoding? (Concept: Encoding efficiency)

34000 bits

68000 bits

29750 bits

136000 bits

Consider the following HTML code below.
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<style>
body{text-align: center;}
p{font-size: 30px;font-style: italic;color: black;}
.blue{color: green;}
.red{color: blue;}
.green{color: red;}
#myId{color: grey;}
</style>
</head>
<body>
<div>
<h2 class="red">Happy Coding</h2>
<p class="blue">1st class</p>
<p class="red" id="myId">2nd class</p>
<p class="green">3rd class </p>
</div>
</body>
</html>
```
How will the browser render the above HTML file?
Match the rendered colour for the text.
| | | |
|---|---|---|
| 1. | Happy Coding | a. green |
| 2. | 1st Class | b. blue |
| 3. | 2nd Class | c. red |
| 4. | 3rd Class | d. grey |
1- b, 2 - a, 3- d, 4 - c

1 - a, 2 - c, 3 - d, 4 - b

1- b, 2 - a, 3- c, 4 - d

1- a, 2 - c, 3- b, 4 - d

Which of the following statement(s) is/are true regarding HTML and encodings? Concepts Covered: Encoding Standards, HTML & CSS

Both UTF-8 and UTF-32 are variable length encodings.

The UTF-8 can only be used for encoding (2^16 + 1) characters.

The HTML tags are case-insensitive.

The External CSS is preferred over internal and inline CSS for developing large websites.

A certain text document consisting of only alphanumeric characters (including spaces) takes 35,552 bits, when encoded with UCS-4 (32 bit) encoding. How many bits will the same document take if encoded with ASCII 7 bit encoding? (Concept: Encoding efficiency)

6666 bits

7777 bits

8888 bits

17,776 bits