Quiz Space

January 2023 term · Modern Application Development II · BSCS2006

MAD 2 End Term: 30 April 2023, Set QPD1-S2 (January 2023 term)

The IIT Madras BS Modern Application Development II (MAD 2) End Term paper sat on 30 Apr 2023, in the January 2023 term, set QPD1-S2: 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
MSQ
10
MCQ
22

Updated

Official paper: IIT M DIPLOMA ET1 EXAM QPD1 S2 30 Apr 2023 · No negative marking.

Question 1

+2 marksOne or more correct options

Which of the following statement(s) is/are false regarding javascript language?

Select all that apply.

  1. A

    Hoisting moves the declaration of arrow functions to the top of their scopes.

  2. B

    All 3 keywords, i.e., “var”, “let” and “const” can be used to declare global variables.

  3. C

    The functions are treated as first class citizens in the language.

  4. D

    Node.js is an example of a javascript engine.

Show answer

Correct answers

  • A

    Hoisting moves the declaration of arrow functions to the top of their scopes.

  • D

    Node.js is an example of a javascript engine.

Question 2

+2 marksOne or more correct options

Which of the following statement(s) is/are true about cookies and CORS?

Select all that apply.

  1. A

    A session cookie expires as soon as the browser is closed.

  2. B

    The CORS mechanism reduces the chances of malicious actions by explicitly saying which URLs can be the originators of data.

  3. C

    A browser sandbox causes any browser based malware to directly affect the user’s system.

  4. D

    All of these

Show answer

Correct answers

  • A

    A session cookie expires as soon as the browser is closed.

  • B

    The CORS mechanism reduces the chances of malicious actions by explicitly saying which URLs can be the originators of data.

Question 3

+2 marksOne or more correct options

Select all that apply.

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

Correct answers

  • B
  • D

Question 4

+2 marksOne or more correct options

Which of the following statement(s) is/are false about pub/sub messaging?

Select all that apply.

  1. A

    Publisher has to know about all the subscribers.

  2. B

    Publisher does not have to know about the subscribers.

  3. C

    Communication between publisher and subscribers is asynchronous.

  4. D

    Communication between publishers and subscribers is synchronous.

Show answer

Correct answers

  • A

    Publisher has to know about all the subscribers.

  • D

    Communication between publishers and subscribers is synchronous.

Question 5

+2 marksOne or more correct options

Which of the following statement(s) is/are false?

Select all that apply.

  1. A

    In short polling, the server does not respond until the data is available or the request times out.

  2. B

    In long polling, the server does not respond until the data is available or the request times out.

  3. C

    In short polling, the server responds immediately with or without data.

  4. D

    In long polling, the server responds immediately with or without data.

Show answer

Correct answers

  • A

    In short polling, the server does not respond until the data is available or the request times out.

  • D

    In long polling, the server responds immediately with or without data.

Question 6

+3 marksOne correct option

Which of the following shows the correct output if the javascript program written below is executed?

  1. A

    [25, 121, 289]

  2. B

    [25, 121]

  3. C

    25

  4. D

    25 121

Show answer

Correct answer

  • C

    25

Question 7

+3 marksOne correct option

Which of the following statements is true in the context of REST?

  1. A

    Both the HTTP request methods, “GET” and “POST” are idempotent.

  2. B

    In general, an HTTP “PUT” request is used to make incremental changes to an existing resource.

  3. C

    A “DELETE” request, that deletes a resource using a unique identifier, is idempotent.

  4. D

    None of these

Show answer

Correct answer

  • C

    A “DELETE” request, that deletes a resource using a unique identifier, is idempotent.

Question 8

+3 marksOne correct option

Which of the following shows the correct output if the javascript program written below is executed?

javascript
async function demo () {
let prom = new Promise((res, rej) => {
setTimeout(() => res(40), 2000)
})
console.log("Statement 2") // Statement 2
return prom
}
demo().then(result => console.log(result))
console.log("Statement 1") // Statement 1
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 9

+3 marksOne correct option

Which of the following statements is false regarding a message broker?

  1. A

    A message broker allows two servers in a network to directly communicate with each other, without an intermediary.

  2. B

    A message broker makes the network scalable for adding more servers to the network.

  3. C

    A message broker can be used for batch processing of messages.

  4. D

    A message broker is well suited in case of traffic spikes, as messages are retained in the queue until processed.

