Quiz Space

January 2022 term · Modern Application Development I · BSCS2003

MAD 1 End Term: 3 April 2022 (January 2022 term)

The IIT Madras BS Modern Application Development I (MAD 1) End Term paper sat on 3 Apr 2022, in the January 2022 term: 32 questions for 100 marks in 180 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
32
Marks
100
Duration
180 min
MCQ
26
MSQ
4
Numerical
2

Updated

Official paper: IIT M FOUNDATION DIPLOMA ENDTERM FN1 3 Apr 2022 · No negative marking.

Question 1

+2 marksOne correct option

The hexadecimal representation of the number 3218 is _ .

  1. A

    B1

  2. B

    B2

  3. C

    D1

  4. D

    D2

Show answer

Correct answer

  • C

    D1

Question 2

+2 marksOne correct option

Let L = {‘c’, ‘e’, ‘i’, ‘m’, ‘o’, ‘t’} be a complete character set (i.e., only these symbols need to be represented in the set). What is the minimum number of bits required to represent ‘committee’ in this character set?
Note: You can create your own character encoding method, but each character should be encoded using the same number of bits.

  1. A

    18

  2. B

    27

  3. C

    9

  4. D

    32

Show answer

Correct answer

  • B

    27

Question 3

+2 marksOne correct option

Consider the HTML code below.

html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>My title</title>
<style>
.class1 {
color: yellow;
}
.class2 {
color: red;
}
.class3 {
color: blue;
}
</style>
</head>
<body>
<div>
<p class="class3 class2 class1">
CSS is fun!
</p>
</div>
</body>
</html>

What will be the color applied to the text in the paragraph tag?

  1. A

    yellow

  2. B

    red

  3. C

    blue

  4. D

    None of these

Show answer

Correct answer

  • C

    blue

Question 4

+2 marksOne correct option

Consider the following services provided by platform-as-a-service approach.
A Power supply, network and hardware management.
B Updating of security patches and OS installation.
C providing base for application platform.
D Includes multiple database connectivity.
Suppose the above-mentioned services are taken care by the provider, then identify the job of developer.

  1. A

    Specify the requirements on server, database and network connectivity.

  2. B

    Deploy and maintain the application.

  3. C

    Both Specify the requirements on server, database and network connectivity & Deploy and maintain the application.

  4. D

    None of these

Show answer

Correct answer

  • C

    Both Specify the requirements on server, database and network connectivity & Deploy and maintain the application.

Question 5

+2 marksOne correct option

Identify the system that provides centralized control over distributed patches and provides a friendly interface for Git.

  1. A

    Gitlens

  2. B

    Github

  3. C

    Gitlab

  4. D

    Both Gitlens and Github

Show answer

Correct answer

  • D

    Both Gitlens and Github

Question 6

+3 marksOne correct option

Consider the code snippet given below.

python
from jinja2 import Template
class ClassRoom:
def __init__(self, rollNo, name):
self.rollNo = rollNo
self.name = name
self.email = name + "@gmail.com"
def getRollNo(self):
return self.rollNo
def getName(self):
return self.name
info = ClassRoom(144, "Raman")
course=["Java", "Python", "C++"]
temp = Template("My name is {{ Info.getName() }}, my roll number is {{ Info.getRollNo() }}, and my email address is: {{ Info.email }}")
temp1 = Template("""The list of courses are: {% for item in course %}
{{ item }}
{% endfor %}
""")
out = temp.render(Info=info)
out1 = temp1.render(course=course)
print(out, out1)

What will be the output of the above code?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 7

+3 marksOne correct option

Consider the code below.

python
from flask import Flask
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class Hello(Resource):
def get(self):
return {'Message': 'Hello World!'}, 200
class Demo(Resource):
def get(self, n):
return {'Your Result': n+100},201
class HelloName(Resource):
def get(self, name):
return {'Info': 'Your name is {}'.format(name)}, 202
api.add_resource(Hello, '/helloworld','/')
api.add_resource(Demo, '/<int:n>')
api.add_resource(HelloName, '/helloname/<string:name>')
if __name__ == '__main__':
app.run(debug=True)

If the above flask application is running on URL “ http://127.0.0.1:5000/”, then which of the following statements is/are correct?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 8

