MAD Study Hub

Home / Past papers / MAD1 Quiz 1 / this paper

2024 Oct27: - 27 Oct 2024

MAD1 Quiz 116 questions50 marks13 MCQ · 3 MSQ
Elapsed 00:00
Q1MCQ2 marks
Suppose a Gamer wants to buy a Bluetooth earphone which can give him a good gaming experience, for that the delay between the action that happens in his phone and the sound heard by him for that action should be as low as possible so that he can play well. Following this scenario, which of the following option(s) is/are correct?
  1. He should buy the earphones which have high latency as much possible.
  2. It all depends on Internet Speed, so we can’t determine anything.
  3. He should buy the earphones which have low latency as much possible.
  4. He should buy the earphones which have as low Bluetooth version as possible.
Q2MCQ2 marks
question figure
Text of the picture (copyable)
Consider the below URL:

https://www.google.com/search?q=physics+books

Select the correct answer that identifies the different components of the given URL.
  1. question figure
    text
    Host: http
    Protocol: google.com/search
    Query string: q=physics+books
  2. question figure
    text
    Protocol: http
    Host: google.com/search
    Query string: q=physics+books
  3. question figure
    text
    Protocol: http
    Query string: google.com/search
    Protocol: q=physics+books
  4. question figure
    text
    Host: http
    Query string: google.com/search
    Protocol: q=physics+books
Q3MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following HTML code and select the correct rendered output from the following.

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
</head>
<body>
    <table border="2">
        <tr>
            <th>One</th>
            <td>Four</td>
        </tr>
        <tr>
            <th>Two</th>
            <td>Three</td>
        </tr>
    </table>
</body>
</html>
```
  1. question figure
    text
    This is a diagram of a table with two rows and two columns.
    
    | One | Four |
    |---|---|
    | Two | Three |
  2. question figure
    text
    | One | Two |
    |---|---|
    | Four | Three |
  3. question figure
    text
    This is a 2x2 table.
    
    | One | Two |
    |---|---|
    | Three | Four |
  4. question figure
    text
    This is a 2x2 grid with text in each cell.
    
    | One | Four |
    |---|---|
    | Two | Three |
Q4MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following code block and select the correct option regarding the output
when we run the python file app.py.

```python
from jinja2 import Template

template='''
Welcome to {{Degree}} DEGREE
First level to clear is {{level}}
...
'''

rendered=Template(template)
output=rendered.render(Degree="IITM BS",level="Foundation")
print(output)
```
  1. question figure
    text
    Welcome to IITM BS DEGREE
    First level to clear is {{ Level }}
  2. question figure
    text
    Welcome to {Degree} DEGREE
    First level to clear is
  3. question figure
    text
    Welcome to IITM BS DEGREE
    First level to clear is Foundation
  4. question figure
    text
    Welcome to DEGREE
    First level to clear is {{ Level }}
Q5MCQ3 marks
question figure
Text of the picture (copyable)
The following Python code snippet generates the output on the terminal.

```python
from string import Template
greet_template = Template('Hello, $name! Welcome to $place.')

greeting1 = greet_template.substitute(name='Alice', place='Wonderland')
print(greeting1)

data = dict(name='Bob')
greeting2 = greet_template.safe_substitute(data)
print(greeting2)

greeting3 = greet_template.substitute(data)
print(greeting3)
```

Which of the following is the correct output?
  1. question figure
    text
    ```
    Hello, Alice! Welcome to Wonderland.
    Hello, Bob! Welcome to $place.
    Hello, Bob! Welcome to $place.
    ```
  2. question figure
    text
    ```
    Hello, Alice! Welcome to Wonderland.
    Hello, Bob! Welcome to .
    Hello, Bob! Welcome to $place.
    ```
  3. question figure
    text
    ```
    Hello, Alice! Welcome to Wonderland.
    KeyError: 'what'
    Hello, Bob! Welcome to $place.
    ```
  4. question figure
    text
    ```
    Hello, Alice! Welcome to Wonderland.
    Hello, Bob! Welcome to $place.
    KeyError: 'place'
    ```
Q6MCQ3 marks
question figure
Text of the picture (copyable)
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>Welcome to MAD-I course</h1>
</body>
```

**Filename: home.html**
```html
<body>
    <h1>Welcome to PDSA course</h1>
</body>
```

**Filename: index.html**
```html
<body>
    <h1>Welcome to DBMS course</h1>
</body>
```

