MauryaHub PYQ Practice

Application Development - 1 · Quiz 2 · May 2026

Application Development - 1 · Quiz 2 · May 2026

← Course papers · Start practice / exam

Questions and published explanations below are available without starting a test. Some questions may not have a published solution yet.

16 / 16 published solutions

Question 2 MCQ · 3.0 marks

Consider the Flask SQLAlchemy data model.
Source diagram or notation
What is the output after the following Python code is executed ? (Assume all entries are successfully committed to the database)
Source diagram or notation
6406537086409.
4
6406537086410.
3
6406537086411.
2
6406537086412.
1

Published solution

**1. Read the LIKE pattern:** User.mail_id.like("p%") matches strings beginning with p, followed by zero or more characters. It does not search for p anywhere in the address; a contains search would use %p%. **2. Check all inserted addresses:** abc@gmail.com, lmn@gmail.com and opqrst@gmail.com do not begin with p. Only pxyz@gmail.com does. In particular, the p inside opqrst is not at the start. **3. Count the returned rows:** all() creates a list containing that one User object, so len(result) is 1. The unique and not-null column constraints do not change this filtering result. **Answer: D — 1.** A: **Incorrect:** Not every inserted address begins with p. B: **Incorrect:** Only one address, not three, matches the prefix. C: **Incorrect:** The embedded p in opqrst does not match a leading-p pattern. D: **Correct:** pxyz@gmail.com is the sole matching row.

Report a correction for Q2

Question 3 MCQ · 3.0 marks

Consider the SQLAlchemy model **Order** mapped to the table **orders**.
Source diagram or notation
6406537086429.Source diagram or notation
6406537086430.Source diagram or notation
6406537086431.Source diagram or notation
6406537086432.Source diagram or notation

Published solution

**1. Translate the two SQL conditions:** The query requires status="PAID" and amount>500 on the same Order row. The paid order of amount 500 is excluded because the comparison is strict. **2. Combine filters with SQLAlchemy:** Chaining .filter(Order.status=="PAID").filter(Order.amount>500) accumulates both criteria with SQL AND. It selects order IDs 3 and 5, with amounts 800 and 1200. **3. Distinguish SQL AND from Python and/or:** Python and/or evaluate operand truth values while building the expression; they do not construct SQL conjunctions. For these equality expressions, the other choices either lose a condition or return a different query/expression. **4. Recognize another valid form:** Although not listed, .filter(Order.status=="PAID", Order.amount>500) or an explicit and_(...) would also express the intended conjunction. **Answer: B — chain filter(status == "PAID") and filter(amount > 500).** **Convention note:** The statements shown create Query objects; execution/iteration or .all() is needed to fetch the matching rows. Python Boolean coercion of SQL expressions is not a replacement for SQLAlchemy’s expression operators. A: **Incorrect:** Python or is not SQL OR/AND; here the equality’s false truth value causes the amount condition to be used alone. B: **Correct:** Chained filters combine both SQL predicates and select exactly IDs 3 and 5. C: **Incorrect:** Python and combines two Query objects rather than their SQL filters; it yields the second query and loses the status requirement. D: **Incorrect:** This queries a Boolean expression rather than Order rows and does not encode the required SQL conjunction.

Report a correction for Q3

Question 4 MCQ · 3.0 marks

Consider the following models: Course and Enrollment corresponding to tables course and enrollment in SQLite database.
Source diagram or notation
Based on the model schemas, what relationship do the classes Course and Enrollment share?
6406537086434.
Many-to-Many
6406537086435.
One-to-Many
6406537086436.
One-to-One
6406537086437.
The tables are not at all related

Published solution

**1. Locate the foreign key:** Enrollment.course_id references Course.id. Each non-null Enrollment.course_id can therefore identify one Course. **2. Check for uniqueness:** There is no unique constraint on Enrollment.course_id, so several Enrollment rows can reference the same Course. The unique primary key Enrollment.id identifies enrollments individually, not courses. **3. State the direction:** From Course to Enrollment the relationship is one-to-many; from Enrollment to Course it is many-to-one. No secondary association between these two classes makes their direct relationship many-to-many. **Answer: B — One-to-Many.** **Convention note:** The source does not mark course_id nullable=False, so an enrollment may have no course reference if nulls are permitted. This optionality does not change the maximum one-to-many cardinality. A: **Incorrect:** Each enrollment row has only one course_id, so the direct Course–Enrollment relationship is not many-to-many. B: **Correct:** One course can be referenced by multiple enrollment rows. C: **Incorrect:** A unique constraint on course_id would be needed to restrict each course to at most one enrollment. D: **Incorrect:** The foreign key explicitly relates the tables.

