Find the Batting Average of a batsman | Function to find the average of a batsman ; Calculate number of dismissals ; check for 0 times out ; Calculate batting average ; Driver Program
def averageRuns ( runs , matches , notout ) : NEW_LINE INDENT out = matches - notout ; NEW_LINE if ( out == 0 ) : NEW_LINE INDENT return - 1 ; NEW_LINE DEDENT avg = runs // out ; NEW_LINE return avg ; NEW_LINE DEDENT runs = 10000 ; NEW_LINE matches = 250 ; NEW_LINE notout = 50 ; NEW_LINE avg = averageRuns ( runs , matches , notout ) ; NEW_LINE if ( avg == - 1 ) : NEW_LINE INDENT print ( " NA " ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( avg ) ; NEW_LINE DEDENT