If a simple Python HTTP server is created for this directory, what will be rendered on the browser for base URL?
  1. question figure
    text
    Welcome to PDSA course
  2. question figure
    text
    Welcome to DBMS course
  3. question figure
    text
    Welcome to MAD-I course
  4. question figure
    text
    Directory listing for /
Q7MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following Python code and select correct output.

```python
from jinja2 import Template

class Loan:

    def __init__(self, accno, loan_amount, interest_rate):
        self.accno = accno
        self.loan_amount = loan_amount
        self.interest_rate = interest_rate

    def get_loan_details(self):
        return (self.accno, self.loan_amount, self.interest_rate)

loan1 = Loan(101, 45900, 5)
loan2 = Loan(102, 170000, 6)

tm1 = Template("Account1 : {{ l1.get_loan_details() }}")
tm2 = Template("Account2 : {{ l2.get_loan_details() }}")

print(tm1.render(l1=loan1))
print(tm2.render(l2=loan2))
```
  1. question figure
    text
    Account1 : (102, 170000, 6)
    Account2 : (101, 45900, 5)
  2. question figure
    text
    Account2 : (102, 170000, 6)
  3. question figure
    text
    Account1 : (101, 45900, 5)
  4. question figure
    text
    Account1 : (101, 45900, 5)
    Account2 : (102, 170000, 6)
Q8MCQ3 marks
question figure
Text of the picture (copyable)
Which of the following flask view functions will return a 404 error for the URL:
http://127.0.0.1:5000/communication/landline/0712 ?
  1. question figure
    text
    ```python
    @app.route('/communication/<type>/<areacode>')
    def home(type, areacode):
        details = {'type': type, 'area-code': areacode}
        return details
    ```
  2. question figure
    text
    ```python
    @app.route('/communication/<string:type>/<int:areacode>')
    def home(type, areacode):
        details = {'type': type, 'area-code': areacode}
        return details
    ```
  3. question figure
    text
    ```python
    @app.route('/communication/<string:type>/0712')
    def home(type):
        details = {'type': type, 'area-code': 044}
        return details
    ```
  4. question figure
    text
    ```python
    @app.route('/communication/online/<string:type>/<areacode>')
    def home(type, areacode):
        details = {'type': type, 'area-code': 044}
        return details
    ```
Q9MCQ4.5 marks
A certain network connection with a bandwidth of 10 Mbps allows making 1000 requests to a server per second. If each request is modified to have an additional data of 8 Kb, what should be the additional bandwidth required to maintain the rate of 2000 requests per second?
  1. 18 Mbps
  2. 16 Mbps
  3. 26 Mbps
  4. 36 Mbps
Q10MCQ4.5 marks
question figure
Text of the picture (copyable)
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)
def my_func():
    if request.method == 'GET':
        return "<h1>Hello from POST</h1>"

    elif request.method == 'POST':
        return "<h1>Hello from GET</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 GET POST` in one terminal, what will be the output on another terminal for command;
`curl http://127.0.0.1:5000/home ?`
  1. question figure
    text
    ```html
    <h1>Hello from GET</h1>
    ```
  2. question figure
    text
    ```html
    <h1>Hello from POST</h1>
    ```
  3. question figure
    text
    ```html
    <h1>Please enter a valid HTTP method</h1>
    ```
  4. question figure
    text
    ```html
    <h1>Method not Allowed</h1>
    ```
Q11MCQ4.5 marks
question figure
Text of the picture (copyable)
A client C and the server S located, 12000 km apart are connected with the help of
a cable. A request was sent by the client C to server S, but while sending back the
response to the client, the cable breaks and the response is now sent back via air. This
change in medium caused an additional delay of 20 msec. As compared to the Round
Trip Time of the healthy network, the Round Trip Time (RTT) of the faulty system would
________.

[The speed of light in air is 3 x 10⁸ m/s and that on a cable is 2 x 10⁸ m/s]
  1. Increase
  2. Decrease
  3. Remain Same
  4. Insufficient Information
Q12MSQ2 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the below server response

**HTTP/2.0 500 Internal Server Error**

Which of the following is/are **True**?
  1. HTTP/2.0 is the protocol and version respectively
  2. 500 is the port number
  3. “Internal Server Error” is the status message
  4. 500 is the status code
  5. HTTP/2.0 is the server failure
Q13MSQ2 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the flask code below.

```python
from flask import Flask

app = Flask(__name__)

@app.route("/employee/<id>")
def get_employee(id):
    return "Employee id : " + str(id)

if __name__ == "__main__":
    app.run(debug=True)
```