Show answer

Correct answer

  • A

    A message broker allows two servers in a network to directly communicate with each other, without an intermediary.

Question 10

+3 marksOne correct option

Which of the following statement(s) is incorrect regarding the prototype in JavaScript?

  1. A

    Every constructor function has a property named ‘prototype’.

  2. B

    Any object created using the new keyword and the constructor function, will inherit from the constructor’s prototype object.

  3. C

    Prototype of an object can be accessed using the ‘__proto__’ property of the object.

  4. D

    The prototype of an object can be accessed using the ‘prototype’ property of the object.

Show answer

Correct answer

  • D

    The prototype of an object can be accessed using the ‘prototype’ property of the object.

Question 11

+3 marksOne correct option

Consider the below application with markup “index.html” and javascript file “app.js”.

index.html:

html
<body>
<div id="app"></div>
<script
src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="app.js" type="module"></script>
</body>

app.js:

javascript
const Player = {
template: `<div><div>{{striker.name}}*</div>
<div>{{nonStriker.name}}</div>
</div>`,
data() {
return {
player1: {name: 'Rohit'},
player2: {name: 'Virat'},
}
},
props: {
run: { type: Number, default: 0 },
},
computed: {
striker() {
return this.run % 2 == 0 ? this.player1 : this.player2
},
nonStriker() {
return this.run % 2 == 1 ? this.player1 : this.player2
},
},
}
const Run = {
template: `<button @click="$emit('run-changed',
run)">{{run}}</button>`,
props: { run: Number },
}
new Vue({
el: '#app',
template: `<div>
<Player :run='score'/>
<div style='display: flex'>
<Run :run="3" @run-changed = 'runChanged'/>
<Run :run="4" @run-changed = 'runChanged' />
</div>
</div>`,
components: { Run, Player },
data: {
score: 0,
},
methods: {
runChanged(run) {
this.score = run
},
},
})

Suppose the user clicks on buttons with text “3” and then “4”, what will be rendered inside the “Player” component?

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

Correct answer

  • A

Question 12

+3 marksOne correct option

Consider the below application with markup “index.html” and javascript file “app.js”.

index.html:

html
<div id="app"></div>
<script
src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script
src="https://unpkg.com/vue-router@3.0.0/dist/vue-router.js"></script>
<script src="app.js" type="module"></script>

app.js:

javascript
const data = {
1: { totalRun: 1000, totalMatches: 20 },
2: { totalRun: 7000, totalMatches: 100 },
}
const NotFound = { template: `<div> Player Not Found</div>` }
const Profile = {
template: `<div>Run: {{stat.totalRun}}, Matches:
{{stat.totalMatches}}, Average: {{average}}</div>`,
data() {
return {
stat: data[this.$route.params.id],
}
},
computed: {
average() {
return this.stat.totalRun / this.stat.totalMatches
},
},
}
const router = new VueRouter({
routes: [
{ path: '/profile/:id', component: Profile },
{ path: '*', component: NotFound },
],
})
new Vue({
el: '#app',
template: '<div><router-view /></div>',
router,
})

Suppose the application is running on “http://127.0.0.1:8080”. What will be rendered inside the “router-view” component for the URL “http://127.0.0.1:8080/#/player”?

  1. A

    Player Not Found

  2. B

    Run: 1000, Matches: 20, Average: 50

  3. C

    Run: 7000, Matches: 100, Average: 70

  4. D

    None of these

Show answer

Correct answer

  • A

    Player Not Found

Question 13

+3 marksOne correct option

Consider the below application with markup “index.html” and javascript file “app.js”.

index.html:

html
<div id="app"></div>
<script
src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script
src="https://unpkg.com/vue-router@3.0.0/dist/vue-router.js"></script>
<script src="app.js" type="module"></script>

app.js:

javascript
const data = {
1: { totalRun: 1000, totalMatches: 20 },
2: { totalRun: 7000, totalMatches: 100 },
}
const NotFound = { template: `<div> Player Not Found</div>` }
const Profile = {
template: `<div>Run: {{stat.totalRun}}, Matches:
{{stat.totalMatches}}, Average: {{average}}</div>`,
data() {
return {
stat: data[this.$route.params.id],
}
},
computed: {
average() {
return this.stat.totalRun / this.stat.totalMatches
},
},
}
const router = new VueRouter({
routes: [
{ path: '/profile/:id', component: Profile },
{ path: '*', component: NotFound },
],
})
new Vue({
el: '#app',
template: '<div><router-view /></div>',
router,
})