Report a correction for Q4

Question 5 MCQ · 3.0 marks

Consider the following Python code. File name: decorator.py
Source diagram or notation
What will be the output, when running the above code using the command "python decorator.py"?
6406537086438.Source diagram or notation
6406537086439.Source diagram or notation
6406537086440.Source diagram or notation
6406537086441.Source diagram or notation

Published solution

**1. Apply the decorator:** @loggerDecorator replaces the name getData with inner_wrapper, while the wrapper retains a reference to the original getData as func. **2. Follow the wrapper:** Calling getData() first prints Function execution started. It then calls the original func twice; each call returns the string Data retrieved without printing it. **3. Follow the outer print:** The wrapper returns the tuple (res1,res2). Therefore print(getData()) prints two lines: first Function execution started, then ('Data retrieved', 'Data retrieved'). Returned values are not automatically printed as separate lines. **Answer: C — Function execution started, then ('Data retrieved', 'Data retrieved').** A: **Incorrect:** The wrapper prints its start message before returning the tuple, not after it. B: **Incorrect:** The two inner calls return strings; they do not print two separate Data retrieved lines. C: **Correct:** The start message appears first, followed by the returned tuple printed by the outer print. D: **Incorrect:** Both the placement of the message and the separate string outputs are incorrect.

Report a correction for Q5

Question 6 MCQ · 3.0 marks

Which of the following statements is correct? **Statement 1**: In Server-Side Rendering (SSR), the client's browser receives a nearly empty HTML skeleton and relies heavily on client-side JavaScript execution to fetch data and construct the Document Object Model (DOM). **Statement 2**: Client-Side Rendering (CSR) reduces the immediate processing load on the web server by offloading UI layout rendering tasks to the user's browser engine.
6406537086454.
Both are incorrect
6406537086455.
Both are correct
6406537086456.
Only Statement 1 is correct
6406537086457.
Only Statement 2 is correct

Published solution

**1. Check the SSR description:** Server-side rendering generates page HTML on the server and sends populated markup to the browser. It may later use client JavaScript for interaction or hydration, but an almost-empty shell constructed mainly in the browser describes CSR instead. Thus statement 1 is false. **2. Check the CSR description:** In client-side rendering, the browser executes JavaScript to construct and update the UI. This shifts much of the UI-generation work away from server-rendering each page, so statement 2 describes the intended reduction in immediate rendering work on the server. **Answer: D — only Statement 2 is correct.** **Convention note:** CSR does not eliminate server-side API, authentication or data-processing work, and it does not guarantee lower total server cost for every application. Browsers also perform final layout/painting after receiving SSR HTML. A: **Incorrect:** Statement 2 correctly describes the rendering-work shift. B: **Incorrect:** Statement 1 mislabels the CSR-style empty-shell behavior as SSR. C: **Incorrect:** Statement 1 is false and statement 2 is true. D: **Correct:** Only statement 2 correctly describes CSR’s allocation of UI-rendering work.

Report a correction for Q6

Question 7 MCQ · 3.0 marks

A recipe webpage needs to display two distinct sections: 1. A list of ingredients where the **order does not matter.** 2. A sequence of cooking steps that **must be followed in order.** Which combination of HTML list container tags is most appropriate for these sections?
6406537086459.Source diagram or notation
6406537086460.Source diagram or notation
6406537086461.Source diagram or notation
6406537086462.Source diagram or notation

Published solution

**1. Match list semantics to ingredients:** When order is not meaningful, use an unordered list container, ul, with each ingredient in an li element. **2. Match list semantics to instructions:** Cooking steps form a meaningful sequence, so use an ordered list container, ol, with each step in an li. The ordering is semantic, not merely a choice of bullet or number styling. **Answer: D — Ingredients: ul; Cooking Steps: ol.** A: **Incorrect:** An ordered list suggests a meaningful sequence for the ingredients, which the prompt says is unnecessary. B: **Incorrect:** The ingredient list is suitable, but the cooking sequence should be an ordered list. C: **Incorrect:** A description list dl is for name–description groups, and the steps should not use ul. D: **Correct:** ul fits the unordered ingredients and ol fits the sequential cooking steps.

Report a correction for Q7

Question 8 MCQ · 3.0 marks

