Skip to main content

TCS

TCS OA-21 2024

Problem Description

In a database containing information about N students, each student record has the following fields:

  • Name: A string representing the student's name.
  • Age: An integer representing the student's age.
  • Grade: A string of length 1 representing the student's grade (e.g., 'A', 'B', 'C').
  • Gender: A character representing the student's gender ('M' for male, 'F' for female).

Your task is to:

  1. Return a list of students who are older than 20 years.
  2. Calculate the average grade of female students using the ASCII values of their grade characters.

Input Format

  • An integer N representing the number of students.
  • A list of student records, where each record contains:
    • Name (string)
    • Age (integer)
    • Grade (string of length 1)
    • Gender (character)

Output Format

  • A list of students older than 20 years.
  • The average ASCII value of grades for female students.

Constraints

  • 1 ≤ N ≤ 10
  • Each Grade is a single character with an ASCII value between 65 ('A') and 90 ('Z').

Example

Sample Input:

4
[
    {"Name": "Alice", "Age": 22, "Grade": "A", "Gender": "F"},
    {"Name": "Bob", "Age": 19, "Grade": "B", "Gender": "M"},
    {"Name": "Clara", "Age": 23, "Grade": "C", "Gender": "F"},
    {"Name": "Dave", "Age": 25, "Grade": "B", "Gender": "M"}
]

Sample Output:

["Alice", "Clara", "Dave"]
68.5

Explanation:

Students older than 20: Alice, Clara, and Dave are older than 20.
Average ASCII of grades for females:ASCII of "A" = 65, ASCII of "C" = 67Average = (65 + 67) / 2 = 68.5