**1. Identify the list semantics:** dl contains description terms dt and descriptions dd. The terms are Flask and SQLAlchemy; each is followed by its description.
**2. Apply ordinary browser defaults:** The descriptions are displayed on separate lines and indented relative to their terms. No bullets or hyphens are generated by this markup.
**Answer: A — Flask and SQLAlchemy terms, each followed by its indented description.**
A: **Correct:** Both descriptions are indented under their corresponding terms.
B: **Incorrect:** This removes the ordinary indentation of the description entries.
C: **Incorrect:** The markup does not introduce literal hyphens.
D: **Incorrect:** Both descriptions are dd elements, so there is no reason for only one to be indented.
**1. Register the endpoint:** The route decorator must precede def score() so Flask registers the function at /score.
**2. Render the template with data:** render_template("score.html",mayur=50,manoj=45) loads the HTML template and supplies the two scores as context variables.
**Answer: B — The decorated view returning render_template("score.html", mayur=50, manoj=45).**
**Convention note:** Assume the app is reachable at the host/port being used and render_template is imported; the question tests the route and template call.
A: **Incorrect:** render is not the specified Flask template-rendering function.
B: **Correct:** The route placement and render_template call with context are correct.
C: **Incorrect:** The decorator is after the function and not applied to it; the shown placement is also syntactically incomplete.
D: **Incorrect:** Returning a filename with keyword assignments is not valid template-rendering syntax.
**1. Identify selector matches:** .container p.highlight selects every highlighted paragraph anywhere inside .container, including the nested “Important information” paragraph. It does not select the span or the highlighted paragraph outside the container.
**2. Resolve the competing blue rule:** The red selector has specificity (0,2,1), while .content .special has (0,2,0). Red wins for the nested special paragraph despite the blue rule appearing later. Thus the inside welcome, important-information and footer paragraphs are red.
**Answer: C — All highlighted paragraph descendants of .container.**
A: **Incorrect:** The span is green, and the outside highlighted paragraph is not selected by the red rule.
B: **Incorrect:** A descendant selector also reaches nested paragraphs, not only direct children.
C: **Correct:** All highlighted paragraph descendants match the winning red selector.
D: **Incorrect:** More than the first paragraph matches: the nested special and footer paragraphs do too.
**1. Check strict dollar substitution:** template1 contains both $name and $city. Supplying only name leaves city missing, so template1.substitute(name="Alice") raises KeyError.
**2. Compare the other expressions individually:** Adding city satisfies both placeholders; an extra state key is harmless. Under default Jinja Undefined behavior, a missing printed price renders empty instead of raising KeyError, and extra context keys are also harmless.
**Answer: A — template1.substitute(name="Alice").**
**Convention note:** The expressions are compared individually. In the complete script, the first uncaught KeyError stops execution before later result assignments and print statements. StrictUndefined would change Jinja’s missing-variable behavior, but it is not configured here.
A: **Correct:** The missing city placeholder raises KeyError.
B: **Incorrect:** Both needed keys are present; extra state is ignored.
C: **Incorrect:** Default Jinja prints a missing simple variable as empty text rather than raising KeyError.
D: **Incorrect:** All used Jinja values exist; extra currency is ignored.
**1. Evaluate the macro calls:** greet(name) emits “Hello, ” followed by the supplied name and an exclamation mark. The calls produce “Hello, Alice!” and “Hello, Bob!”.
**2. Distinguish source newlines from layout:** These are plain text in the body without paragraph or line-break elements. Normal HTML whitespace collapsing displays them on one line separated by a space.
**Answer: A — Hello, Alice! Hello, Bob!.**
A: **Correct:** The browser collapses the source whitespace and displays both greetings inline.
B: **Incorrect:** The macro is defined before it is used, so greet is not undefined.
C: **Incorrect:** Source newlines alone do not force separate browser lines in normal HTML flow.
D: **Incorrect:** Jinja evaluates the expressions rather than displaying their braces literally.
**1. Handle the first response:** The root view returns redirect(url_for("login")), which redirects the browser to /signin/user.
**2. Handle the destination:** login() returns url_for("login") itself as response text. That relative URL is /signin/user, so this is the final visible page content; the address bar separately contains the full destination URL.
**Answer: B — /signin/user.**
A: **Incorrect:** This is the full address-bar destination, not the response body returned by login().
B: **Correct:** url_for builds /signin/user and the destination view returns that string.
C: **Incorrect:** The browser is redirected away from the root, whose text is not this value.
D: **Incorrect:** The destination route exists.
**1. Compare specificity:** The paragraph matches p, .important and #highlight. An ID selector has higher specificity than a class selector or a type selector.
**2. Apply the winning declaration:** #highlight sets color:green. The later red class declaration cannot override the more-specific ID rule.
**Answer: B — Green.**
A: **Incorrect:** The type selector loses to both class and ID selectors.
B: **Correct:** The ID selector wins and assigns green.
C: **Incorrect:** Source order does not outweigh the ID selector’s higher specificity here.
D: **Incorrect:** An explicit matching color rule replaces the browser’s default text color.
{%for item in sl1|sort%}
<1i>{{item}}</li>
{xendfor%}
{%for item in sl.sort()%}
<1i>{{item}}</li>
{%endfor%}
6406534364668.
*
Published solution
**1. Supply the template data:** render(sl=l) provides sl=[5,4,3,2,1]. The desired unordered-list order is ascending.
**2. Use the Jinja filter:** sl|sort produces [1,2,3,4,5] without relying on an in-place Python sort. Looping over it emits a separate list item for each value.
**Answer: C — Loop over sl|sort.**
**Convention note:** The PDF restores the option boundaries: C is the sort-filter loop; D is the sl.sort() loop, although the export merges that text into C and represents D as an OCR artifact.
A: **Incorrect:** reverse=True sorts descending, opposite to the requested order.
B: **Incorrect:** Looping over sl without sorting preserves 5,4,3,2,1.
C: **Correct:** The default sort filter returns the required ascending sequence.
D: **Incorrect:** The Python list .sort() mutates and returns None, which cannot be iterated by this loop.
**1. Select only user arguments:** sys.argv starts with main.py. Passing v[1:] removes that filename and keeps the five strings "1" through "5".
**2. Join with separators:** ",".join(v) inside process joins its supplied list into “1,2,3,4,5”. Therefore the correct pair is the string join operation plus output=process(v[1:]).
**Answer: D — st=",".join(v); return st; output=process(v[1:]).**
A: **Incorrect:** Passing all of v includes main.py in the output.
B: **Incorrect:** There is no defined standalone join(v,",") function, and this also retains the filename.
C: **Incorrect:** Slicing the arguments is right, but the standalone join function is not defined.
D: **Correct:** The slice excludes the filename and the string method inserts commas correctly.
We want to use an online grammar checking tool, which takes each word from the client and
sends it to the web server. The available network bandwidth between the client and the server is 2
Gbps. What should be the maximum allowed size(in MBs) of a document containing the word sent
from the client to the server per second for the grammar check? (Use: 1KB= 1000Bytes,
1MB=1000KB and so on.)
Published solution
**1. Convert the bit rate:** \(2\text{ Gbps}=2\times10^9\) bits per second. Dividing by eight gives \(250\times10^6\) bytes per second.
**2. Convert to decimal MB:** One MB is \(10^6\) bytes as specified, so the maximum one-second transfer is 250 MB.
**Answer: 250.**
**Convention note:** This is an ideal bandwidth limit, ignoring protocol overhead, other traffic and processing time.
Consider a client which is located 3000 km from the server makes a request through the cable.
Suddenly after the request reaches the server, the cable breaks and the response is now to be
sent to the client via air. This change of medium caused an additional delay of 47 ms at the server
end. How long will the client have to wait before receiving the response (in ms)? ( speed on cable =
2e8 m/s and in air 3e8 m/s)
Published solution
**1. Outbound cable propagation:** Distance is \(3000\text{ km}=3\times10^6\text{ m}\). The request takes \((3\times10^6)/(2\times10^8)=0.015\text{ s}=15\text{ ms}\).
**2. Add server delay and air return:** The response propagation is \((3\times10^6)/(3\times10^8)=10\text{ ms}\). Including the additional 47 ms delay, total wait from request transmission is \(15+47+10=72\) ms.
**Answer: 72.**
**Convention note:** Count from the client’s original request, including both directions; serialization and other unspecified delays are ignored.
**1. Follow the intended condition:** For a successful Flask description, args[1] must be flask and args[2] must be the literal type. The dictionaries then map flask→python→server-side.
**2. Compare the commands:** B and C satisfy these requirements. The extra server-side argument in B is ignored because only the first two user arguments are read; both produce “flask is a server-side python framework.”
**Answer: B, C — B and C — flask type, with or without the ignored extra argument.**
**Convention note:** The printed code uses a single = in if args[2] = 'type', which is a Python SyntaxError. No command produces the requested output literally. The intended answers above assume that comparison is repaired to ==; all dictionary and argument reasoning then follows the shown program.
A: **Incorrect:** The second user argument is python rather than the required type.
B: **Correct:** The first two user arguments are flask and type; the extra argument is unused.
C: **Correct:** This supplies exactly the required two arguments.
D: **Incorrect:** type is not a key in the frameworks dictionary, so the outer condition fails.
E: **Incorrect:** The second user argument is server-side rather than type.
**1. Validate the arguments:** For webapp.py react type, args[1]=react is a known framework and args[2]=type satisfies the intended comparison.
**2. Resolve dictionary lookups:** frameworks["react"] is javascript and languages["javascript"] is client-side. The rendered sentence is “react is a client-side javascript framework.”
**Answer: A — react is a client-side javascript framework..**
**Convention note:** As in the shared listing, replace the erroneous single = in the if comparison with ==. Without that syntactic repair the whole script fails before processing any command. The sentence reflects the example dictionary, not a complete taxonomy of React.
A: **Correct:** This follows both dictionary lookups.
B: **Incorrect:** The program maps react to javascript, not python.
C: **Incorrect:** The intended second argument test succeeds.
D: **Incorrect:** The framework key exists and enough arguments are supplied.
**1. Pass the outer test:** django is a key in frameworks and the command supplies two user arguments, so the outer condition succeeds. language becomes python.
**2. Fail the inner test:** The second user argument is python, not the required literal type. The inner else prints “Invalid second argument or language not found!”.
**Answer: C — Invalid second argument or language not found!.**
**Convention note:** The shared listing’s single = in the if condition must be repaired to == before this intended branch trace can execute; otherwise the script has SyntaxError.
A: **Incorrect:** The command does not pass the inner condition, so no description sentence is rendered.
B: **Incorrect:** Even though Django maps to server-side Python, the command’s second argument fails validation.
C: **Correct:** The failing inner comparison selects this message.
D: **Incorrect:** The outer condition succeeds, so its Invalid command branch is not selected.
**1. Parse the supplied values:** gender remains the original string FeMaLe for display. The suffix lb selects conversion: \(154\times0.453592=69.853168\) kg.
**2. Compute the displayed value:** gender.lower() is female, so the code uses 0.75: \(69.853168\times0.75=52.389876\). round gives 52 and int preserves it. The page shows FeMaLe, 154lb and 52 grams.
**Answer: B — Gender: FeMaLe; Weight: 154lb; Recommended Intake: 52 grams.**
**Convention note:** This is a trace of the supplied example formula, not individualized nutritional guidance.
A: **Incorrect:** These are the default query values, but the request explicitly supplies others.
B: **Correct:** This preserves the original query strings and rounds the code’s computed value to 52.
C: **Incorrect:** Seventy is approximately the converted weight, not the multiplied result.
D: **Incorrect:** The code does not lowercase gender for display, and the computed result is 52, not 70.
**MLF**
**Section Id :** 64065392557
**Section Number :** 6
**Section type :** Online
**Mandatory or Optional :** Mandatory
**Number of Questions :** 13
Published solution
**1. Parse weight without a suffix:** The supplied string 60 matches neither kg nor lb, so float("60") gives 60 kg for calculation. The display still receives the original weight_raw string 60.
**2. Compute and render:** FEMALE.lower() is female, so the code returns \(60\times0.75=45\), which rounds to integer 45. The page displays FEMALE, 60 and 45 grams.
**Answer: B — Gender: FEMALE; Weight: 60; Recommended Intake: 45 grams.**
**Convention note:** The formula is the one in the exercise and is evaluated only as program behavior.
A: **Incorrect:** The route supplies all template values, so they are not blank.
B: **Correct:** The exact supplied strings and the calculated 45 match.
C: **Incorrect:** The calculation is right, but the template prints 60, not an added kg suffix.
D: **Incorrect:** The explicitly supplied gender and weight replace the defaults, and the result is 45.