Consider the following Python jinja2 templating code.
Source diagram or notation
6406537086463.
Nothing will be rendered in place of **x**
6406537086464.
0
6406537086465.
1
6406537086466.
2

Published solution

**1. Track the loop-local assignments:** range(3) yields i=0,1,2. The {% set x=i %} statement assigns x within the loop’s local scope; it does not create a persistent outer-scope x. **2. Evaluate the expression outside the loop:** After {% endfor %}, x is undefined in the surrounding template context. Under Jinja’s default Undefined behavior, rendering {{ x }} produces an empty string. **3. Distinguish empty interpolation from no output at all:** The template can still emit whitespace/newlines, and print adds a newline. The selected option means no text replaces x, not that the entire process writes zero bytes. **Answer: A — nothing is rendered in place of x.** **Convention note:** This uses the default Undefined class shown by Template(...). StrictUndefined would instead raise an undefined-variable error; a namespace object can be used when deliberate cross-loop mutation is needed. A: **Correct:** The loop-local x does not survive outside the loop and default undefined interpolation is empty. B: **Incorrect:** The first iteration’s x is not exported to the outer context. C: **Incorrect:** The second iteration’s value is also loop-local. D: **Incorrect:** Unlike an ordinary Python loop variable, this Jinja set assignment does not expose the last value outside the loop.

Report a correction for Q8

Question 9 MSQ · 5.0 marks

Consider the following flask app.
Source diagram or notation
If the application is running locally on http://127.0.0.1:5000, select the correct options.
6406537086413.Source diagram or notation
6406537086414.Source diagram or notation
6406537086415.Source diagram or notation
6406537086416.Source diagram or notation

Published solution

**1. Parse the dynamic path independently of the query string:** The path converter captures slash-containing subject strings such as ML/Python. The test is the case-sensitive substring check "Python" in subject. Query parameters such as topic or level do not alter subject. **2. Follow direct and redirected successes:** /course/ML/Python?topic=NLP directly returns Welcome to Python course!. /learn/basics/Python?level=beginner passes the same substring check and redirects to /course/basics/Python, which returns that welcome message. **3. Check the two other URLs:** /learn/web/Python?level=advanced also redirects and displays the welcome, so A’s claimed error page is false. /course/Java/React?type=Framework lacks Python and calls abort(404), whose handler displays Course not available!. **4. Distinguish body text from status:** The custom error handler returns only a string, so Flask uses status 200 for that handled response unless the handler explicitly returns the 404 status too. This does not change the rendered text asked about. **Answer: B, C, D — B, C and D.** **Convention note:** A browser normally follows the 302 redirect; a command-line client that does not follow redirects would initially see the redirect response. The custom handler omits “, 404”, so its displayed unavailable page is returned with HTTP 200 in this exact code. A: **Incorrect:** The path contains Python, so this URL redirects to the welcome page, not the claimed unavailable message. B: **Correct:** The path subject ML/Python contains Python and directly returns the welcome text. C: **Correct:** The learning route redirects to the matching course route and the browser displays the welcome text. D: **Correct:** Java/React lacks Python, so the custom handler displays Course not available!.

Report a correction for Q9

Question 10 MCQ · 5.0 marks

Consider the following Flask application structure and code.
Source diagram or notation
Source diagram or notation
Which of the following statements about the template rendering behavior is correct?
6406537086417.
All routes will work correctly as Flask searches both
Source diagram or notation
and
Source diagram or notation
6406537086418.
Only
Source diagram or notation
and
Source diagram or notation
routes work, while
Source diagram or notation
and
Source diagram or notation
routes fail with
Source diagram or notation
Error
6406537086419.
The
Source diagram or notation
and
Source diagram or notation
routes work, while
Source diagram or notation
and
Source diagram or notation
fail with
Source diagram or notation
Error
6406537086420.
All routes fail because Flask requires templates to be in a default folder

Published solution

**1. Identify the configured template root:** Flask(__name__, template_folder="my_templates") sets this application’s loader to the my_templates directory. It does not additionally search the default templates directory merely because that directory exists. **2. Resolve the successful relative names:** public/home.html and private/dashboard.html are both beneath my_templates, so the / and /dashboard routes can render them. **3. Resolve the failing names:** render_template("index.html") looks for my_templates/index.html, not views/index.html. Similarly page.html is only in the separate templates directory, so /view and /page raise TemplateNotFound. **Answer: C — / and /dashboard work; /view and /page fail with TemplateNotFound.** **Convention note:** This assumes the shown HTML files have no additional missing includes or inheritance requirements and no unshown blueprints/custom loaders add search paths. A: **Incorrect:** A custom template_folder replaces the default application template directory; it does not automatically combine both. B: **Incorrect:** /view fails and / succeeds, opposite to the claimed pair. C: **Correct:** The two nested template paths exist under the configured root; index.html and page.html do not. D: **Incorrect:** Flask supports custom template directories, so not all routes fail.