+3 marksOne correct option

What will the output of the Python code given below?

python
def decor1(func):
def inner():
x = func()
return (x * x)*10
return inner
def decor(func):
def inner():
x = func()
return x + 10
return inner
@decor1
@decor
def num():
return 1
print(num())
  1. A

    1000

  2. B

    1210

  3. C

    10

  4. D

    None of these

Show answer

Correct answer

  • B

    1210

Question 9

+3 marksOne correct option

Consider the code given below.

Which of the following types of code coverage will be satisfied when the above code is run from a terminal?

  1. A

    Condition coverage

  2. B

    Function coverage

  3. C

    Statement coverage

  4. D

    None of these

Show answer

Correct answer

  • B

    Function coverage

Question 10

+3 marksOne correct option

Consider the following JavaScript code.

File name : index.html

html
<!DOCTYPE html>
<html>
<body>
<form>
<label for = "mail"> provide me with an e-mail address: </label>
<input type = "email" id="mail" name="mail">
<button>Submit </button>
</form>
<script src= "script.js">
</script>
</body>
</html>

File name: script.js

javascript
const email = document.getElementById("mail");
email.addEventListener("input", function (event) {
if ((email.validity.typeMismatch)) {
email.setCustomValidity("provide me with valid e-mail address!");
}else {
email.setCustomValidity("email verified");
}
});

What will be the output for the given inputs?
1) abcd@gmail.com
2) abcdatgmail

  1. A

    “email verified” and “I am expecting an e-mail address”

  2. B

    “provide me with valid an e-mail address!” and “email verified”

  3. C

    “email verified” and “provide me with valid e-mail address!”

  4. D

    None of these

Show answer

Correct answer

  • C

    “email verified” and “provide me with valid e-mail address!”

Question 11

+3 marksOne correct option

Consider the following JavaScript code.

File name: script.js

javascript
window.onload = function() {
const heading = document.createElement("h1");
const heading_text = document.createTextNode("Big Head!");
const heading1 = document.createElement("h3");
const heading_text1 = document.createTextNode("small Head!");
heading.appendChild(heading_text);
heading1.appendChild(heading_text1);
document.body.appendChild(heading);
document.body.appendChild(heading1);
}

File name: index.html

html
<!DOCTYPE html>
<html>
<body>
<script src="script.js"></script>
</body>
</html>

How will the browser render the above code?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 12

+3 marksOne correct option

Consider the following table “employee” in SQLite database.

What will be the output of the SQL query given below?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 13

+3 marksOne correct option

Consider the following HTML and external CSS code.

File name: style.css

css
body{background-color: lavender; text-align: center;}
h2{font-style: normal; font-size: 30px; color: #f08080;}
p{font-size: 20px;}
.blue{color: green;}
.red{color: blue;}
.green{color: red;}

File name: index.html

html
<!DOCTYPE html>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h2>Welcome to IIT</h2>
<p class="blue">I am blue color </p>
<p class="red">I am red color </p>
<p class="green">I am green color </p>
</body>
</html>

How the heading and paragraph are printed in the output?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 14

+3 marksOne correct option

Which of the following is the valid Python code to create a login session for a user and delete the session when the user logs out?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 15

+3 marksOne correct option

Consider the following code
File name: app.py

python
from flask import Flask, render_template, request
app = Flask(__name__)
users = {
'3':{'name': 'Rio', 'cadre': 'manager'},
'2':{'name': 'Jai', 'cadre': 'steno'},
'5':{'name': 'Rovan', 'cadre': 'computer operator'}
}
@app.route('/')
def country():
id = request.args.get('id')
authenticated_users_id = [1, 3, 4, 5]
user = users.get(id)
name = user.get('name') if user is not None else None
cadre = user.get('cadre') if user is not None else None
user = {'is_authenticated': False, 'name': name,
'cadre': cadre}
if int(id) in authenticated_users_id:
user['is_authenticated'] = True
return render_template('index.html', data = user)
if int(id) not in authenticated_users_id:
user['is_authenticated'] = False
return render_template('index.html', data = user)
if __name__ == "__main__":
app.run(debug = True)

File name: index.html

html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
{% if data.name == None %}
User not found
{% elif data.is_authenticated == True %}
Hello {{data.name}} you have access: {{data.cadre}}
{% else %}
Hello {{data.name}} you have no access to this site: {{data.cadre}}
{% endif %}
</body>
</html>

Suppose the application is running locally on the ‘http://127.0.0.1:5000’, then what will be rendered by the browser for ‘http://127.0.0.1:5000/?id=5’, ‘http://127.0.0.1:5000/?id=2’ and
‘http://127.0.0.1:5000/?id=8’ respectively?

  1. A

    “Hello Rovan you have access: computer operator”, “Hello Jai you have no access to this site: steno” and “User not found”

  2. B

    “Hello Rovan you have no access to this site: computer operator”, “Hello Jai you have access: steno” and “User not found”

  3. C

    “User not found”, “Hello Rovan you have access: computer operator” and “Hello Jai you have no access to this site: steno”

  4. D

    “User not found”,“Hello Rovan you have no access to this site: computer operator” and “Hello Jai you have access: steno”

Show answer

Correct answer

  • A

    “Hello Rovan you have access: computer operator”, “Hello Jai you have no access to this site: steno” and “User not found”

Question 16

+3 marksOne correct option

Consider the following JavaScript code.

File name: index.html

html
<!DOCTYPE html>
<html>
<head>
<p> Course name - Course </p>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

File name: script.js

javascript
const para = document.querySelector('p');
para.addEventListener('click', updateName);
function updateName() {
const cname = prompt('Enter your Course');
para.textContent = 'course name:' +cname;
}

Suppose the script is running locally and if the input given as “APP Development” then what will be rendered by the browser?

  1. A

    course name: course

  2. B

    course name: APP Development

  3. C

    APP Development

  4. D

    course: App Development

Show answer

Correct answer

  • B

    course name: APP Development

Question 17

+3 marksOne correct option

Consider the following Python code snippet.

python
1 from jinja2 import Template
2
3 template = """
4 {% for e in employees %}
5 Employee Name: {{ e.name }}
6 Project allocated Id: {{ e.ProjectID | default('1000') }}
7 {% endfor %}
8 """
9 x = Template(template)
10
11 emp = [ {"name": "ABC", "ProjectID": 1111},
12 {"name": "DEF", "ProjectID": 2222},
13 {"name": "PQR"},
14 {"name": "XYZ"}
15 ]
16
17 print(x.render(employees = emp))
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 18

+3 marksOne correct option

Match the status codes responded by server on client request.

  1. A

    a-ii, b-i, c-iii, d-iv

  2. B

    a-ii, b-i, c-iv, d-iii

  3. C

    a-i, b-ii, c-iii, d-iv

  4. D

    a-ii, b-iv, c-iii, d-i

Show answer

Correct answer

  • B

    a-ii, b-i, c-iv, d-iii

Question 19

+4.5 marksOne correct option

Consider the code snippet given below.

html
<!DOCTYPE html>
<html>
<head>
<style>
p ~ p {
background-color: green;
}
</style>
</head>
<body>
<h2>This is my Heading</h2>
<p>Paragraph 1</p>
<p>Paragraph 2</p>
<p>Paragraph 3</p>
<div>
<p>Paragraph 4</p>
</div>
<p>Paragraph 5</p>
<p>Paragraph 6</p>
</body>
</html>

Which of the following is the correct output of the above HTML code?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 20

+4.5 marksOne correct option

Consider the files given below.

File 1: macros.py

python
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def home():
list = [43, 76, 87, 98, 45, 23]
return render_template('index_macros.html', my_list = list)
if __name__=='__main__':
app.run(debug=True)

File 2: index_macros.html

html
{% from "_macros.html" import calc %}
<!DOCTYPE html>
<html>
<head>
<title> Macros </title>
</head>
<body>
{{ calc(my_list) }}
</body>
</html>

File 3: _macros.html

html
{% macro calc(my_list) %}
<h3> The original list :{{ my_list }} </h3>
<h3> The modified list: </h3>
{% for num in my_list if num%2==1 and num%3==1 %}
{{ num }}
{% endfor %}
{% endmacro %}

Which of the following will be the correct output, if the above application is running on URL “ http://127.0.0.1:5000/”?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 21

+4.5 marksOne correct option

Suppose a client and the server are 1200 kilometers apart and the client want to access a web application that requires basic authentication to authenticate its users. The sequence diagram representing the authentication process is given below. What is the minimum amount of time required before the client can finally view its profile? [Assuming speed of light on cable is 2 × 10⁸ m/s]

  1. A

    67 milliseconds

  2. B

    29 milliseconds

  3. C

    79 milliseconds

  4. D

    55 milliseconds

Show answer

Correct answer

  • C

    79 milliseconds

Question 22

+4.5 marksOne correct option

Consider the following Python code

python
def element(type, style, text):
stylestr = ''
for i in style:
stylestr += i + ':'
stylestr += style[i] + ';'
return "<"+type+" style = '"+stylestr+"'>"+text+"</"+type+">"
style1 = {"color":"blue","font-size":"25px","background-color":"grey"}
style2 = {"border":"5px dotted green","width":"300px"}
style3 = {"color":"red"}
text1 = 'This is some text'
text2 = 'Some more text'
My_doc = """
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
</head>
<body>
""" + element('div',style2,element('h1',style1, text1) +
element('p',style3,text2))+ """
</body>
</html>
"""

How will the browser render the HTML document created by the above code?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 23

+4.5 marksOne correct option

The sample tables “salesman” and “customer” in SQLite database are given below. Choose the correct SQL query to find every salesman and customer who belong to the same city from the given input tables.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 24

+4.5 marksOne correct option

Which of the following queries produces the below multi-column indexing?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 25

+4.5 marksOne correct option

What will be the output of code snippet given below.

python
1 from jinja2 import Template
2
3 output1 = Template("Company name of car model {{ c.getModel() }} is {{ c.getCompany() }}")
4 output2 = Template("Company name of car model {{ c.model() }} is {{ c.getCompany() }}")
5 output3 = Template("Company name of car model {{ c.getModel() }} is {{ c.company() }}")
6
7 class Car:
8 def __init__(self, company, model):
9 self.company = company
10 self.model = model
11
12 def getCompany(self):
13 return self.company
14
15 def getModel(self):
16 return self.model
17
18 c1 = Car("Maruti","ERTIGA")
19 c2 = Car("Honda","AMAZE")
20 c3 = Car("Tata","NEXON")
21
22 print(output1.render(c = c1))
23 print(output1.render(c = c2))
24 print(output1.render(c = c3))
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 26

+4.5 marksOne correct option

Consider the below Python code to generate HTML code:

Python code:

python
from pyhtml import *
def generate_link(ctx):
for title, page in [('Home', '/home.html'),
('Login', '/login.html')]:
yield li(a(href=page)(title))
t = html(
head( title('Demo Pyhtml render') ),
body(
nav(
ul(generate_link)
)
)
)
print (t.render())

Which of the below HTML code will be generated when the above code is executed?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 27

+2 marksOne or more correct options

Consider a flask application given below.

File 1: main.py

python
from flask import Flask
app = Flask(__name__)
@app.route('/about', methods=['GET'])
def hello_world():
return '<p>Hello, World!</p>'
@app.route('/home/', methods=['POST'])
def home():
return '<h1>You are now on home page</h1>'
if __name__=='__main__':
app.run(debug=True)

Which of the following statements is/are true, if the above flask application is running on the URL “http://127.0.0.1:5000/”?

Select all that apply.

  1. A

    Whenever we hit the URL “http://127.0.0.1:5000/about/”, the browser will show “404 Not found” error.

  2. B

    Whenever we hit the URL “http://127.0.0.1:5000/about/”, the browser will display “Hello, World!”.

  3. C

    Whenever we hit the URL “http://127.0.0.1:5000/home/” using the browser, it will show “Method Not Allowed” error.

  4. D

    Whenever we hit the URL “http://127.0.0.1:5000/home/” using the browser, it will display “You are now on home page”.

Show answer

Correct answers

Question 28

+2 marksOne or more correct options

Which of the following statements is/are true about Sessions and Cookies?

Select all that apply.

  1. A

    Cookies are stored in the browser.

  2. B

    Sessions are client-side files that contain user information.

  3. C

    A cookie is dependent on the session, but a session is not dependent on the cookie.

  4. D

    A session is dependent on the cookie, but a cookie is not dependent on the session.

Show answer

Correct answers

  • A

    Cookies are stored in the browser.

  • D

    A session is dependent on the cookie, but a cookie is not dependent on the session.

Question 29

+2 marksOne or more correct options

Consider the following Python file and a templating file given below:

Python file: main.py

python
from flask import Flask, render_template, request, redirect
app = Flask(__name__)
@app.route('/my_route')
def My_form():
return render_template('my_form.html')
@app.route('/home', methods = ['POST', 'GET'])
def home():
if request.method == 'POST':
fav_lang = request.form['num']
return redirect(f"/{fav_lang}")
@app.route('/<fav_lang>')
def demo(fav_lang):
return f"I am comfortable with {fav_lang}."
if __name__=='__main__':
app.run(debug=True)

templates file: my_form.html

html
<!DOCTYPE html>
<html>
<body>
<h2>This is a form</h2>
<form action='/home' method='POST'>
<h3>Your favorite programming language: <input type = 'text'
name = 'num' /></h3>
<p><input type = 'submit' value = 'Submit' /></p>
</form>
</body>
</html>

Suppose the above application is running on URL “ http://127.0.0.1:5000/”, which of the following statements is/are true?

Select all that apply.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answers

  • B
  • D

Question 30

+3 marksOne or more correct options

A Python file and two HTML files are given below.

File 1: main.py

python
from flask import Flask, render_template, make_response, request
app=Flask(__name__)
@app.route('/home')
def myHome():
return render_template('form.html')
@app.route('/setmycookie', methods = ['GET', 'POST'])
def setMyCookie():
if request.method == 'POST':
input = request.form['name1']
res = make_response(render_template('index.html'))
res.set_cookie('Fruit', input)
return res
@app.route('/getmycookie')
def getMyCookies():
val= request.cookies.get('Fruit')
return 'My favorite fruit is '+ val
if __name__ == '__main__':
app.run(debug=True)

File 2: form.html

html
<!DOCTYPE html>
<head>
</head>
<html>
<body>
<form action = '/setmycookie' method = 'POST'>
<h3>Your Input: <input type = 'text' name = 'name1'/></h3>
<h3><input type = 'submit'</h3>
</form>
</body>
</html

File 3: index.html

html
<!DOCTYPE html>
<head>
</head>
<html>
<body>
<h1> Cookies are now being set.</h1>
</body>
</html>

Which of the following statements is/are true, if the above application is running on URL the “http://127.0.0.1:5000”?

Select all that apply.

  1. A

    Whenever we hit the URL ‘http://127.0.0.1:5000/’, a form with one input field will get open.

  2. B

    On the URL ‘http://127.0.0.1:5000/home’, when we click on submit button after filling the form, it will display “Cookies are now being set.” on the webpage.

  3. C

    Whenever we submit the form, it will remain on the URL ‘/home’ itself.

  4. D

    Whenever we give ‘Apple’ as input to the form, thus on hitting the URL
    ‘http://127.0.0.1:5000/getmycookie’, it will show ‘My favorite fruit is Apple’ on the screen.

Show answer

Correct answers

  • B

    On the URL ‘http://127.0.0.1:5000/home’, when we click on submit button after filling the form, it will display “Cookies are now being set.” on the webpage.

  • D

    Whenever we give ‘Apple’ as input to the form, thus on hitting the URL
    ‘http://127.0.0.1:5000/getmycookie’, it will show ‘My favorite fruit is Apple’ on the screen.

Question 31

+3 marksNumerical answer

A certain internet connection is established such that its bandwidth reduces by half of its original value every hour. A user connects to this connection at 12 noon with the network speed of 2 Mbps, how much data (in GBs) will be consumed by the user by 5 p.m in the evening? [round off upto 2 decimal places](Assume that the user is using the entire bandwidth)

Show answer

Correct answer: 1.745 (accepted within ±0.005)

Question 32

+3 marksNumerical answer

A sorting method employs O(nlog(n)) algorithmic complexity and to sort 100 data items it spends exactly 1 millisecond. Calculate the time (in sec) taken by this sorting method to sort 10⁵ items (take 10 as base for all logarithmic functions).
NOTE: Enter your answer in one decimal place.

Show answer

Correct answer: 2.5