Please login


Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video

Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

Doctor’s fees

doctor fee's coding question

Doctor’s Fees

This is one of the previous year questions of TCS NQT 2020. The question is a basic implementation of situation testing, i.e; on the basis of the given situation you need to output the correct answer

Doctor Fee’s Coding Question

Problem Statement

A doctor has a clinic where he serves his patients. The doctor’s consultation fees are different for different groups of patients depending on their age. If the patient’s age is below 17, fees is 200 INR. If the patient’s age is between 17 and 40, fees is 400 INR. If patient’s age is above 40, fees is 300 INR. Write a code to calculate earnings in a day for which one array/List of values representing age of patients visited on that day is passed as input.


  • Age should not be zero or less than zero or above 120
  • Doctor consults a maximum of 20 patients a day
  • Enter age value (press Enter without a value to stop):

Example 1:

  • Input
  • Output
    Total Income 2000 INR

Note: Input and Output Format should be same as given in the above example.
For any wrong input display INVALID INPUT

Output Format

  • Total Income INR
age = []

for i in range(20):

    m = input()

    if m == "":


    elif int(m) in range(0,120):



        print("INVALID INPUT")


fees = 0

for i in age:

    if i < 17:


    elif i <40:




print("Total Income {} INR".format(fees))