Questions and published explanations below are available without starting a test. Some questions may not have a published solution yet.
15 / 16 published solutions
Question 2 MCQ · 2.0 marks
You want to create an app where students can log in and download hall tickets. To make this more
efficient, you want to have some very quick way to check whether a given user has already
downloaded their hall ticket or not. Which kind of database will you prefer?
6406536626931.
RDBMS
6406536626932.
Doc-oriented database
6406536626933.
Graph database
6406536626934.
Key-value store
Published solution
**1. Identify the requested access pattern:** The app needs a quick lookup of one small fact using a student/user identifier: has this user downloaded the ticket? This naturally maps to user_id→downloaded_flag.
**2. Match the data model:** A key–value store is designed for direct retrieval by key, without joining tables, traversing relationships or searching a document structure.
**3. Limit the recommendation:** This is the most suitable offered store for the isolated flag lookup. The rest of a hall-ticket application can still use relational storage and access controls; an indexed RDBMS can also perform this lookup efficiently.
**Answer: D — Key-value store.**
A: **Incorrect:** An indexed relational table can work well, but its richer relational model is not required for the narrow flag lookup asked here.
B: **Incorrect:** Document structure is unnecessary for a single keyed status value.
C: **Incorrect:** Graph traversal offers no advantage for this direct identifier-to-flag access pattern.
D: **Correct:** A user identifier can directly index the downloaded-status value.
Which of the following enables asynchronous communication between client and server without
loading the entire web page?
6406536626951.
CGI
6406536626952.
FTP
6406536626953.
SMTP
6406536626954.
AJAX
Published solution
**1. Identify the browser interaction:** The client needs to request or send data in the background while keeping the currently loaded page. JavaScript can update only the relevant UI afterward.
**2. Match the term:** AJAX is the conventional name for this asynchronous browser–server interaction, historically using XMLHttpRequest and now also commonly implemented with fetch. The transferred data need not be XML.
**Answer: D — AJAX.**
A: **Incorrect:** CGI is a server-side interface for running programs, not the browser technique for partial-page asynchronous updates.
B: **Incorrect:** FTP transfers files and is not the intended browser-page communication mechanism.
C: **Incorrect:** SMTP transfers email rather than making interactive background web requests.
D: **Correct:** AJAX enables asynchronous requests and page updates without a full reload.
**1. Read the query parameters:** The URL supplies user=Alice and role=ADMIN, so the defaults Guest and Member are not used.
**2. Apply the transformations:** username.upper() becomes ALICE; role.lower() becomes admin. These transformed values are supplied to the Template placeholders name and role_type.
**3. Substitute the text:** The template becomes “Hello ALICE! Your role is admin.” The placeholder name role_type does not need to be a URL parameter because it is explicitly supplied to substitute().
**Answer: D — Hello ALICE! Your role is admin..**
A: **Incorrect:** role_type is provided as a substitution keyword, so it need not appear in the URL.
B: **Incorrect:** The URL supplies both values, and the code also applies uppercase to the username.
C: **Incorrect:** This leaves both original capitalizations unchanged, ignoring the transformations.
D: **Correct:** It applies both requested transformations and substitutes the correct placeholders.
Which of the following is the correct output of the above code?
6406536626943.
56
6406536626944.
11
6406536626945.
6
6406536626946.
30
Published solution
**1. Apply the decorator:** @modify replaces the name bar with wrapper, which retains access to the original multiplication function as func.
**2. Trace bar(2,3):** wrapper receives p=2,q=3 and calls the original function, producing 2×3=6.
**3. Apply the wrapper’s return:** It returns result+5=6+5=11. This is numeric addition, not string concatenation or multiplication by five.
**Answer: B — 11.**
A: **Incorrect:** The numbers are numeric, so six and five are added rather than concatenated into 56.
B: **Correct:** The underlying product six is increased by five to give eleven.
C: **Incorrect:** Six is the intermediate multiplication result before the wrapper adds five.
D: **Incorrect:** The wrapper adds five; it does not multiply the product by five.
A server has a 16-core CPU, 64 GB RAM and 1 Gbps network connection. The server is running a
single instance of an app that can generate a maximum of 500 HTML pages per second, each of
which results in a 100KB image to be downloaded by the client. What is the maximum number of
requests per second that can be handled by this setup?
6406536626947.
10,000
6406536626948.
1250
6406536626949.
1000
6406536626950.
500
Published solution
**1. Compute the image-transfer ceiling:** Using decimal networking units, 1 Gbps is \(10^9/8=125{,}000{,}000\) bytes/s. A 100-KB image is 100,000 bytes, allowing at most 1250 image transfers/s if other traffic is ignored.
**2. Compare application throughput:** The single running application can generate only 500 pages/s. The overall rate cannot exceed either its processing capacity or the network capacity.
**3. Select the bottleneck:** \(\min(500,1250)=500\) page requests/s in the given simplified model. More CPU cores do not multiply the explicitly stated single-instance capacity automatically.
**Answer: D — 500.**
**Convention note:** This uses the question’s simplified model in which page-processing and image-transfer ceilings are compared; HTML size, protocol overhead and other resource contention are not quantified.
A: **Incorrect:** This exceeds both the stated application capacity and the estimated image-transfer ceiling.
B: **Incorrect:** 1250 is the image-only network ceiling, but the app is limited to 500 pages/s.
C: **Incorrect:** The application cannot generate 1000 pages/s under the supplied capacity.
D: **Correct:** The application’s 500-page/s capacity is the tighter stated limit.
A web server is connected to a 5Mbps network line. Each HTTP request contains 4KB of header
information and 6KB of payload. What is the maximum number of requests per second the web
server can support?(Note: 1KB=1000B, 1MB=1000KB and so on)
6406536626955.
500
6406536626956.
62
6406536626957.
124
6406536626958.
31
Published solution
**1. Count request bytes:** Headers and payload total \(4+6=10\) KB, or 10,000 bytes using the stated decimal units.
**2. Convert to bits:** Each request uses \(10{,}000(8)=80{,}000\) bits. A 5-Mbps link supplies 5,000,000 bits/s.
**3. Divide and choose the offered integer:** \(5{,}000{,}000/80{,}000=62.5\) requests/s as an ideal average bandwidth rate. The largest offered whole number below that ceiling is 62.
**Answer: B — 62.**
**Convention note:** The bandwidth-derived long-run ideal rate is 62.5 requests/s. The listed answer 62 treats the result as a whole-request-per-second budget and excludes additional protocol/response overhead.
A: **Incorrect:** It ignores the necessary byte-to-bit conversion and exceeds the link budget.
B: **Correct:** 62 complete requests use 4,960,000 bits, below the 5-Mbps budget; 63 would exceed it in a one-second budget.
C: **Incorrect:** 124 requests would require approximately twice the available bandwidth.
D: **Incorrect:** 31 is below the attainable ideal ceiling and is not the maximum offered feasible count.
**1. List the competing declarations:** The element matches the p rule (blue), .text class (green), and #para ID (red). It also carries the inline declaration style="color:black".
**2. Apply the cascade:** For these ordinary author declarations with no !important, the inline declaration overrides the stylesheet selector declarations. ID specificity does not override that normal inline style.
**3. State the rendering:** The text “IITM BS Degree Program” appears in black. Its wording is unchanged; only the winning colour is being selected.
**Answer: C — IITM BS Degree Program in black.**
A: **Incorrect:** The ID rule would beat the class/type rules, but it loses to the supplied inline colour.
B: **Incorrect:** The class rule does not override the ID rule or the inline declaration.
C: **Correct:** The normal inline color:black declaration wins among the shown rules.
D: **Incorrect:** The type-selector rule has the lowest specificity among the competing stylesheet rules and also loses to inline styling.
You have a DRAM module with bus width of 64 bits, clock speed of 1 GHz, and operating in DDR
(double-data-rate or two values per clock cycle) mode. What is the maximum bandwidth (in Giga-
bytes per second) of data transfer achievable with this module?
6406536626989.
8 GigaBytes/s
6406536626990.
16 GigaBytes/s
6406536626991.
24 GigaBytes/s
6406536626992.
None of these
Published solution
**1. Convert bus width:** A 64-bit transfer carries \(64/8=8\) bytes.
**2. Include DDR:** At one billion clock cycles per second and two transfers per cycle, the rate is \(2\times10^9\) transfers/s.
**3. Calculate bandwidth:** \(8(2\times10^9)=16\times10^9\) bytes/s, or 16 decimal GB/s. This is the theoretical bus ceiling rather than a guaranteed sustained application bandwidth.
**Answer: B — 16 GigaBytes/s.**
A: **Incorrect:** Eight GB/s counts only one transfer per cycle and omits DDR’s factor of two.
B: **Correct:** Eight bytes per transfer times two billion transfers per second gives sixteen GB/s.
C: **Incorrect:** The specification supplies two transfers per cycle, not three.
D: **Incorrect:** The correct sixteen-GB/s value is explicitly offered.
**1. Recognize Flask variable syntax:** Angle brackets declare a dynamic path component. /user/id is a literal path and does not capture the value 55.
**2. Check compatible converters:** /user/<int:id> accepts the integer-looking segment 55 and converts it to an integer. /user/<id> uses the default string converter, which also accepts the text “55”.
**3. Check the float route precisely:** The standard Werkzeug float converter requires a decimal-form path such as 55.0. The literal integer segment 55 does not match it, even though Python could convert the string to float manually.
**Answer: B, C — /user/<int:id> and /user/<id>.**
A: **Incorrect:** Without angle brackets, id is a literal part of the URL rather than a variable.
B: **Correct:** The int converter matches 55 and provides the handler with integer 55.
C: **Correct:** The default string converter matches the nonempty segment and provides string "55".
D: **Incorrect:** The standard float converter does not match the exact integer-only path /user/55; /user/55.0 is a different path.
**1. Identify the route’s shape:** /user/<name> matches one nonempty path segment after /user/. Its default converter is string, so both letters and digits are allowed.
**2. Check the valid URLs:** /user/IITM supplies name="IITM" and /user/101 supplies name="101". /user/BS?id=101 matches the path with name="BS"; the query string does not change route matching.
**3. Reject path mismatches:** /user/10/greet adds an unhandled segment, while /user supplies no required name segment. Neither matches this sole route.
**Answer: A, B, E — **http://127.0.0.1:5000/user/IITM**; **http://127.0.0.1:5000/user/101**; **http://127.0.0.1:5000/user/BS?id=101**.**
A: **Correct:** IITM is a valid single string segment and renders Welcome IITM.
B: **Correct:** Digit characters also form a valid string name and render Welcome 101.
C: **Incorrect:** The extra /greet segment is not included in the route.
D: **Incorrect:** The required name path component is missing.
E: **Correct:** The path captures BS; the unrelated query parameter does not prevent a match.
Consider the following HTML and Python Flask code.
6406536626963.
Output is: 3
6406536626964.
Output is:
6406536626965.
Output is: 1 2 3
6406536626966.
Output is: 1 2 3 3
Published solution
**1. Locate the assignment:** Each iteration executes {% set x = i %}, but the assignment occurs inside Jinja’s loop scope. The template does not initialize an outer x or use a namespace.
**2. Follow scope exit:** The loop-local x values do not survive as an outer variable after endfor. Therefore the later {{ x }} refers to an undefined value.
**3. Apply default rendering:** Flask’s ordinary Jinja undefined handling renders that missing variable as an empty string. The visible output is only “Output is:”, ignoring layout whitespace.
**Answer: B — Output is:.**
**Convention note:** An environment configured with StrictUndefined would raise an undefined-variable error instead. The supplied Flask setup uses the normal default undefined rendering.
A: **Incorrect:** Loop assignments do not leak the final value three into the outer scope.
B: **Correct:** The outside variable is undefined and renders blank under the default Jinja environment.
C: **Incorrect:** The loop contains assignments, not expressions printing i on each iteration.
D: **Incorrect:** Neither the loop values nor a final outer three are printed.
What will be the output in the console window when the above HTML doc is rendered on the
browser ?
6406536626993.
1
6406536626994.
2
6406536626995.
3
6406536626996.
4
Published solution
**1. Identify the returned collection:** getElementsByTagName("li") returns a live HTMLCollection. Initially it contains the one existing list item.
**2. Apply innerHTML +=:** The script replaces the list contents with the old markup plus two new li elements. The list consequently contains App Dev-1, App Dev-2 and App dev projects.
**3. Read the live length:** Because the collection tracks current matching DOM elements, lst_items.length is now three and the console prints 3. A static snapshot would behave differently.
**Answer: C — 3.**
A: **Incorrect:** One is the old count; the collection is live and reflects the added elements.
B: **Incorrect:** Two counts only the appended items and omits the original item still in the resulting markup.
C: **Correct:** The resulting document contains three li elements and the live collection reports three.
D: **Incorrect:** Only two items are appended to the original one, not three.
curl -X POST --json '{"uid":"admin","pwd":"12345"}' http://127.0.0.1:5000/login
Published solution
**1. Inspect permitted methods:** @app.route("/login",methods=["POST"]) accepts POST for this handler. An ordinary browser address-bar navigation sends GET and is not permitted.
**2. Inspect curl’s explicit methods:** -X GET overrides the request method even with --json, so B receives 405 Method Not Allowed. A and E explicitly send POST and reach the credentials check.
**3. Inspect curl’s implicit method:** --json sends request data and selects POST when no overriding method is given, so D also uses POST. Wrong credentials in A produce the application’s “Invalid credentials...” response, not a method error.
**Answer: B, C — curl -X GET --json '{"uid":"admin","pwd":"xyz"}' http://127.0.0.1:5000/login; URL request: http://127.0.0.1:5000/login.**
A: **Incorrect:** It uses the allowed POST method; the wrong password affects credentials, not method permission.
B: **Correct:** -X GET explicitly chooses a method not allowed by the route, yielding 405.
C: **Correct:** Opening that URL normally sends GET and yields 405 for this POST-only route.
D: **Incorrect:** With --json and no explicit override, curl sends POST, so the route is allowed.
E: **Incorrect:** It explicitly sends POST with the expected credentials and does not produce a method error.
**1. Match the route argument:** The registered resource URL contains <int:id>, so Flask-RESTful passes an id keyword argument to the selected HTTP-method handler. The handler signature must accept it.
**2. Check supported method names:** A get(self,id) method handles GET and a post(self,id) method handles POST. Either can perform the shown search when requested with its corresponding method.
**3. Follow the search logic:** The valid methods compare p["id"] against the received integer, return the matching formatted product and otherwise return the not-found text. Methods missing id fail to accept the route parameter.
**Answer: B, D — B and D — handlers accepting id for their respective HTTP methods.**
**Convention note:** Selecting a POST handler means the client must send POST; an ordinary browser GET will not call it. The question asks which inserted implementations can work, rather than requiring both to support GET.
A: **Incorrect:** post(self) lacks id, so dispatch passes an unexpected id keyword and the handler cannot run correctly.
B: **Correct:** get(self,id) accepts the route argument and handles a GET lookup.
C: **Incorrect:** get(self) similarly fails to accept the id supplied by the resource route.
D: **Correct:** post(self,id) accepts the argument and correctly searches for a POST lookup.
Based on the above data, answer the given subquestions.
Which of the following relationships exists between the “User” and “Profile” models?
6406536626977.
Many-to-Many
6406536626978.
Many-to-One
6406536626979.
One-to-Many
6406536626980.
One-to-One
Published solution
**1. Read the scalar relationship:** User.profile sets uselist=False, so accessing that attribute produces one Profile object or None instead of a list.
**2. Read the database restriction:** Profile.user_id is both a foreign key to User.id and unique. The uniqueness prevents two non-null profile rows from referencing the same user.
**3. Combine the constraints:** This is the intended one-to-one mapping: at most one linked profile per user, and one user for a non-null linked profile. The declarations do not require every user to already have a profile.
**Answer: D — One-to-One.**
A: **Incorrect:** There is no many-to-many association table or collection on both sides.
B: **Incorrect:** A unique user_id prevents multiple profiles from sharing one non-null user reference.
C: **Incorrect:** The User side is scalar and the foreign key is unique, so it is not a collection of multiple profiles.
D: **Correct:** uselist=False plus the unique foreign key implements the one-to-one mapping.