Suppose the application is running on “http://127.0.0.1:8080”. What will be displayed for the URL “http://127.0.0.1:8080/#/profile/1”?

  1. A

    Player Not Found

  2. B

    Run: 1000, Matches: 20, Average: 50

  3. C

    Run: 7000, Matches: 100, Average: 70

  4. D

    None of these

Show answer

Correct answer

  • B

    Run: 1000, Matches: 20, Average: 50

Question 14

+3 marksOne correct option

Consider the below application with markup “index.html” and javascript file “app.js”.

index.html:

html
<body>
<div id="app"></div>
<script
src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script
src="https://unpkg.com/vue-router@3.0.0/dist/vue-router.js"></script>
<script src="app.js" type="module"></script>
</body>

app.js:

javascript
const overs = {
1: [2, 3, 4, 6, 2],
2: [3, 2, 5, 3, 1],
}
const NotFound = { template: `<div> Over Not Found</div>` }
const MatchNotStarted = { template: `<div>Match has not yet started.
</div>` }
const currentOver = {
template: `<div style='display: flex'>
<div v-for='run in over' style='padding: 10px'>{{run}}</div>
</div>`,
data() {
return {
over: overs[this.$route.params.overNo]
? overs[this.$route.params.overNo]
: overs[2],
}
},
}
const liveScore = {
template: `<div>Total Score:{{totalScore}} <router-view /></div>`,
data() {
return {
totalScore: 100,
}
},
}
const router = new VueRouter({
routes: [
{
path: '/live-score',
component: liveScore,
children: [
{ path: '', component: MatchNotStarted },
{ path: 'over/:overNo', component: currentOver },
],
},
],
})
new Vue({
el: '#app',
template: `<div><router-view /></div>`,
router,
})

Suppose the application is running on “http://127.0.0.1:8080”. What will be rendered in the “router-view” component of the “live-score” component for URL “http://localhost:8080/#/live-score”?

  1. A

    Total Score:100

  2. B

    Match has not yet started.

  3. C

    2 3 4 6 2

  4. D

    Over Not Found

Show answer

Correct answer

  • B

    Match has not yet started.

Question 15

+3 marksOne correct option

Consider the below application with markup “index.html” and javascript file “app.js”.

index.html:

html
<body>
<div id="app"></div>
<script
src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script
src="https://unpkg.com/vue-router@3.0.0/dist/vue-router.js"></script>
<script src="app.js" type="module"></script>
</body>

app.js:

javascript
const overs = {
1: [2, 3, 4, 6, 2],
2: [3, 2, 5, 3, 1],
}
const NotFound = { template: `<div> Over Not Found</div>` }
const MatchNotStarted = { template: `<div>Match has not yet started.
</div>` }
const currentOver = {
template: `<div style='display: flex'>
<div v-for='run in over' style='padding: 10px'>{{run}}</div>
</div>`,
data() {
return {
over: overs[this.$route.params.overNo]
? overs[this.$route.params.overNo]
: overs[2],
}
},
}
const liveScore = {
template: `<div>Total Score:{{totalScore}} <router-view /></div>`,
data() {
return {
totalScore: 100,
}
},
}
const router = new VueRouter({
routes: [
{
path: '/live-score',
component: liveScore,
children: [
{ path: '', component: MatchNotStarted },
{ path: 'over/:overNo', component: currentOver },
],
},
],
})
new Vue({
el: '#app',
template: `<div><router-view /></div>`,
router,
})

Suppose the application is running on “http://127.0.0.1:8080”. What will be rendered in the “router-view” component of the “live-score” component for URL “http://localhost:8080/#/live-score/over/2”?

  1. A

    Total Score:100

  2. B

    Match has not yet started.

  3. C

    2 3 4 6 2

  4. D

    3 2 5 3 1

Show answer

Correct answer

  • D

    3 2 5 3 1

Question 16

+3 marksOne correct option

Consider the below application with markup “index.html” and javascript file “app.js”.

index.html:

html
<body>
<div id="app"></div>
<script
src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script
src="https://unpkg.com/vue-router@3.0.0/dist/vue-router.js"></script>
<script src="app.js" type="module"></script>
</body>