Assume that the above flask application is running on http://127.0.0.1:5000 . Which of the following URLs will render "Not Found" error?
  1. question figure
    text
    http://127.0.0.1:5000/employee/102
  2. question figure
    text
    http://127.0.0.1:5000/employee/id=102
  3. question figure
    text
    http://127.0.0.1:5000/id=102
  4. question figure
    text
    http://127.0.0.1:5000/102
Q14MSQ4.5 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following code snippet.

```python
@app.route('/name/<type>')
def prod_detail(type):
    # CODE BLOCK HERE
```

Assume the database has a "product" table represented by class "Product" which has a TEXT column "type". If we want the server to return a 404 status code when a user goes to the route '/name/<type>' with a "type" that does not exist in the database, which of the following lines would give us the desired output?
  1. question figure
    text
    ```python
    type = Product.query.filter_by(type=type).first()
    if type is None:
        return render_template("404.html")
    return render_template('details.html', type=type)
    ```
  2. question figure
    text
    ```python
    type = Product.query.filter_by(type=type).first()
    if type is None:
        abort(404)
    return render_template('details.html', type=type)
    ```
  3. question figure
    text
    ```python
    type = Product.query.filter_by(type=type).first_or_404()
    return render_template('details.html', type=type)
    ```
  4. question figure
    text
    ```python
    type = Product.query.filter_by(type=type).first()
    if type is None:
        return render_template("404.html"), 404
    return render_template('details.html', type=type)
    ```
Comprehension passage - the questions below it refer to this
Consider the following code and answer the given subquestions. question figure Consider the following code and answer the given subquestions.
Q15MCQ3 marks
question figure
Text of the picture (copyable)
Suppose the value of **Method** in form.html is GET
(form method is set to GET) and in the input box
we write "Application", after submitting the form
how the URL will look? Remember server is
running on the server, http://127.0.0.1:5000.
  1. question figure
    text
    http://127.0.0.1:5000/?name=Application
  2. question figure
    text
    http://127.0.0.1:5000/name=Application
  3. question figure
    text
    http://127.0.0.1:5000/?name
  4. question figure
    text
    http://127.0.0.1:5000/
Q16MCQ3 marks
question figure
Text of the picture (copyable)
Suppose the value of **Method** in form.html is
POST (form method is set to POST) and in the
input box we write "Application", after submitting
the form how the URL will look? Remember server
is running on the server, http://127.0.0.1:5000.
  1. question figure
    text
    http://127.0.0.1:5000/?name:Application
  2. question figure
    text
    http://127.0.0.1:5000/?Application
  3. question figure
    text
    http://127.0.0.1:5000/?name
  4. question figure
    text
    http://127.0.0.1:5000/

Answer key

  1. Q1 (MCQ, 2 marks): C
  2. Q2 (MCQ, 2 marks): B
  3. Q3 (MCQ, 3 marks): A
  4. Q4 (MCQ, 3 marks): B
  5. Q5 (MCQ, 3 marks): D
  6. Q6 (MCQ, 3 marks): B
  7. Q7 (MCQ, 3 marks): D
  8. Q8 (MCQ, 3 marks): D
  9. Q9 (MCQ, 4.5 marks): C
  10. Q10 (MCQ, 4.5 marks): B
  11. Q11 (MCQ, 4.5 marks): C
  12. Q12 (MSQ, 2 marks): A, C, D
  13. Q13 (MSQ, 2 marks): C, D
  14. Q14 (MSQ, 4.5 marks): B, C, D
  15. Q15 (MCQ, 3 marks): A
  16. Q16 (MCQ, 3 marks): D

Concepts this paper tests

Auto-generated summary from the source site. Handy as a checklist; the lessons above explain each idea from scratch.

Summary of Core Topics, Concepts, Principles, and Equations

1. Web Development and HTTP

2. HTML and Forms

3. Networking Concepts

4. Python and Flask

@app.route('/') def home(): return "Hello, World!"

if _name_ == '_main_': app.run(debug=True) ```

app = Flask(_name_)

@app.route('/', methods=['GET', 'POST']) def home(): if request.method == 'GET': return "GET request" elif request.method == 'POST': return "POST request"

if _name_ == '_main_': app.run(debug=True) ```

5. Jinja2 Templates

app = Flask(_name_)

@app.route('/') def home(): template = Template('Hello, {{ name }}!') return template.render(name='World')

if _name_ == '_main_': app.run(debug=True) ```