Quiz Space

Programming in Python · End Term · 31 Aug 2025 · May 2025 term · Set QDF1

Question 17: Consider the following Python code and answer the sub-qu…

Question 17

+1 markNumerical answer

Consider the following Python code and answer the sub-questions:
students = [
{
"name": "Arya",
"subjects": {
"Math": 78, "Science": 88, "English": 92
}
},
{
"name": "Bilal",
"subjects": {
"Math": 65, "Science": 55, "English": 60
}
},
{
"name": "Chitra",
"subjects": {
"Math": 45, "Science": 40, "English": 42
}
},
{
"name": "Deep",
"subjects": {
"Math": 90, "Science": 91, "English": 85
}
},
{
"name": "Esha",
"subjects": {
"Math": 35, "Science": 39, "English": 55
}
},
]
def filter_and_rank(data):
eligible = []
for student in data:
marks = list(student["subjects"].values())
passed = 0
high = 0
for mark in marks:
if mark >= 40:
passed += 1
if mark >= 90:
high += 1
if passed == len(marks) and high > 0:
total = sum(marks)
eligible.append((student["name"], total))
eligible.sort(key=lambda x: x[1], reverse=True)
return [name for name, _ in eligible]

If a new student {"name": "Fatima", "subjects": {"Math": 90, "Science": 90, "English": 90}} is added to the list, what will be the new position (1-based index) of Fatima in the ranked output list returned by filter_and_rank ?

Show answer

Correct answer: 1

Question 17 of 20 in the IIT Madras BS Programming in Python (Python) End Term paper sat on 31 Aug 2025, in the May 2025 term (IIT M FOUNDATION AN EXAM QDF3 31 Aug 2025). It carries 1 mark.

More questions from this paper

  1. Q1What will be the output of the following Python code?\ words = ["jacket", "cap", "scarf", "hat", "sock"]\ result = []\ …
  2. Q2Consider the following Python code:\ def evaluate_score(score):\ if score >= 90:\ if score == 100:\ print("Perfect Scor…
  3. Q3Consider the following Python code:\ class Employee:\ def init(self, name):\ self.name = name\ self.role = "Employee"\ …
  4. Q4What will be the total number of lines printed when the following code is executed? scores = {\ "Aarav": [10, 20, 30],\…
  5. Q5What will be the output of the following code snippet?\ data = [(4, 7), (5, 8), (6, 6), (9, 3)]\ total = 0\ for a, b in…
  6. Q6What will be the output of the following code?\ items = ["apple", "banana", "cherry", "date", "fig", "grape", "kiwi"]\ …
  7. Q7Consider the use of the map() function in the following code snippets. Select all options that has the value [4, 9, 16,…
  8. Q8Which of the following statements about the exception handling behavior are TRUE? Select ALL that apply.\ def safe_divi…
  9. Q9Consider the following code snippet:\ def update_scores(scores, bonus):\ updated = []\ for score in scores:\ updated.ap…
  10. Q10Consider the following Python code:\ names = ["Aarav", "Bhuvan", "Charan", "Deepa"]\ marks = [88, 76, 92, 81]\ bonus = …
  11. Q11Consider the following Python code:\ with open("data.txt", "w") as f:\ for i in range(3):\ for j in range(i + 1):\ f.wr…
  12. Q12Consider the following Python code:\ a1 = (3, 6, 9, 12, 15, 18, 21, 24)\ a2 = a1[2:7]\ a3 = a2[::-1]\ a4 = tuple(x for …
  13. Q13Consider the following Python code:\ def transform(words):\ if not words:\ return []\ first = words[0][::-1]\ if first …
  14. Q14Consider the following Python code snippet:\ colors = ['red', 'blue', 'green', 'red', 'blue', 'red', 'yellow']\ freq = …
  15. Q15Consider the following Python code and answer the sub-questions:\ students = [\ {\ "name": "Arya",\ "subjects": {\ "Mat…
  16. Q16Consider the following Python code and answer the sub-questions:\ students = [\ {\ "name": "Arya",\ "subjects": {\ "Mat…
  17. Q18Consider the following Python code and answer the sub-questions:\ class Vehicle:\ total_vehicles = 0\ all_models = []\ …
  18. Q19Consider the following Python code and answer the sub-questions:\ class Vehicle:\ total_vehicles = 0\ all_models = []\ …
  19. Q20Consider the following Python code and answer the sub-questions:\ class Vehicle:\ total_vehicles = 0\ all_models = []\ …