Quiz Space

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

Question 4: Consider the following Python code snippet. Filename: cod…

Question 4

+3 marksOne correct option

Consider the following Python code snippet.

Filename: code.py

python
from string import Template as string_template
from jinja2 import Template as jinja_template
template1 = string_template('Hello $name, welcome to $city!')
template2 = jinja_template('{{product}} costs {{price}}')
result1 = template1.substitute(name='Alice')
result2 = template1.substitute(name='Alice', city='Boston', state='Massachusetts')
result3 = template2.render({"product": "laptop"})
result4 = template2.render({"product": "laptop", "price": "45000", "currency": "rupees"})
print(result1)
print(result2)
print(result3)
print(result4)

Which of the following statements will throw a key error?

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

Correct answer

  • A

Question 4 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. Q5What will be the output of the following Jinja2 template when rendered in Flask?
  5. Q6Consider the following Flask code snippet: Assume the above code is running on server http://127.0.0.1:5000/ . What wil…
  6. Q7Consider the following code: What will be the color of the paragraph text when rendered in a browser?
  7. Q8Consider the following Python file “output.py” File: “output.py” Which of the following code snippet when placed at \<!…
  8. Q9Consider the following Python code snippet: main.py We are executing above main.py in command line with command python …
  9. Q10We want to use an online grammar checking tool, which takes each word from the client and sends it to the web server. T…
  10. Q11Consider a client which is located 3000 km from the server makes a request through the cable. Suddenly after the reques…
  11. Q12Consider the following Python code snippet and answer the given subquestions Filename: webapp.py
  12. Q13Consider the following Python code snippet and answer the given subquestions Filename: webapp.py
  13. Q14Consider the following Python code snippet and answer the given subquestions Filename: webapp.py
  14. Q15Given the following code, answer the given subquestions:
  15. Q16Given the following code, answer the given subquestions: