Question 1
The hexadecimal representation of the number 3218 is _ .
B1
B2
D1
D2
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.
The hexadecimal representation of the number 3218 is _ .
B1
B2
D1
D2
Correct answer
D1
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.
18
27
9
32
Correct answer
27
Consider the HTML code below.
<!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?
yellow
red
blue
None of these
Correct answer
blue
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.
Specify the requirements on server, database and network connectivity.
Deploy and maintain the application.
Both Specify the requirements on server, database and network connectivity & Deploy and maintain the application.
None of these
Correct answer
Both Specify the requirements on server, database and network connectivity & Deploy and maintain the application.
Identify the system that provides centralized control over distributed patches and provides a friendly interface for Git.
Gitlens
Github
Gitlab
Both Gitlens and Github
Correct answer
Both Gitlens and Github
Consider the code snippet given below.
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?
Correct answer
Consider the code below.
from flask import Flaskfrom 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?
Correct answer
What will the output of the Python code given below?
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@decordef num(): return 1
print(num())1000
1210
10
None of these
Correct answer
1210
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?
Condition coverage
Function coverage
Statement coverage
None of these
Correct answer
Function coverage
Consider the following JavaScript code.
File name : index.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
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
“email verified” and “I am expecting an e-mail address”
“provide me with valid an e-mail address!” and “email verified”
“email verified” and “provide me with valid e-mail address!”
None of these
Correct answer
“email verified” and “provide me with valid e-mail address!”
Consider the following JavaScript code.
File name: script.js
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
<!DOCTYPE html><html> <body> <script src="script.js"></script> </body></html>How will the browser render the above code?
Correct answer
Consider the following table “employee” in SQLite database.
What will be the output of the SQL query given below?
Correct answer
Consider the following HTML and external CSS code.
File name: style.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
<!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?
Correct answer
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?
Correct answer
Consider the following code
File name: app.py
from flask import Flask, render_template, requestapp = 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
<!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?
“Hello Rovan you have access: computer operator”, “Hello Jai you have no access to this site: steno” and “User not found”
“Hello Rovan you have no access to this site: computer operator”, “Hello Jai you have access: steno” and “User not found”
“User not found”, “Hello Rovan you have access: computer operator” and “Hello Jai you have no access to this site: steno”
“User not found”,“Hello Rovan you have no access to this site: computer operator” and “Hello Jai you have access: steno”
Correct answer
“Hello Rovan you have access: computer operator”, “Hello Jai you have no access to this site: steno” and “User not found”
Consider the following JavaScript code.
File name: index.html
<!DOCTYPE html><html> <head> <p> Course name - Course </p> </head> <body> <script src="script.js"></script> </body></html>File name: script.js
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?
course name: course
course name: APP Development
APP Development
course: App Development
Correct answer
course name: APP Development
Consider the following Python code snippet.
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)1011 emp = [ {"name": "ABC", "ProjectID": 1111},12 {"name": "DEF", "ProjectID": 2222},13 {"name": "PQR"},14 {"name": "XYZ"}15 ]1617 print(x.render(employees = emp))Correct answer
Match the status codes responded by server on client request.
a-ii, b-i, c-iii, d-iv
a-ii, b-i, c-iv, d-iii
a-i, b-ii, c-iii, d-iv
a-ii, b-iv, c-iii, d-i
Correct answer
a-ii, b-i, c-iv, d-iii
Consider the code snippet given below.
<!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?
Correct answer
Consider the files given below.
File 1: macros.py
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
{% from "_macros.html" import calc %}<!DOCTYPE html><html> <head> <title> Macros </title> </head> <body> {{ calc(my_list) }}
</body></html>File 3: _macros.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/”?
Correct answer
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]
67 milliseconds
29 milliseconds
79 milliseconds
55 milliseconds
Correct answer
79 milliseconds
Consider the following Python code
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?
Correct answer
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.
Correct answer
Which of the following queries produces the below multi-column indexing?
Correct answer
What will be the output of code snippet given below.
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 = company10 self.model = model1112 def getCompany(self):13 return self.company1415 def getModel(self):16 return self.model1718 c1 = Car("Maruti","ERTIGA")19 c2 = Car("Honda","AMAZE")20 c3 = Car("Tata","NEXON")2122 print(output1.render(c = c1))23 print(output1.render(c = c2))24 print(output1.render(c = c3))Correct answer
Consider the below Python code to generate HTML code:
Python code:
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?
Correct answer
Consider a flask application given below.
File 1: main.py
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/”?
Whenever we hit the URL “http://127.0.0.1:5000/about/”, the browser will show “404 Not found” error.
Whenever we hit the URL “http://127.0.0.1:5000/about/”, the browser will display “Hello, World!”.
Whenever we hit the URL “http://127.0.0.1:5000/home/” using the browser, it will show “Method Not Allowed” error.
Whenever we hit the URL “http://127.0.0.1:5000/home/” using the browser, it will display “You are now on home page”.
Correct answers
Whenever we hit the URL “http://127.0.0.1:5000/about/”, the browser will show “404 Not found” error.
Whenever we hit the URL “http://127.0.0.1:5000/home/” using the browser, it will show “Method Not Allowed” error.
Which of the following statements is/are true about Sessions and Cookies?
Cookies are stored in the browser.
Sessions are client-side files that contain user information.
A cookie is dependent on the session, but a session is not dependent on the cookie.
A session is dependent on the cookie, but a cookie is not dependent on the session.
Correct answers
Cookies are stored in the browser.
A session is dependent on the cookie, but a cookie is not dependent on the session.
Consider the following Python file and a templating file given below:
Python file: main.py
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
<!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?
Correct answers
A Python file and two HTML files are given below.
File 1: main.py
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 '+ valif __name__ == '__main__': app.run(debug=True)File 2: form.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></htmlFile 3: index.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”?
Whenever we hit the URL ‘http://127.0.0.1:5000/’, a form with one input field will get open.
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.
Whenever we submit the form, it will remain on the URL ‘/home’ itself.
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.
Correct answers
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.
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.
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)
Correct answer: 1.745 (accepted within ±0.005)
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.
Correct answer: 2.5