app.js:

javascript
const overs = {
1: [2, 3, 4, 6, 2],
2: [3, 2, 5, 3, 1],
}
const NotFound = { template: `<div> Over Not Found</div>` }
const MatchNotStarted = { template: `<div>Match has not yet started.
</div>` }
const currentOver = {
template: `<div style='display: flex'>
<div v-for='run in over' style='padding: 10px'>{{run}}</div>
</div>`,
data() {
return {
over: overs[this.$route.params.overNo]
? overs[this.$route.params.overNo]
: overs[2],
}
},
}
const liveScore = {
template: `<div>Total Score:{{totalScore}} <router-view /></div>`,
data() {
return {
totalScore: 100,
}
},
}
const router = new VueRouter({
routes: [
{
path: '/live-score',
component: liveScore,
children: [
{ path: '', component: MatchNotStarted },
{ path: 'over/:overNo', component: currentOver },
],
},
],
})
new Vue({
el: '#app',
template: `<div><router-view /></div>`,
router,
})

Suppose the application is running on “http://127.0.0.1:8080”. What will be rendered in the “router-view” component of the “live-score” component for URL “http://localhost:8080/#/live-score/over/20”?

  1. A

    Total Score:100

  2. B

    Match has not yet started.

  3. C

    2 3 4 6 2

  4. D

    3 2 5 3 1

Show answer

Correct answer

  • D

    3 2 5 3 1

Question 17

+3 marksOne or more correct options

Which of the following is/are not the correct ways to achieve the following.

Select all that apply.

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

Correct answers

  • C
  • D

Question 18

+3 marksOne or more correct options

Which of the following statement(s) is/are false regarding Vuex?

Select all that apply.

  1. A

    A Vuex store provides a single source of truth that can drive the application.

  2. B

    It provides a variable named “this.$vuexstore” to allow components to access the store data.

  3. C

    A component cannot have its own local state, if the application uses Vuex.

  4. D

    The mutations and actions are some constructs of a Vuex store.

Show answer

Correct answers

  • B

    It provides a variable named “this.$vuexstore” to allow components to access the store data.

  • C

    A component cannot have its own local state, if the application uses Vuex.

Question 19

+3 marksOne or more correct options

Which of the following statement(s) is/are false regarding forward and reverse proxy?

Select all that apply.

  1. A

    A forward proxy is used to protect the server(s) from the outside world.

  2. B

    A reverse proxy can be used to cache the responses, to reuse them for similar subsequent requests.

  3. C

    A load balancer becomes irrelevant, where there is not more than 1 server.

  4. D

    An efficient load balancer must use a round-robin algorithm.

Show answer

Correct answers

  • A

    A forward proxy is used to protect the server(s) from the outside world.

  • D

    An efficient load balancer must use a round-robin algorithm.

Question 20

+3 marksOne or more correct options

Suppose you are building an application which requires sending emails to all the users stored in the database at regular intervals. Given below are the two approaches to satisfy the requirement.

Approach 1:

python
@celery.task
def send_bulk_emails():
all_users = User.query.all() // Get all the user objects from the
database
for user in all_users:
// send email to the user
send_bulk_emails.delay() // invokes celery task

Approach 2:

python
@celery.task
def send_email(email):
// send email to the user
all_users = User.query.all() // Get all the user objects from the database
for user in all_users:
send_email.delay(user.email) // invokes celery task

Choose the correct statement(s).

Select all that apply.

  1. A

    Approach 1 will take more time than approach 2, if more than 2 celery workers are available.

  2. B

    Approach 2 will take more time than approach 1, if more than 2 celery workers are available.

  3. C

    Both the approaches will take same time (approx), if only 1 celery worker is available.

  4. D

    None of these

Show answer

Correct answers

  • A

    Approach 1 will take more time than approach 2, if more than 2 celery workers are available.

  • C

    Both the approaches will take same time (approx), if only 1 celery worker is available.

Question 21

+3 marksOne or more correct options

Which of the following statement(s) is/are correct regarding Vue.js framework?

Select all that apply.

  1. A

    In Vue 2, the “el” property of the Vue constructor can be used to refer to an HTML element via an ID or a class.

  2. B

    The components of Vue must define “data” property as a function.

  3. C

    A Vue component cannot implement lifecycle hooks (i.e., created, mounted, etc.), if they are already implemented in the Vue instance.

  4. D

    All of these

