Quiz Space

Modern Application Development I · Quiz 1 · 13 Jul 2025 · May 2025 term

MAD 1 Quiz 1 13 Jul 2025 — Question 16

Question 16

+3 marksOne correct option

Given the following code, answer the given subquestions:

python
from flask import Flask, request, render_template_string
app = Flask(__name__)
template = """
<!DOCTYPE html>
<html>
<head><title>Protein RDA</title></head>
<body>
<h2>Recommended Daily Protein Intake</h2>
<p>Gender: {{ gender }}</p>
<p>Weight: {{ weight_raw }}</p>
<p>Recommended Intake: <strong>{{ rda }} grams</strong></p>
</body>
</html>
"""
def parse_weight(weight_raw):
if weight_raw.endswith('kg'):
return float(weight_raw[:-2])
elif weight_raw.endswith('lb'):
return float(weight_raw[:-2]) * 0.453592
return float(weight_raw)
def protein_rda(gender, weight_kg):
return weight_kg * (0.8 if gender.lower() == 'male' else 0.75)
@app.route('/protein', methods=['GET'])
def protein():
gender = request.args.get('gender', 'male')
weight_raw = request.args.get('weight', '60kg')
weight_kg = parse_weight(weight_raw)
rda = int(round(protein_rda(gender, weight_kg)))
return render_template_string(template, gender=gender, weight_raw=weight_raw, rda=rda)
app.run(debug=True)
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 16 of 16 in the IIT Madras BS Modern Application Development I (MAD 1) Quiz 1 paper sat on 13 Jul 2025, in the May 2025 term (IIT M DIPLOMA AN EXAM QDD2 13 July 2025). It carries 3 marks.

More questions from this paper

  1. Q1What will be the output of the following HTML code?
  2. Q2Figure question
  3. Q3Consider the following HTML code snippet. filename: index.html Which elements from the above document will have a red b…
  4. Q4Consider the following Python code snippet. Filename: code.py Which of the following statements will throw a key error?
  5. Q5What will be the output of the following Jinja2 template when rendered in Flask?
  6. Q6Consider the following Flask code snippet: Assume the above code is running on server http://127.0.0.1:5000/ . What wil…
  7. Q7Consider the following code: What will be the color of the paragraph text when rendered in a browser?
  8. Q8Consider the following Python file “output.py” File: “output.py” Which of the following code snippet when placed at \<!…
  9. Q9Consider the following Python code snippet: main.py We are executing above main.py in command line with command python …
  10. Q10We want to use an online grammar checking tool, which takes each word from the client and sends it to the web server. T…
  11. Q11Consider a client which is located 3000 km from the server makes a request through the cable. Suddenly after the reques…
  12. Q12Consider the following Python code snippet and answer the given subquestions Filename: webapp.py
  13. Q13Consider the following Python code snippet and answer the given subquestions Filename: webapp.py
  14. Q14Consider the following Python code snippet and answer the given subquestions Filename: webapp.py
  15. Q15Given the following code, answer the given subquestions: