Home / Past papers / MAD1 Quiz 2 / this paper

THIS IS QUESTION PAPER FOR THE SUBJECT "MODERN APPLICATION DEVELOPMENT 1" ARE YOU SURE YOU HAVE TO WRITE EXAM FOR THIS SUBJECT? CROSS CHECK YOUR HALL TICKET TO CONFIRM THE SUBJECTS TO BE WRITTEN. (IF IT IS NOT THE CORRECT SUBJECT, PLS CHECK THE SECTION AT THE TOP FOR THE SUBJECTS REGISTERED BY YOU)
Consider the Python file and a template given below. Python file: app.py Template file: index.html
Consider the Python file and a template given below. Python file: app.py Template file: index.html If the above flask application is running locally on the URL ‘http://127.0.0.1:5000’, which of the following statements is/are true about the above code snippet?```python
from flask import Flask, url_for, redirect, render_template
app = Flask(__name__)
@app.route("/<name>/")
def index1(name):
return "Hi" + " " + name + "!" + " " + "This is your home page."
@app.route("/first_index/<string:name>")
def index2(name):
if name == "XYZ":
return redirect(url_for("index1", name = "XYZ"))
else:
return redirect( url_for("index3"))
@app.route("/second_index")
def index3():
return render_template("index.html")
if __name__ == "__main__":
app.run(debug=True)
```
```html
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Document</title>
</head>
<body>
<h2>You are on the incorrect page.</h2>
<a href="{{ url_for("index1", name="ABC") }}">Go back</a>
</body>
</html>
```
For the endpoint '/XYZ', the browser will show 'Not Found' error.

On clicking the link "Go back" in "index.html", the browser will render: Hi ABC! This is your home page.

For the endpoint '/first_index/XYZ', the browser will redirect to the URL for the function index3, i.e., '/second_index'.

For the endpoint '/first_index/ABC', the browser will redirect to the URL for the function 'index3' i.e., '/second_index'.
A flask application is given below. If the above flask application is running locally on the URL ‘http://127.0.0.1:5000’, which of the following statement is true about the above flask application?```python
from flask import Flask, jsonify
app = Flask(__name__)
Gadgets = [
{"tech":"Smartwatch, Digital camera"},
{"mobile":"Headphones, Speakers"},
{"Laptop":"Keyboard, Mouse"}
]
@app.route("/home", methods=["GET"])
def func1():
return jsonify({"The list of gadgets": Gadgets})
@app.route("/")
def rest_lists():
return {
"Restaurant 1" : "Hotel Alpine",
"Restaurant 2" : "Maurya Vihar",
"Restaurant 3" : "Royal Garden"
}
if __name__ == "__main__":
app.run(debug=True)
```
For the endpoint "/", The content type of the response is 'application/json'

For the endpoint '/home', the application returns:
```json
"The list of gadgets":
{
"tech":"Smartwatch, Digital camera",
"mobile":"Headphones, Speakers",
"Laptop":"Keyboard, Mouse"
}
```
None of the endpoints, i.e., '/' or '/home' can be considered as access URIs of an API.

For the endpoint '/home', the application returns:
```
"The list of gadgets":
{
"tech": "Smartwatch, Digital camera"
},
{
"mobile": "Headphones, Speakers"
},
{
"Laptop": "Keyboard, Mouse"
}
```
Consider the table “production” in SQLite database given below: | Manufacturer | Product | Quantity | Cost | |---|---|---|---| | Industry A | Biscuits | 3 | 100 | | Industry B | Shoes | 2 | 500 | | Industry A | Chocolate | 10 | 200 | | Industry C | Pen | 20 | 50 | | Industry B | Shirts | 5 | 700 | | Industry D | Beverages | 30 | 150 | | Industry C | Notebook | 40 | 250 | What will be the output of the SQL query given below? ```sql SELECT Manufacturer, COUNT(*) FROM production WHERE Quantity>10 GROUP BY Manufacturer HAVING COUNT(*)=2; ```

``` | Manufacturer | COUNT(*) | |---|---| | Industry D | 1 | ```

``` Manufacturer|COUNT(*) Industry C |2 ```

``` Manufacturer|COUNT(*) Industry C |2 Industry D |1 ```

``` Manufacturer|COUNT(*) Industry C |1 Industry D |2 ```
Consider the table “employee” given below. The model class “Employee” corresponds to table “employee” in the database. | id | first_name | last_name | email | |---|---|---|---| | 1 | Ruhil | Verma | verma@gmail.com | | 2 | Monica | gulati | manisha@gmail.com | | 3 | Sandeep | Sharma | sharma@gmail.com | | 4 | Taapsi | Uma | uma@gmail.com | What will be the output of the flask_sqlalchemy command given below? ```python >>> user1= Employee.query.filter_by(first_name="Monica").first() >>> user1.first_name= "Manisha" >>> db.session.commit() >>> emp = Employee.query.all() >>> for emp1 in emp: ...print(first_name) ```

Ruhil Monica Sandeep Taapsi

Ruhil Sandeep Taapsi

Ruhil Manisha Sandeep Taapsi

None of these
Which of the following is the correct Python object representation of the given SQL query with declarative_base() class. ```sql
CREATE TABLE "Items" (
"ID" INTEGER,
"name" TEXT,
"cost" INTEGER,
PRIMARY KEY("ID" AUTOINCREMENT)
)
```
```python
Base = declarative_base()
class User(Base):
__tablename__ = "User"
ID = Column(Integer, primary_key = True, autoincrement = True)
name = Column(String)
cost = Column(Integer)
```
```python
Base = declarative_base()
class Items(Base):
__tablename__ = "Items"
ID = Column(Integer, primary_key = True, autoincrement = True)
name = Column(String)
cost = Column(Integer)
```
```python
Base = declarative_base()
class Items(Base):
__tablename__ = "Items"
Item_ID = Column(Integer, primary_key = True, autoincrement = True)
Item_name = Column(String)
Item_cost = Column(Integer)
```
```python
Base = declarative_base()
class Items(Base):
__tablename__ = "Items"
cost = Column(Integer, primary_key = True, autoincrement = True)
name = Column(String)
ID = Column(Integer)
```
If the below flask application is running locally on the URL: ‘http://127.0.0.1:5000’, what will be rendered by the browser? Python file: main.py Template: index.html
If the below flask application is running locally on the URL: ‘http://127.0.0.1:5000’, what will be rendered by the browser? Python file: main.py Template: index.html ```python
from flask import Flask, render_template
app=Flask(__name__)
@app.route('/')
def home():
my_course = ['App1', 'App2', 'python', 'Data science',
'Database', 'machine learning']
return render_template('index.html', list=my_course)
if __name__ == '__main__':
app.run(debug=True)
```
```html
<html>
<head>
<title>template file</title>
</head>
<body>
{% macro display(list) %}
{% for course in list %}
<p>{{ course }}</p>
{% endfor %}
{% endmacro %}
{{ display(list) }}
</body>
</html>
```
``` ['App1', 'App2', 'python', 'Data science', 'Database', 'machine learning'] ```

``` ['App1', 'App2', 'python', 'Data science', 'Database', 'machine learning'] ```

App1 App2 python Data science Database machine learning

App1 App2 python Data science Database machine learning
Consider the following table “table_A” in SQLite database. | | ID | First_Name | Last_Name | Course | |---|---|---|---|---| | | Filter | Filter | Filter | Filter | | 1 | 1 | Raj | R | Java | | 2 | 2 | Riya | Z | Java | | 3 | 3 | Sam | sundar | Java | | 4 | 4 | praneeth | k | Java | | 5 | 5 | Kunal | T | Python | | 6 | 6 | vimal | singh | Python | | 7 | 7 | sethu | J | Python | | 8 | 8 | liza | G | C++ | | 9 | 9 | shylla | chopra | C++ | What will be the output of the following SQL query? ```sql SELECT Course, count(ID) AS No_Of_Students FROM table_A GROUP BY Course ORDER BY No_Of_Students ASC; ```

| | Course | No_Of_Students | |---|---|---| | 1 | Python | 1 | | 2 | Java | 1 | | 3 | Java | 1 | | 4 | Java | 1 | | 5 | C++ | 1 | | 6 | Java | 1 | | 7 | Python | 1 | | 8 | C++ | 1 | | 9 | Python | 1 |

``` | | Course | No_Of_Students | |---|--------|----------------| | 1 | Python | 1 | | 2 | C++ | 1 | | 3 | Python | 1 | | 4 | Java | 1 | | 5 | C++ | 1 | | 6 | Java | 1 | | 7 | Java | 1 | | 8 | Java | 1 | | 9 | Python | 1 | ```

| | Course | No_Of_Students | |---|---|---| | 1 | Java | 4 | | 2 | Python | 3 | | 3 | C++ | 2 |

| | Course | No_Of_Students | |---|---|---| | 1 | C++ | 2 | | 2 | Python | 3 | | 3 | Java | 4 |
Consider the following HTML file with embedded JavaScript. Filename: index.html How will the browser render the above HTML file?```html
<!DOCTYPE html>
<html>
<body>
<h2>Creating a Json Object </h2>
<p id="jsonobj"></p>
<script>
const txt = '{"name":"icecream","type":"cup",
"flavor":"vanilla"}'
const obj = JSON.parse(txt);
document.getElementById("jsonobj").innerHTML = obj.name + ", "
+ obj.flavor + ", " + obj.type;
</script>
</body>
</html>
```
Creating a Json Object undefined, undefined, undefined

Creating a Json Object vanilla, icecream, cup

Creating a Json Object cup, vanilla, icecream

Creating a Json Object icecream, vanilla, cup
Consider the following table ‘flowers’ in SQLite database. Here's the transcription of the visible text: | ID ▼1 | Name | color | |---|---|---| | Filter | Filter | Filter | | 1 | Jasmine | white | | 2 | Rose | pink | | 3 | Lily | pink | | 4 | Lotus | pink | | 5 | Red rose | red | What will be the output of the following SQL query? ```sql Select count(ID), Name, color from flowers group by color HAVING count(color)<2; ```

| count(ID) | Name | color | |---|---|---| | 3 | Rose | pink |

| count(ID) | Name | color | | :-------- | :-------- | :---- | | 1 | red rose | red | | 1 | Jasmine | white |

| count(ID) | Name | color | | :-------- | :-------- | :---- | | 3 | Rose | pink | | 1 | red rose | red | | 1 | Jasmine | white |

| count(ID) | Name | color | | :-------- | :-------- | :---- | | 1 | Red rose | red | | 1 | Jasmine | white |
Match the following based on the memory hierarchy of computer. | Parameters | Storage element | | :------------------ | :-------------- | | 1. Highest Latency | a. HDD | | 2. Lowest Density | b. Register | | 3. Lowest Throughput| c. DRAM | | | d. SSD | | | e. SRAM |
Consider the HTML document given below: Which of the following statements is true for the above HTML document when rendered by the browser?```html
<!DOCTYPE html>
<html>
<head>
<style>
[id~=out] {
border: 10px solid red;
}
[class~=out]{
border: 5px solid yellow;
}
</style>
</head>
<body>
<h2>Hello World!</h2>
<h1 id="out">Hey!</h1>
<p id="out-text">My name is Fred.</p>
<p class="outcontent">I am learning to develop
applications.</p>
<p id ="out"> Are you also willing to learn?</p>
<p class="out">Welcome to the world of Application
development!</p>
<h3>Have a nice day!!</h3>
</body>
</html>
```
Consider the following PyHTML program. Identify the corresponding HTML file which will be generated on running the PyHTML code. ```python
from pyhtml import *
my_html = html(head(title("Quiz 2")),
body(h2("Second level heading"),
div("This is my first div"),
p("Paragraph1"),
p("Paragraph2")
)
)
output = my_html.render()
print(output)
```
```html
<!DOCTYPE html>
<html>
<head>
<title>Quiz 2</title>
</head>
<body>
<h2>Second level heading</h2>
<div>This is my first div</div>
<p>Paragraph1</p>
<p>Paragraph2</p>
</body>
</html>
```
```html
<!DOCTYPE html>
<html>
<head>
<h2>Second level heading</h2>
</head>
<body>
<title>Quiz 2</title>
<div>This is my first div</div>
<p>Paragraph1</p>
<p>Paragraph2</p>
</body>
</html>
```
```html
<!DOCTYPE html>
<html>
<head>
<title>Quiz 2</title>
<div>This is my first div</div>
</head>
<body>
<h2>Second level heading</h2>
<p>Paragraph1</p>
<p>Paragraph2</p>
</body>
</html>
```
```html
<!DOCTYPE html>
<html>
<head>
<title>Quiz 2</title>
</head>
<body>
<h2>Second level heading</h2>
<div>This is my first div
<p>Paragraph1</p>
<p>Paragraph2</p>
</div>
</body>
</html>
```
Consider two software packages A and B. The average processing time of the package A is TA(n) = 0.001n milliseconds and the average processing time of the package B is TB(n) = 500√n milliseconds, where n is the number of records being processed. Which of the given software packages A and B should be chosen to process data collections, containing 10⁸ records?
Consider the following Python code snippet: ```python
from flask import Flask
from flask_restful import Resource, Api, reqparse, fields, \
marshal_with
app = Flask('__main__')
api = Api(app)
parser = reqparse.RequestParser()
parser.add_argument("Id")
parser.add_argument("name")
parser.add_argument("email")
out_fields = {
"Id": fields.Integer,
"name": fields.String
}
class MyApi(Resource):
def get(self):
info = parser.parse_args()
return {"Identity": info['Id'] , "Name": info['name'], \
"E-mail": info['email']}
@marshal_with(out_fields)
def post(self):
info = parser.parse_args()
return info
api.add_resource(MyApi, '/myinfo')
app.run(debug = True)
```
If the application is running locally on the URL: "http://127.0.0.1:5000", What will be the output on the terminal for command:
```bash
curl -X POST -H "Content-Type: application/json" \
-d "{\"Id\":3, \"name\":\"user_1\", \"email\": \
\"user_1@gmail.com\"}" http://127.0.0.1:5000/myinfo
```
```json
{
"Identity": "3",
"Name": "user_1",
"E-mail": "user_1@gmail.com"
}
```
```json
{
"Id": 3,
"name": "user_1"
}
```
```json
{
"Id": "3",
"name": "user_1"
}
```
```json
{
"name": "user_1",
"email": "user_1@gmail.com"
}
```