Report a correction for Q10

Question 11 MCQ · 2.0 marks

What does the following curl command do?
Source diagram or notation
6406537086421.
Sends a PUT request to update data using form format.
6406537086422.
Sends a PUT request using JSON encoding.
6406537086423.
Sends a GET request to retrieve user information.
6406537086424.
Sends a DELETE request to remove user data.

Published solution

**1. Read the request method:** The -X PUT flag explicitly selects the HTTP PUT method. The URL identifies the API endpoint being contacted. **2. Read the data encoding:** -d "status=active&role=admin" sends the body as form-style key–value data. With the shown options, curl uses application/x-www-form-urlencoded, not application/json. **3. State what the command requests:** It sends a PUT request carrying status=active and role=admin as form data. Whether the server accepts or applies that update depends on its API implementation; the command itself does not guarantee a database change. **Answer: A — a PUT request carrying form-encoded update data.** A: **Correct:** Both the method and form-style encoding match the command. B: **Incorrect:** The body is form encoded, not JSON, and no JSON content type is supplied. C: **Incorrect:** -X PUT overrides a GET interpretation. D: **Incorrect:** The selected method is PUT, not DELETE.

Report a correction for Q11

Question 12 MCQ · 2.0 marks

In the context of asynchronous updates, which of the following statements is correct?
6406537086450.
It updates a web page without reloading the whole page
6406537086451.
It leads to better user experience as it involves quick response on the main page with minimal data to refresh
6406537086452.
Both It updates a web page without reloading the whole page and It leads to better user experience as it involves quick response on the main page with minimal data to refresh are correct
6406537086453.
None of these

Published solution

**1. Explain an asynchronous update:** Browser code can request data and update selected DOM elements without navigating to a new document or reloading the entire page. The user can usually continue interacting while the request is pending. **2. Connect that behavior to user experience:** Updating only the necessary data can reduce transferred content and preserve the rest of the page’s state. Thus both the partial-update description and the stated potential UX advantage are the intended correct statements. **Answer: C — both statements are correct.** **Convention note:** Asynchronous updates can improve responsiveness; they do not guarantee a fast server response or good UX for every implementation. Proper loading, error and accessibility handling still matters. A: **Incorrect:** This statement is true, but the combined option also includes the second intended true statement. B: **Incorrect:** This is the intended benefit, but the combined option is the most complete answer. C: **Correct:** Both descriptions are correct in the intended partial-page-update context. D: **Incorrect:** The first statement is correct, so “None” cannot be right.

Report a correction for Q12

Question 13 MCQ · 4.0 marks

Consider the following Flask RESTful API code.
Source diagram or notation
What will be the response?
6406537086425.
{"n": 3}
6406537086426.
Runtime error
6406537086427.
400 Bad Request
6406537086428.
{ }

Published solution

**1. Identify the accepted endpoint and payload:** MyResponse defines post, and the curl command sends POST to / with Content-Type: application/json and the JSON object {"n":3}. The shell quoting produces a valid JSON body. **2. Parse and validate the required argument:** RequestParser requires n and converts it with int. The supplied numeric value 3 is present and valid, so parse_args returns a mapping with n equal to integer 3. **3. Serialize the response:** Returning that mapping from a Flask-RESTful Resource serializes it as a JSON object. The response is {"n":3}, with the ordinary successful status 200; the exact spaces/newline are not significant. **Answer: A — {"n": 3}.** A: **Correct:** The required integer argument is present and is returned in the parsed mapping. B: **Incorrect:** The shown valid request does not trigger a parsing or method-signature exception. C: **Incorrect:** 400 would arise for an absent or invalid required n, not this valid integer payload. D: **Incorrect:** The parser retains the valid required field n, so the returned object is not empty.

Report a correction for Q13

Question 14 NAT · 2.0 marks

A magnetic disk can spin only in one direction with a constant speed of 6000rpm. What is the maximum delay (worst-case latency) before data transfer starts (in milliseconds)?

Published solution