Show answer

Correct answers

  • A

    In Vue 2, the “el” property of the Vue constructor can be used to refer to an HTML element via an ID or a class.

  • B

    The components of Vue must define “data” property as a function.

Question 22

+2 marksOne correct option

Which of the following statements is false about VueJS framework?

  1. A

    VueJS is a framework built on top of HTML, CSS and javascript.

  2. B

    VueJS is built on a component based architecture.

  3. C

    It cannot be installed/used via npm (node package manager).

  4. D

    All of these

Show answer

Correct answer

  • C

    It cannot be installed/used via npm (node package manager).

Question 23

+2 marksOne correct option

Which of the following statements is false regarding webhooks?

  1. A

    A webhook should deliver data to other apps, as it happens.

  2. B

    A webhook is primarily meant for a server to server communication.

  3. C

    A webhook typically uses an HTTP POST request to deliver the response.

  4. D

    A webhook and web socket is essentially the same.

Show answer

Correct answer

  • D

    A webhook and web socket is essentially the same.

Question 24

+2 marksOne correct option

Suppose an endpoint in your flask application triggers a celery task, which generates a CSV file named “data.csv” and saves it in the static folder of a flask application. The file generator takes anywhere between 20 and 40 seconds to generate and save the CSV file.
The below fetch call is used to get the file generated by the above explained celery task.

Which of the following is the most efficient way to make the above fetch call so that it doesn’t fail and return the desired response?

  1. A

    Use short polling to check the state of the celery task after every 5 seconds, and make the fetch call, when the task succeeds.

  2. B

    Use javascript function “setTimeout” to make the fetch after 41 seconds, which makes sure that the file is generated and saved to the desired location.

Show answer

Correct answer

  • A

    Use short polling to check the state of the celery task after every 5 seconds, and make the fetch call, when the task succeeds.

Question 25

+4.5 marksOne correct option

Consider the following Vue application with markup “index.html” and javascript file “app.js”.

index.html:

html
<div id = "app">
<my-comp>
<template #header>
This is header content
</template>
<template #footer>
This is footer content
</template>
<p> This is some content </p>
</my-comp>
</div>
<script src = "app.js"> </script>

app.js:

javascript
Vue.component("myComp", {
template : `<div>
<p>
<slot name="header"></slot>
</p>
<p>
<slot></slot>
</p>
</div>
`,
})
const app = new Vue({
el : "#app",
})

Suppose you open the “index.html” file in a browser. What will be rendered by the browser?

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

Correct answer

  • B

Question 26

+4.5 marksOne correct option

Consider the following javascript program, and predict the output if executed.

javascript
new Promise((str1, str2) => {
if (5 == "5") str1(5)
else str2(8)
}).
then(d => {
console.log("Checkpoint 4", d);
throw new Error(20);
return d * 5;
})
.then(d => {
console.log("Checkpoint 2", d);
return d;
}, d => {
console.log("Checkpoint 1", d.message);
return d.message * 2;
}).catch(e => {
console.log("Checkpoint 3", e.message);
return e.message * 2;
}).finally(d => {
console.log("Checkpoint 6", d);
return d * 5;
}).then(d => {
console.log("Checkpoint 5", d);
return d * 5;
})
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 27

+4.5 marksOne correct option

Consider the following Vue application with markup “index.html” and javascript file “app.js”.

index.html:

html
<div id = "app">
<input v-model = "text" @input = "save_data">
<p> {{content}} </p>
</div>
<script scr = "app.js"></script>

app.js:

javascript
new Vue({
el : "#app",
data : {
text : "",
content : "",
},
mounted () {
try {
this.text = localStorage.getItem("value1").split("abhi").slice(1,
-1),join("");
this.content =
localStorage.getItem("value1").split("abhi").slice(1),join("");
}
catch {
this.text = "";
this.content = "";
}
},
methods : {
save_data() {
localStorage.setItem("value1", this.text);
localStorage.setItem("value2", this.content);
}
}
})

Suppose you open “index.html” file in a browser, and type the text “abhishekabhinavabhi” in the text box shown (after removing the previous text, if any), and hard refresh the page twice, without clicking anywhere. What will be the value shown in the text box, and the “age” placeholder, respectively?

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

Correct answer

  • A

Question 28

+4.5 marksOne correct option

