Physical Fitness - TCS NQT
Physical Fitness - TCS NQT
Problem:
A physical fitness test (running test) is conducted to select candidates for military training in a country. A batch of 3 candidates appearing for the running test on track for 3 rounds. The program must accept 9 integers indicating the oxygen level after each round for 3 candidates as the input. For each candidate, the program must calculate the average oxygen level over the 3 rounds. The candidate who has the highest average oxygen level is the most fit candidate. The program must print the string value "Candidate Number: " followed by the most fit candidate's number as the output. If more than one trainee attains the same highest average level, they all need to be printed.
Boundary Condition(s): 1 <= Oxygen level <= 100
Input Format: The first 3 lines, each contains an integer representing the oxygen level of the 3 candidates after the round 1. The middle 3 lines, each contains an integer representing the oxygen level of the 3 candidates after the round 2. The last 3 lines, each contains an integer representing the oxygen level of the 3 candidates after the round 3.
Output Format: The line(s), each contains the string value "Candidate Number: " followed by the most fit candidate's number.
Example Input/Output 1:
Input:
96 93 96 93 91 93 91 93 91
Output:
Candidate Number: 1
Candidate Number: 3
Explanation:
The oxygen level of candidate 1 after each round is 96 93 91 The oxygen level of candidate 2 after each round is 93 91 93 The oxygen level of candidate 3 after each round is 96 93 91 The average oxygen level of each candidate is 93.33, 92.33 and 93.33.
Here the candidate 1 and the candidate 3 have the highest average oxygen level.
Hence the output is
Candidate Number: 1
Candidate Number: 3
Example Input/Output 2:
Input:
92 86 95 85 85 87 82 82 82
Output:
Candidate Number: 3
Program:
candidate = [0, 0, 0]
for i in range(9):
oxygen_level = int(input())
candidate[i%3] += oxygen_level
for i in range(3):
if candidate[i] == max(candidate):
print("Candidate Number:",i+1)
Comments
Post a Comment