**1. Convert rotational speed:** \(6000\ rpm=6000/60=100\) revolutions per second. **2. Calculate one revolution’s duration:** \(T=1/100\) seconds = 0.01 seconds = 10 milliseconds. **3. Use the worst angular position:** If the required sector has just passed the head, the wait can approach one complete revolution. Thus worst-case rotational latency is conventionally 10 ms. Average rotational latency would be half a revolution, 5 ms. **Answer: 10.** **Convention note:** The question is interpreted as rotational latency only. Seek, controller overhead and transfer time are not specified and are not added. The precise continuous worst-case wait approaches the full-period bound.

Report a correction for Q14

Question 15 MSQ · 4.0 marks

Consider the following Flask app code.
Source diagram or notation
The above flask app is running on "http://127.0.0.1:5000". Which of the following commands will return a runtime error?
6406537086442.Source diagram or notation
6406537086443.Source diagram or notation
6406537086444.Source diagram or notation
6406537086445.Source diagram or notation

Published solution

**1. Match URL variables to method parameters:** The /users route supplies no user_id. The /users/<int:user_id> route supplies user_id as a keyword argument to whichever resource method handles the request. **2. Evaluate GET:** get(self) accepts no user_id, so GET /users/5001 passes an unexpected keyword argument and raises TypeError. GET /users supplies none and succeeds with {"status":"GET request"}, status 200. **3. Evaluate POST:** post(self,user_id) requires that argument. POST /users/5001 supplies 5001 and succeeds with status 201 and its user_id field. POST /users supplies no argument, causing TypeError for the missing required user_id. **4. Select the runtime errors:** They are GET on the variable route (A) and POST on the nonvariable route (C), rather than ordinary method-not-allowed errors. **Answer: A, C — GET /users/5001 and POST /users.** **Convention note:** In a normal server response these uncaught TypeErrors produce HTTP 500; with debug/testing exception propagation, a debugger or test client can surface the underlying TypeError instead. A: **Correct:** The route supplies user_id to get, but get accepts only self, causing TypeError. B: **Incorrect:** The route supplies the required integer user_id to post, so this succeeds with 201. C: **Correct:** post requires user_id, but this route supplies none, causing TypeError. D: **Incorrect:** get takes no URL argument, matching the /users route and returning 200.

Report a correction for Q15

Question 16 MSQ · 2.0 marks

Which of the following statements is/are true about Document Object Model (DOM)?
6406537086446.
It is the programming interface for web documents.
6406537086447.
It is the abstract model of the document.
6406537086448.
Its structure is rigid and cannot be changed once created.
6406537086449.
It can only be manipulated with the help of JavaScript.

Published solution

**1. Define the DOM:** The Document Object Model represents a web document as objects, including nodes for elements and text, together with APIs for inspecting and changing them. It is both an abstract object model and a programming interface. **2. Explain mutation:** Scripts or other host-language bindings can insert, remove or change nodes and attributes after creation. The model is therefore not rigid, and its definition is not restricted to JavaScript even though JavaScript is the usual browser language. **Answer: A, B — a programming interface and an abstract document model.** A: **Correct:** The DOM supplies programmatic access to document objects and operations. B: **Correct:** It is an abstract structured object representation of the document. C: **Incorrect:** DOM nodes and their relationships can be changed dynamically. D: **Incorrect:** JavaScript is common in browsers, but DOM interfaces are language-independent and can have other bindings.

Report a correction for Q16

Question 17 NAT · 3.0 marks

An e-commerce web application stores user shopping cart information as server-side session state. Each active user session occupies an average of 4 KB of memory. During a flash sale, the application is expected to handle 1.5 million concurrent active sessions, all stored in a centralized Redis cache server. What is the minimum RAM capacity (in GB) required solely to store these session states? (Assume that 1000B=1KB, 1000KB=1MB and so on)

Published solution

**1. Multiply sessions by storage per session:** \(1500000\cdot4\ KB=6000000\ KB\). Every active session must be represented; using an average state size is the assumption supplied. **2. Convert using the specified decimal units:** Divide by 1000 to get 6000 MB, then divide by 1000 again to get 6 GB. Equivalently, \(1500000\cdot4000=6000000000\) bytes. **3. State the requested minimum:** Session payloads alone require 6 GB. This is not a practical full Redis-server RAM recommendation because metadata, allocator overhead, replication buffers and the operating system are excluded by the question. **Answer: 6.**

Report a correction for Q17