Which of the following shows the correct output if the javascript program written below is executed?

javascript
let num = 50
const a = {
num : 10,
func : function (num) {
console.log("Function A:", num)
}
}
const b = {
num : 20,
func : function () {
console.log("Function B:", this.num)
a.func.bind(this)(num = 40)
}
}
b.func.apply(a, [40])
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 29

+4.5 marksOne correct option

Consider the below application with markup “index.html” and javascript file “app.js”.

index.html:

html
<body>
<div id="app"></div>
<script
src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="app.js" type="module"></script>
</body>

app.js:

javascript
new Vue({
el: '#app',
template: `<div>
<ol type='1'>
<li v-for='fruit in fruits'>{{fruit}}</li>
</ol>
</div>`,
data: {
fruits: ['Banana', 'Mango'],
},
created() {
this.fruits.push('Orange')
},
mounted() {
this.fruits.push('Apple')
},
})

Suppose you open the file “index.html” in a browser. What will be rendered by the browser?

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

Correct answer

  • D

Question 30

+4.5 marksOne correct option

Consider the below application with markup “index.html” and javascript file “app.js”.

index.html:

html
<body>
<div id="app"></div>
<script
src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="app.js" type="module"></script>
</body>

app.js:

javascript
const Player = {
template: `<div style='background-color:red'><slot></slot></div>`,
data() {
return {
scores: [
{ name: 'Rohit', run: 20 },
{ name: 'Virat', run: 50 },
],
}
},
}
new Vue({
el: '#app',
template: `<div>
<h1> Score Board</h1>
<Player>
<ol type='1'>
<li v-for='score in scores'>{{score.name}}:
{{score.run}}</li>
</ol>
</Player>
</div>`,
data: {
scores: [
{ name: 'Rohit', run: 50 },
{ name: 'Virat', run: 20 },
],
},
components: {
Player,
},
})

Suppose you open the file “index.html” in a browser. What will be rendered inside the slot, by the browser?

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

Correct answer

  • B

Question 31

+4.5 marksOne correct option

Consider the below flask application.

app.py:

python
from flask import Flask
from flask_caching import Cache
from time import sleep
config = {
"CACHE_TYPE": "RedisCache",
"CACHE_REDIS_URL": 'redis://localhost:6379/1'
}
app = Flask(__name__)
app.config.from_mapping(config)
cache = Cache(app)
@cache.memoize(timeout=120)
def get_score(name):
sleep(10)
return 0
@app.route('/match/<int:match_id>/player/<name>/score')
def score(match_id, name):
score = get_score(name)
return f"IND Vs AUS- SKY: {score}"
if __name__ == '__main__':
app.run(debug=True)

If the Redis server is running on “localhost:6379”, and application is running on “http://127.0.0.1:5000”. If a user visits the URL “http://127.0.0.1:5000/match/1/player/sky/score” at 7AM in the morning for the first time and then at 9AM for the second time. What will be the approximate absolute difference between the response time of the requests?

  1. A

    10 seconds

  2. B

    0 seconds

  3. C

    20 seconds

  4. D

    120 Seconds

Show answer

Correct answer

  • B

    0 seconds

Question 32

+4.5 marksOne correct option

Consider the below flask application.

app.py:

python
from flask import Flask
from flask_caching import Cache
from time import sleep
config = {
"CACHE_TYPE": "RedisCache",
"CACHE_REDIS_URL": 'redis://localhost:6379/1'
}
app = Flask(__name__)
app.config.from_mapping(config)
cache = Cache(app)
@cache.memoize(timeout=120)
def get_score(name):
sleep(10)
return 0
@app.route('/match/<int:match_id>/player/<name>/score')
def score(match_id, name):
score = get_score(name)
return f"IND Vs AUS- SKY: {score}"
if __name__ == '__main__':
app.run(debug=True)

If the Redis server is running on “localhost:6379”, and application is running on “http://127.0.0.1:5000”. If a user visits the URL “http://127.0.0.1:5000/match/1/player/sky/score” first and then “http://127.0.0.1:5000/match/2/player/sky/score” within 2 minutes. What will be the approximate absolute difference between the response time of the requests?

  1. A

    10 seconds

  2. B

    0 seconds

  3. C

    20 seconds

  4. D

    120 Seconds

Show answer

Correct answer

  • A

    10 seconds